Nice HTTP authentication support for Django
Project description
Nice HTTP authentication support for Django
This is a common base for supporting multiple auth methods in an app.
Right now, we provide only the HTTP Basic auth module; but you can easily add your own specific schemes, if you need them, and more generic ones are going to be added in the future (see Planned features).
Requirements
- Django 2.0+
Installation
pip install dj-authentication
settings.py
- Add
'dj_authentication'
to the list ofINSTALLED_APPS
. - Remove
'django.contrib.auth.middleware.AuthenticationMiddleware'
from the list ofMIDDLEWARE
s. - Add
dj_authentication.request_http_auth.HTTPAuthMiddleware
to the list ofMIDDLEWARE
s. - Choose backends used for determining
request.user
, for example:
REQUEST_USER_BACKENDS = [
'dj_authentication.methods.basic', # HTTP Basic Auth
'django.contrib.auth',
]
Tips
To trigger an authentication dialog in a browser, if the user is not authenticated:
if not request.user.is_authenticated:
return HttpResponse(status=401)
Note: this requires dj_authentication.methods.basic
backend.
Planned features
- Support for Bearer scheme with JWT tokens verified against an OAuth/OIDC auth server thru
jwks_uri
- Support for Bearer scheme with opaque tokens verified against an OAuth/OIDC auth server thru Introspection Endpoint
- Support for client certificates (see also OAuth 2.0 Mutual TLS)
- Support for OIDC
private_key_jwt
scheme
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
Close
Hashes for dj_authentication-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 546d621aab227b6ccdc7ef1b9359dcc727462a5e18fd0d34e843ffadacd72122 |
|
MD5 | 15e5099018019cfcb33faff31a485c38 |
|
BLAKE2b-256 | c5de2962aa9df469e4a69155d33e8b036dcc89fc1863c23887e84ed5bfe5cf73 |