amsterdam-django-oidc
This package contains an authentication backend for Django.
It is currently based on the authentication backend provided by Mozilla through the mozilla-django-oidc package.
The Mozilla package however does not validate the iss, aud and exp claims of the access token and always calls
the userinfo endpoint on the identity provider. Unfortunately that is not adequate for the use case within the
landscape of applications of the city of Amsterdam. Hence, the reason for this solution.
Instead of calling the userinfo endpoint, it will validate the aforementioned claims.
Install
The package can be installed using your favorite package manager for python. For example using uv:
uv add amsterdam-django-oidc
Or using pip:
pip install amsterdam-django-oidc
Usage
Add the backend to the setting AUTHENTICATION_BACKENDS:
# settings.py
AUTHENTICATION_BACKENDS = [
# ...
"amsterdam_django_oidc.OIDCAuthenticationBackend",
]
There are also a few settings required in addition to those of the Mozilla package:
| Name | Type | Description |
|---|---|---|
| OIDC_OP_ISSUER | str | The allowed issuer, the value of the iss claim in the access token must match the value of this setting |
| OIDC_TRUSTED_AUDIENCES | list[str] | Audiences that we trust, at least one of the values of the aud claim must match one the values of this setting |
| OIDC_VERIFY_AUDIENCE | bool | Controls wether or not to verify the aud claim, default: True |
Development
In order to facilitate further development of this package a containerized setup is provided.
Building the container images
docker compose build
Running development tools
It's recommended to start a container and use the shell inside the container:
docker compose run --rm amsterdam-django-oidc bash
Once you see the shell it's possible to run commands like:
uv run ruff check
uv run mypy .
uv run pytest
Release files for amsterdam-django-oidc 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| amsterdam_django_oidc-0.2.4.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| amsterdam_django_oidc-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.5 kB
Release files / amsterdam_django_oidc-0.2.4.tar.gz
| Download URL | amsterdam_django_oidc-0.2.4.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ec34a5f8d3a16b07f3205653edf3bc186d83e811a5434b0e7727f9c97d890f3
|
|
BLAKE2b-256 checksum How to use checksums |
6ef7d6cbc400ba9316b06f84b78ec25baba8fa6aaf2c906aeb170da78f7eafce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / amsterdam_django_oidc-0.2.4-py3-none-any.whl
| Download URL | amsterdam_django_oidc-0.2.4-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
367c9197b36d930491c39b87a93e089f3baab5d89a5d907f1b6646481115f68f
|
|
BLAKE2b-256 checksum How to use checksums |
a74299a1e3cc0edc924ccd46af2a6aa8ada5455a2828ff9dbcd5156fcc8f2a5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|