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 poetry:

poetry 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

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:

isort .
black .
mypy .
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.1.1.tar.gz (8.1 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.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: amsterdam_django_oidc-0.1.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for amsterdam_django_oidc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ff415e27c1605eb632092f6072928ddaab3e0c261b0968a93510dde9b13e89ba
MD5 7b608add08d14da19adf6a5d369807fc
BLAKE2b-256 37a9022de0b6770f3db92bf5045f82e12c4010b2aa79657c8e59e6a3c9edf68e

See more details on using hashes here.

Provenance

The following attestation bundles were made for amsterdam_django_oidc-0.1.1.tar.gz:

Publisher: publish.yaml on Amsterdam/amsterdam-django-oidc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for amsterdam_django_oidc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af2331f5320c2880b3f5658f54dc1c1dfb1e32cf195fce48dc548b0c90a9c87b
MD5 3654a4b3b7cc23b660901132ad2811bf
BLAKE2b-256 839e4c542cfd9a939af7ba552b3aae53e5d371ee6a7b69aa5285e1614d5483c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for amsterdam_django_oidc-0.1.1-py3-none-any.whl:

Publisher: publish.yaml on Amsterdam/amsterdam-django-oidc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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