Skip to content

Commit 68063c7

Browse files
authored
Packaging (#3)
There probably are better ways to do the includes / excludes.
1 parent 0f9eeef commit 68063c7

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

MANIFEST.in

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
exclude .*
2+
exclude *
3+
exclude .github/workflows/*
4+
exclude demodj/*
5+
include pyproject.toml

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
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
2+
3+
To run the demo, export these environment variables
4+
* `ALLOWEDFLARE_ACCESS_URL` https://your-organization.cloudflareaccess.com
5+
* `ALLOWEDFLARE_AUDIENCE` 64-character hexidecimal string
6+
* `ALLOWEDFLARE_PRIVATE_DOMAIN` your-domain.tld
7+
8+
Then run
9+
```
10+
docker-compose up
11+
```
12+
13+
Configure Cloudflare Tunnel public hostname demodj.your-domain.tld to http://localhost:8001 or equivalent.
14+
15+
### TODO
16+
* Better login page
17+
* Django REST Framework (DRF) support
18+
* Grant users view permission to all models
19+
* (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
20+
- Setting username so it can be logged by gunicorn
21+
- Rewriting origin redirects
22+
- Setting the XmlHttpRequest(?) header to avoid redirects to the sign-in page
23+
- Will the original CF_Authorization cookie need to be copied, similar to X-Forwarded-For?

pyproject.toml

+31-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,42 @@
1+
[build-system]
2+
requires = ['setuptools>=61.0', 'setuptools_scm[toml]>=6.2', 'wheel']
3+
build-backend = 'setuptools.build_meta'
4+
5+
[project]
6+
classifiers = [
7+
'Programming Language :: Python :: 3',
8+
'License :: OSI Approved :: BSD License',
9+
'Operating System :: OS Independent',
10+
'Topic :: Internet :: WWW/HTTP :: Session',
11+
]
12+
description = 'Authenticate to Django with JSON Web Tokens (JWTs) signed by Cloudflare Access'
13+
dependencies = [
14+
'cryptography',
15+
'pyjwt',
16+
'requests',
17+
]
18+
dynamic = ['version']
19+
name = 'allowedflare'
20+
readme = 'README.md'
21+
22+
[project.urls]
23+
Homepage = 'https://github.com/covracer/allowedflare'
24+
125
[tool.black]
226
line-length = 100
327
skip-magic-trailing-comma = true
428
skip-string-normalization = true
529

30+
[tool.django-stubs]
31+
django_settings_module = 'demodj.settings'
32+
633
[tool.ruff]
734
line-length = 100
835

936
[tool.mypy]
1037
plugins = ['mypy_django_plugin.main']
1138

12-
[tool.django-stubs]
13-
django_settings_module = 'demodj.settings'
39+
[tool.setuptools]
40+
packages = ['django_allowedflare']
41+
42+
[tool.setuptools_scm]

0 commit comments

Comments
 (0)