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.0.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.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for amsterdam_django_oidc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a14acb0414f394be59f948095e8c196914ba42943db5f4b212df9da63641083d
MD5 c4021dcbcb9f17b9ba900b88a165aac3
BLAKE2b-256 1c54bdc572e45b4f3f03a8b1b4ce657adad19aeb359b4f47fc60eb95308ac1f8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for amsterdam_django_oidc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efe417dcc19334a5d2bac6ea4d0f28ce5123c6ed778016f8d1dbf9b223e7eff3
MD5 9db4dac41fbde061b74586b2a64a72ce
BLAKE2b-256 5c2cb46388a02a3b6837c126f6173f4cdde945ad771e178f59fee6ca428f45f7

See more details on using hashes here.

Provenance

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