A django-allauth dotnetid provider
Project description
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
- Install required packages in your project:
python -m pip install django-dotnetid
- Add
django_dotnetidto your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...,
"django_dotnetid",
"allauth",
"allauth.account",
"allauth.socialaccount",
"allauth.socialaccount.providers.openid_connect",
]
- Add
allauth.account.middleware.AccountMiddlewareat the end of your middlewares:
MIDDLEWARE = [
...
"allauth.account.middleware.AccountMiddleware",
]
- Include the dotnetidprovider URL conf in your project urls.py like this:
from django.urls import include, path
...
path('accounts/', include('allauth.urls')),
-
Run
python manage.py migrateto create the models. -
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_REDIRECT_URL = 'index'
ACCOUNT_LOGOUT_REDIRECT = 'index'
SITE_ID = 1
-
Start the development server.
-
Visit the
/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_dotnetid-1.1.0.tar.gz.
File metadata
- Download URL: django_dotnetid-1.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae99bfd36fdb84a6c3985b039a3e453f32c5c78bc1622cab7115080f93229b02
|
|
| MD5 |
0f97922e311578fe146b437816d793a9
|
|
| BLAKE2b-256 |
e5f7a421d77bb8d779b29c68b3bfc5c9ba1d79b8c5c4a896173a4fdd6daf5942
|
File details
Details for the file django_dotnetid-1.1.0-py3-none-any.whl.
File metadata
- Download URL: django_dotnetid-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58c798d595694f0f2fe0c61f7aa5e24a4e9beb3757e3a89690d965bd9e5e246f
|
|
| MD5 |
4a6023f93c4730e2bcf9783c8c429e84
|
|
| BLAKE2b-256 |
565d55fdd8b0246b75ccec591d225acf6b0159df890e03c5c5dbe35581297d15
|