Skip to main content

django-dotnetid

django-dotnetid is a Django app extending django-allauth. It implements an OpenID connect provider able to map extra_info from the id_token into Django User model. It is also capable of attributing groups automatically.

You need to install django-allauth to be able to use this extension.

A full working example can be found here: https://github.com/sitn/django-dotnetid-example

Quick start

  1. Install required packages in your project:
python -m pip install django-dotnetid
  1. Add django_dotnetid to your INSTALLED_APPS setting like this:
    INSTALLED_APPS = [
        ...,
        "django_dotnetid",
        "allauth",
        "allauth.account",
        "allauth.socialaccount",
        "allauth.socialaccount.providers.openid_connect",
    ]
  1. Add allauth.account.middleware.AccountMiddleware at the end of your middlewares:
MIDDLEWARE = [
...
    "allauth.account.middleware.AccountMiddleware",
]
  1. Include the dotnetidprovider URL conf in your project urls.py like this:
from django.urls import include, path
...
    path('accounts/', include('allauth.urls')),
  1. Run python manage.py migrate to create the models.

  2. In your settings.py, you can add the provider like that:

AUTHENTICATION_BACKENDS = [
    "django.contrib.auth.backends.ModelBackend",
    "allauth.account.auth_backends.AuthenticationBackend",
]

SOCIALACCOUNT_PROVIDERS = {
    "dotnetidprovider": {
        "APP": {
            "provider_id": "dotnetid",
            "name": "Etat de Neuchâtel",
            "client_id": os.environ['DOTNETID_CLIENT_ID'],
            "secret": os.environ['DOTNETID_CLIENT_SECRET'],
            "settings": {
                "server_url": os.environ['DOTNETID_SERVER_URL'],
            },
        },
        "SCOPE": [
            "profile",
            "openid",
            "glados",
        ],
        "EXTRA_ATTRIBUTES_PREFIX": "djangoopenid",
        "OAUTH_PKCE_ENABLED": True,
        "ID_TOKEN_ISSUER": os.environ['DOTNETID_SERVER_URL'],
    }
}
SOCIALACCOUNT_EMAIL_VERIFICATION = None
SOCIALACCOUNT_ADAPTER  = 'django_dotnetid.adapter.DotnetIdAccountAdapter'
LOGIN_URL = f"{FORCE_SCRIPT_NAME}/accounts/login/"
LOGIN_REDIRECT_URL = f"{FORCE_SCRIPT_NAME}"
ACCOUNT_LOGOUT_REDIRECT = f"{FORCE_SCRIPT_NAME}"
SITE_ID = 1
  1. Start the development server.

  2. Visit the /.

Metadata

Release files for django-dotnetid 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-dotnetid 1.2.1
File Size Uploaded Provenance Actions
django_dotnetid-1.2.1.tar.gz 5.9 kB Without provenance Details for django_dotnetid-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-dotnetid 1.2.1
File Interpreter ABI Platform Actions
django_dotnetid-1.2.1-py3-none-any.whl Python 3 none any Details for django_dotnetid-1.2.1-py3-none-any.whl

Total release size: 12.8 kB

Release files / django_dotnetid-1.2.1.tar.gz

Download URL django_dotnetid-1.2.1.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2545a65ef81f88f81ee653d0df57b2d809dc85fa3adca074dc122d6a8b463477
BLAKE2b-256 checksum
How to use checksums
e442ae762b1a84670e9feca359efd386e02689b750b16da15457a4fd91327446
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / django_dotnetid-1.2.1-py3-none-any.whl

Download URL django_dotnetid-1.2.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ecfe0bd0ce8985884c3a2ccc2f9919d7d6110f25ee7b3ba8c943f0277cff988
BLAKE2b-256 checksum
How to use checksums
efd5f1da871e862ad9d6916204d47eefae378f411ef0989af0b369c733b36e00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for django-dotnetid 1.2.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page