govuk-onelogin-django
OpenID Connect client that works with GOV.UK One Login.
Package provides the following endpoints:
one-login/login/to login via GOV.UK One Login.one-login/callback/endpoint GOV.UK One Login will send logged-in users back to.back-channel-logout/endpoint GOV.UK One Login will send logout notifications to.
The example project also provides an example logout view that will log the user out of your service as well as GOV.UK One Login.
See class ExampleLogoutView for example that includes post_logout_redirect_uri
Documentation:
- GOV.UK One Login admin tool used to create a test application: https://admin.sign-in.service.gov.uk/
- GOV.UK One Login documentation: https://www.sign-in.service.gov.uk/documentation
- GOV.UK One Login technical documentation: https://docs.sign-in.service.gov.uk/
Quick start
Before starting, you should create an example app using the GOV.OK One Login admin tool.
-
Add "govuk_onelogin_django" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ..., "govuk_onelogin_django", ]
-
Include the govuk_onelogin_django URLconf in your project urls.py like this:
path("one-login/", include("govuk_onelogin_django.urls"))
-
Include OneLoginBackend to your AUTHENTICATION_BACKENDS like this:
AUTHENTICATION_BACKENDS.append("govuk_onelogin_django.backends.OneLoginBackend")
-
Include the following settings in your settings.py file
# Required start page that includes a link to log in to GOV.UK One Login LOGIN_URL = "your-login-start-page" # A view name that the logged-in user will be redirected to after logging in via GOV.UK One Login LOGIN_REDIRECT_URL = "view-to-send-logged-in-users-to" # All other GOV.UK One Login settings required to configure govuk-onelogin-django GOV_UK_ONE_LOGIN_CLIENT_ID = "Your client ID" GOV_UK_ONE_LOGIN_CLIENT_SECRET = "Your client secret" GOV_UK_ONE_LOGIN_OPENID_CONFIG_URL = "Either integration or production config url." GOV_UK_ONE_LOGIN_SCOPE = "Required scopes" GOV_UK_ONE_LOGIN_AUTHENTICATION_LEVEL = "Required authentication level" GOV_UK_ONE_LOGIN_CONFIDENCE_LEVEL = "Required confidence level"
Note:
GOV_UK_ONE_LOGIN_CLIENT_SECRETis a base64 encoded string of your private key. e.g.base64 -i private_key.pemSee this document detailing how to generate your keys.
Configuration
See configuration document detailing how to override the following:
- Service logout behaviour of back-channel-logout/ endpoint
- Override how GOV.UK One Login config is fetched
- how GOV_UK_ONE_LOGIN_CLIENT_ID is loaded
- How GOV_UK_ONE_LOGIN_CLIENT_SECRET is loaded
Example project
See the example_project README.md for details on how to build and run the example project.
Commands to build and test govuk-onelogin-django
- Install uv
- Update the project's environment:
uv sync - Run tests using local venv:
uv run pytest - Running the tests against all supported python versions:
- Install tox and tox-uv:
uv tool install tox --with tox-uv - Check tox is installed:
tox --version - run the tests:
tox run
- Install tox and tox-uv:
- Install pre-commit hooks:
uv run pre-commit install - Run pre-commit against all files:
uv run pre-commit run --all-files
linting / formatting
- Run the Ruff linter:
uv run ruff check - Resolve fixable errors:
uv run ruff check --fix - Run the Ruff formatter:
uv run ruff format - mypy:
uv run mypy --config-file=pyproject.toml
Publishing
- View the current project version:
uv version - Update the project version with dryrun:
uv version --bump minor --dry-run - Update the project version:
uv version --bump minor - Publish to PyPI:
uv publish --token <token>
Metadata
Release files for govuk-onelogin-django 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| govuk_onelogin_django-0.5.1.tar.gz | 98.6 kB | Without provenance | Details for govuk_onelogin_django-0.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| govuk_onelogin_django-0.5.1-py3-none-any.whl | Python 3 | none | any | Details for govuk_onelogin_django-0.5.1-py3-none-any.whl |
Total release size: 124.5 kB
Release files / govuk_onelogin_django-0.5.1.tar.gz
| Download URL | govuk_onelogin_django-0.5.1.tar.gz |
|---|---|
| Size | 98.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6090470c6e442fd97fbacb5fd0a4d79136fc43c0bf03090e76832283b1a051d7
|
|
BLAKE2b-256 checksum How to use checksums |
394d0d0a7da602ef4594a7480c66d17f6c94ae797f493482bacfaba5dcd7cbf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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}
|
Release files / govuk_onelogin_django-0.5.1-py3-none-any.whl
| Download URL | govuk_onelogin_django-0.5.1-py3-none-any.whl |
|---|---|
| Size | 25.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3563ad35fc6795a53de7cb168540888f1a283a93be0ffb5411ac93b698e0b04b
|
|
BLAKE2b-256 checksum How to use checksums |
02ef600f6b10977612ff84eb49fa24d9064e179f95c31bc318310d64a3e0d75a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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}
|
Security for govuk-onelogin-django 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.