Auth0 Authentication Backend for Django
Project description
#+CREATED: [2025-06-06 Fri 14:01]
django-auth0-auth
Authentication backend for Django with Auth0. As of June 2025, all of
the libraries that I saw for Django Auth0 target old versions of Django,
we'll start this by supporting version 5+ and python 3.11+ (3.10 only
has 1 year of life). Also, some of these don't actually subclass
Django's AuthBackend{.verbatim} and implement a login system that is
more "beside" Django than integrated with it. Because this is fully
integrated, we can use Django's built-in @login_required{.verbatim}
decorator and it's auth Mixins.
This project is not affiliated with Auth0.
Features:
- Fully automated end-to-end testing with Playwright to ensure Auth0 integration works correctly
- Complete Django authentication backend integration using Django's built-in auth system
- Support for modern Django (5+) and Python (3.11+) versions
The names are slightly confusing because there are a lot of one-off
projects (like this one) on PyPI that attempt the same thing. The repo
name here is django-auth0-auth{.verbatim}, the pypi name is
django-auth0-authbackend{.verbatim}, and the importable package is
auth0{.verbatim}. The installation instructions below reflect these
names.
Installation
Install the package from PyPI:
pip install django-auth0-authbackend
Usage
Take a look at the sample app provided in sample/{.verbatim} to see
how it's used in a MWE. There are only a few steps. First, include the
app in your apps in your Django settings:
INSTALLED_APPS = [
...,
"auth0",
]
Next, include the auth settings and auth backend (also in your Django settings):
AUTH0_CLIENT_ID = os.environ.get("AUTH0_CLIENT_ID")
AUTH0_CLIENT_SECRET = os.environ.get("AUTH0_CLIENT_SECRET")
AUTH0_DOMAIN = os.environ.get("AUTH0_DOMAIN")
AUTH0_AUDIENCE = os.environ.get("AUTH0_AUDIENCE")
AUTHENTICATION_BACKENDS = [
"auth0.backend.Auth0Backend",
]
Finally, include the urls in your project urls.py{.verbatim}:
from django.urls import path, include
urlpatterns = [
...,
path("auth0/", include("auth0.urls")),
]
Running the sample app
First, create an auth0 application.
Set up python however you prefer, I'll use a virtual env:
~/.pyenv/versions/3.11.10/bin/python -m venv .venv
source .venv/bin/activate
pip install .
Running the sample app, we can do:
export AUTH0_CLIENT_ID=...
export AUTH0_CLIENT_SECRET=...
export AUTH0_DOMAIN=...
export AUTH0_AUDIENCE=...
python manage.py migrate
python manage.py runserver
Go to http://localhost:8000/auth0 and log in!
Next steps
- Test that it works with the sample app (create an auth0 account to test)
- Run through genAI to look for general improvements: is all the logic we have in the views/index the right place for this?
- Add pre-commit code checks
- Add automated release via github action
- Flesh out user documentation here in README
- Add automated tests (including full e2e testing with Playwright)
- Profit
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_auth0_authbackend-0.0.8.tar.gz.
File metadata
- Download URL: django_auth0_authbackend-0.0.8.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2b4c425d751ee182a7bc27785cadf2a6a4be237200a4402e07811122a702dd5
|
|
| MD5 |
4866f174c562bb3b9460c73ee7cc2f39
|
|
| BLAKE2b-256 |
ed8c728d62cc22c01fb099e15d0e1e92daf8ab5a5e2570c3269a1f30a83a46d0
|
Provenance
The following attestation bundles were made for django_auth0_authbackend-0.0.8.tar.gz:
Publisher:
python-test-publish.yml on andyreagan/django-auth0-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_auth0_authbackend-0.0.8.tar.gz -
Subject digest:
d2b4c425d751ee182a7bc27785cadf2a6a4be237200a4402e07811122a702dd5 - Sigstore transparency entry: 231192437
- Sigstore integration time:
-
Permalink:
andyreagan/django-auth0-auth@098d8ef693929d759aafb066a6f723aaac8f62c6 -
Branch / Tag:
refs/tags/v0.0.8 - Owner: https://github.com/andyreagan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-test-publish.yml@098d8ef693929d759aafb066a6f723aaac8f62c6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_auth0_authbackend-0.0.8-py3-none-any.whl.
File metadata
- Download URL: django_auth0_authbackend-0.0.8-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
390d0bef4363c3dd09ff09b31992ecf87b189f7010d910613c5a2055a27493f9
|
|
| MD5 |
db308152cef31058028b45ac599555ae
|
|
| BLAKE2b-256 |
f95e72241002aa779f846ce43af967963143846387de351f2bf5f34dea917e39
|
Provenance
The following attestation bundles were made for django_auth0_authbackend-0.0.8-py3-none-any.whl:
Publisher:
python-test-publish.yml on andyreagan/django-auth0-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_auth0_authbackend-0.0.8-py3-none-any.whl -
Subject digest:
390d0bef4363c3dd09ff09b31992ecf87b189f7010d910613c5a2055a27493f9 - Sigstore transparency entry: 231192440
- Sigstore integration time:
-
Permalink:
andyreagan/django-auth0-auth@098d8ef693929d759aafb066a6f723aaac8f62c6 -
Branch / Tag:
refs/tags/v0.0.8 - Owner: https://github.com/andyreagan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-test-publish.yml@098d8ef693929d759aafb066a6f723aaac8f62c6 -
Trigger Event:
push
-
Statement type: