Metadata-Version: 2.1
Name: http-csp
Version: 0.1.2
Summary: HTTP Content Security Policy Manager
License: MIT
Author: Jacky Lam
Author-email: jacky.lam@r2studiohk.com
Requires-Python: >=3.9
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Project-URL: repository, https://github.com/jackylamhk/python-http-csp
Description-Content-Type: text/markdown

# python-http-csp
HTTP Content Security Policy Manager

A library to make parsing and generating CSP policies a little easier.

Read more about Content Security Policies: [https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)


## Installing
Install this library from PyPI:
```bash
pip3 install http-csp
```


## Using this library

Parsing a CSP string:

```python
policy = CSP("default-src 'self';")
```
returns a CSP object with a `default_src` attribute with value `["'self'"]`.

Generating a CSP string:

```python
policy = CSP()
policy.default_src = ["'self'"]
policy.image_src = ["*"]
policy.media_src = ["example.org", "example.net"]
generated_policy = policy.generate()
```
returns a string with the value `default-src 'self'; img-src *; media-src example.org example.net;`.
