Skip to content

Commit 7b8e773

Browse files
committed
docs: Create README
1 parent 603e3af commit 7b8e773

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# python-http-csp
2+
HTTP Content Security Policy Manager
3+
4+
A library to make parsing and generating CSP policies a little easier.
5+
6+
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)
7+
8+
9+
## Using this library
10+
11+
Parsing a CSP string:
12+
13+
```python
14+
policy = CSP("default-src 'self';")
15+
```
16+
returns a CSP object with a `default_src` attribute with value `["'self'"]`.
17+
18+
Generating a CSP string:
19+
20+
```python
21+
policy = CSP()
22+
policy.default_src = ["'self'"]
23+
policy.image_src = ["*"]
24+
policy.media_src = ["example.org", "example.net"]
25+
generated_policy = policy.generate()
26+
```
27+
returns a string with the value `default-src 'self'; img-src *; media-src example.org example.net;`.

0 commit comments

Comments
 (0)