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

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.2.0.tar.gz (8.2 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.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: amsterdam_django_oidc-0.2.0.tar.gz
  • Upload date:
  • Size: 8.2 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.2.0.tar.gz
Algorithm Hash digest
SHA256 f8acb51479ae6ae46801b74547122a4baee6f357f93bf1a0e82fe4b17a38939b
MD5 543648794bdb87852f7ed27180241191
BLAKE2b-256 27297cc997730e4ccacd6a0852575aeecab89de9fb863c9d531d3e3f242f2430

See more details on using hashes here.

Provenance

The following attestation bundles were made for amsterdam_django_oidc-0.2.0.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.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for amsterdam_django_oidc-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb3406565882d30eeb41d06a99ad93fea6f03052d3bea593b1b0e77a8b8e5aaa
MD5 b474e2e2a3979ab27702dbe7eb9ef7ca
BLAKE2b-256 1a8486f64fb1a40d0205603a9ebba0eb72e257f37b7425246acc2740a3601b39

See more details on using hashes here.

Provenance

The following attestation bundles were made for amsterdam_django_oidc-0.2.0-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