Authenticate to Django with JSON Web Tokens (JWTs) signed by Cloudflare Access
Project description
Authenticate to Django with JSON Web Tokens (JWTs) signed by Cloudflare Access. A Django reimplementation of https://developers.cloudflare.com/cloudflare-one/identity/authorization-cookie/validating-json/#python-example
To run the demo, export these environment variables
ALLOWEDFLARE_ACCESS_URL
https://your-organization.cloudflareaccess.comALLOWEDFLARE_AUDIENCE
64-character hexidecimal stringALLOWEDFLARE_PRIVATE_DOMAIN
your-domain.tld
Then run
docker-compose up
Configure Cloudflare Tunnel public hostname demodj.your-domain.tld to http://localhost:8001 or equivalent.
TODO
- Better login page
- Django REST Framework (DRF) support
- Grant users view permission to all models
- (Re-) authenticating proxy for different-domain front-ends, like https://developers.cloudflare.com/cloudflare-one/identity/authorization-cookie/cors/#send-authentication-token-with-cloudflare-worker but
- Setting username so it can be logged by gunicorn
- Rewriting origin redirects
- Setting the XmlHttpRequest(?) header to avoid redirects to the sign-in page
- Will the original CF_Authorization cookie need to be copied, similar to X-Forwarded-For?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file allowedflare-2024.10.0.tar.gz
.
File metadata
- Download URL: allowedflare-2024.10.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc2ccdcf363eb14eebadd798ab71e9152b130e58831d7ef864e5493bf34b57d3 |
|
MD5 | eb19686c2e4ba23fe2596187a5fea29f |
|
BLAKE2b-256 | 0eb60c76ac55c46ea56bac2b54a894ede9b544cc9dadd6d66415a3a18edc4959 |
File details
Details for the file allowedflare-2024.10.0-py3-none-any.whl
.
File metadata
- Download URL: allowedflare-2024.10.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4213b5a65fc44ec37f362b379aebf5b3f1cbd7aeacbe9531d293eaf8e1848d2 |
|
MD5 | 6cc5677e6954c8bb793cb830676e8b80 |
|
BLAKE2b-256 | d82018b3da53795db20d65894c73f32f7e5e0d898cfc5c754efdfed46264ae49 |