Skip to main content

A lightweight authentication and access management library for integration with OpenID Connect enabled authentication services.

Project description

https://badge.fury.io/py/mozilla-django-oidc.svg https://github.com/mozilla/mozilla-django-oidc/actions/workflows/unit_tests.yml/badge.svg?branch=main https://github.com/mozilla/mozilla-django-oidc/actions/workflows/integration_tests.yml/badge.svg?branch=main https://codecov.io/gh/mozilla/mozilla-django-oidc/graph/badge.svg?token=QrytQ8IwrM

A lightweight authentication and access management library for integration with OpenID Connect enabled authentication services.

Documentation

The full documentation is at https://mozilla-django-oidc.readthedocs.io.

Design principles

  • Keep it as minimal/lightweight as possible

  • Store as few authn/authz artifacts as possible

  • Allow custom functionality by overriding the authentication backend

  • Mainly support OIDC authorization code flow

  • Allow shipping Mozilla-centric authn/authz features

  • Test against all supported Python/Django version

  • E2E tested and audited by Mozilla InfoSec

Running Unit Tests

Use tox to run as many different versions of Python you have. If you don’t have tox installed (and executable) already you can either install it in your system Python or https://pypi.python.org/pypi/pipsi. Once installed, simply execute in the project root directory.

$ tox

tox will do the equivalent of installing virtual environments for every combination mentioned in the tox.ini file. If your system, for example, doesn’t have python3.4 those tox tests will be skipped.

For a faster test-rinse-repeat cycle you can run tests in a specific environment with a specific version of Python and specific version of Django of your choice. Here is such an example:

$ python -m venv venv
$ source ./venv/bin/activate
(venv) $ pip install '.[dev]'
(venv) $ make test

Measuring code coverage, continuing the steps above:

(venv) $ make coverage

Local development

The local development setup is based on Docker so you need the following installed in your system:

  • docker

  • docker-compose

You will also need to edit your hosts file to resolve testrp and testprovider hostnames to 127.0.0.1.

Running test services

To run the testrp and testprovider instances run the following:

(venv) $ docker-compose up -d testprovider testrp

Then visit the testing django app on: http://testrp:8081.

The library source code is mounted as a docker volume and source code changes are reflected directly in. In order to test a change you need to restart the testrp service.

(venv) $ docker-compose stop testrp
(venv) $ docker-compose up -d testrp

Running integration tests

Integration tests are mounted as a volume to the docker containers. Tests can be run using the following command:

(venv) $ docker-compose run --service-ports testrunner

Linting

All code is checked with https://pypi.python.org/pypi/flake8 in continuous integration. To make sure your code still passes all style guides install flake8 and check:

$ flake8 mozilla_django_oidc tests

You can also run linting with tox:

$ tox -e lint

Finally you can use pre-commit hooks to run linting and formatting before you commit your code:

(venv)  $ pre-commit install

Releasing a new version

mozilla-django-oidc releases are hosted in PyPI. Here are the steps you need to follow in order to push a new release:

  • Make sure that HISTORY.rst is up-to-date focusing mostly on backwards incompatible changes.

    Security vulnerabilities should be clearly marked in a “Security issues” section along with a level indicator of:

    • High: vulnerability facilitates data loss, data access, impersonation of admin, or allows access to other sites or components

      Users should upgrade immediately.

    • Medium: vulnerability endangers users by sending them to malicious sites or stealing browser data.

      Users should upgrade immediately.

    • Low: vulnerability is a nuissance to site staff and/or users

      Users should upgrade.

  • Bump the project version and create a commit for the new version.

    • You can use bumpversion for that. It is a tool to automate this procedure following the semantic versioning scheme.

      • For a patch version update (eg 0.1.1 to 0.1.2) you can run bumpversion patch.

      • For a minor version update (eg 0.1.0 to 0.2.0) you can run bumpversion minor.

      • For a major version update (eg 0.1.0 to 1.0.0) you can run bumpversion major.

  • Create a signed tag for that version

    Example:

    git tag -s 0.1.1 -m "Bump version: 0.1.0 to 0.1.1"
  • Push the signed tag to Github

    Example:

    git push origin 0.1.1

The release is pushed automatically to PyPI using a travis deployment hook on every new tag.

License

This software is licensed under the MPL 2.0 license. For more info check the LICENSE file.

Credits

Tools used in rendering this package:

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

mozilla_django_oidc-5.0.2.tar.gz (57.4 kB view details)

Uploaded Source

Built Distribution

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

mozilla_django_oidc-5.0.2-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file mozilla_django_oidc-5.0.2.tar.gz.

File metadata

  • Download URL: mozilla_django_oidc-5.0.2.tar.gz
  • Upload date:
  • Size: 57.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mozilla_django_oidc-5.0.2.tar.gz
Algorithm Hash digest
SHA256 4e953dcd963c036daaa2ac42b5bb6ea89a1c6ea7be0387c2022a59aca2f83043
MD5 6b86f1f810a08a1dcfe422d1f9532107
BLAKE2b-256 045ed5906dc016253d248eabf3608a6bbfd0df75a993a467cf7cf0a0c7f2b18a

See more details on using hashes here.

File details

Details for the file mozilla_django_oidc-5.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mozilla_django_oidc-5.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 965a3533b0e299288cdf38ec2f8b550217c302ffe78ce5bd0b2d2f4bc436878b
MD5 6cc97a3b71d73d7e0048e4ac866926a8
BLAKE2b-256 a8a9c1664acf30ef0031ed06650039de1693bddf4cf7f58e07939e1aa80bffb7

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