Skip to main content

Extension of the authenctication backend of the mozilla-django-oidc package, with extra validation.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amsterdam_django_oidc-0.2.3.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amsterdam_django_oidc-0.2.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file amsterdam_django_oidc-0.2.3.tar.gz.

File metadata

  • Download URL: amsterdam_django_oidc-0.2.3.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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}

File hashes

Hashes for amsterdam_django_oidc-0.2.3.tar.gz
Algorithm Hash digest
SHA256 da2e00150b656af5dd66664c292a6f201fe48900b399dc6acdbbbbe6399402a3
MD5 de74da471e64271bdae27a8803e6357f
BLAKE2b-256 404416e0e4b91f2e54b36146e9ea4b890044116b61ac2ff0aef4072196ae8076

See more details on using hashes here.

File details

Details for the file amsterdam_django_oidc-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: amsterdam_django_oidc-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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}

File hashes

Hashes for amsterdam_django_oidc-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c908fa422f11a3539a922cd45bd8386420b18fcb1dad2fb9dce853c3f8c9324e
MD5 2f41dca3e181b487b0f071a4486480a3
BLAKE2b-256 0052425746db36d2f4a5ba105cfa6f692c29ec7c411ae6295e474674f218e744

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page