Skip to main content

HTTP Content Security Policy Manager

Project description

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

Installing

Install this library from PyPI:

pip3 install http-csp

Using this library

Parsing a CSP string:

policy = CSP("default-src 'self';")

returns a CSP object with a default_src attribute with value ["'self'"].

Generating a CSP string:

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;.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

http_csp-0.1.2.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

http_csp-0.1.2-py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page