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.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7fd01b7fb528ae3336d1c57e7ef875f76b294394be844af986f3bdece640156 |
|
MD5 | ebda09db84542cec0a2bb7d96e094195 |
|
BLAKE2b-256 | 1d0fdd09d7f4ea69562bbb12abc83fbcb088a949d1e3cc32ed0e3018902d0a07 |