A Django App that adds SAML 2.0 endpoints to dj-rest-auth
Project description
dj-rest-auth-saml
Overview
dj-rest-auth-saml
is a Django App that is actually a plugin for the dj-rest-auth
that gives it the possibility to interact with django-allauth
with SAML 2.0 support.
Requirements:
Make sure that django-allauth
is installed with the SAML 2.0 extension:
pip install django-allauth[SAML]
Installation
To install dj-rest-auth-saml
run:
pip install dj-rest-auth-saml
In the settings.py you should have the following:
INSTALLED_APPS = [
# ...
"django.contrib.sites",
"corsheaders",
"rest_framework",
"rest_framework.authtoken",
"allauth", # this is django-allauth
"allauth.account",
"allauth.socialaccount",
"allauth.socialaccount.providers.saml", # saml support from django-allauth
"dj_rest_auth", # this is dj-rest-auth
"dj_rest_auth_saml" # this package
]
SITE_ID = 1
MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"allauth.account.middleware.AccountMiddleware", # this is important for allauth
]
SOCIAL_LOGIN_SAML_ENABLED = True
SOCIALACCOUNT_PROVIDERS = {
"saml": {"Apps": [
]}
}
Configurations:
follow the detailed in the following link to add your SAML provider(s) in the SOCIALACCOUNT_PROVIDERS["saml"]["Apps"] list:
https://docs.allauth.org/en/latest/socialaccount/providers/saml.html
alternatively you can add a migration that adds your SAML provider to the database using the utility function dj_rest_auth_saml.utils.add_default_saml_application
that requires the following configurations to be set in the settings.py
file:
SOCIAL_LOGIN_SAML_IDP_PROVIDER_ID = "IDP_PROVIDER_ID" # For Google as a provider "https://accounts.google.com/o/saml2?idpid=XXXXXXXXX"
SOCIAL_LOGIN_SAML_SP_ID = "example" # The SP ID used at the IDP
SOCIAL_LOGIN_SAML_IDP_SSO_URL = "https://idp_sso_url" # The url for the IDP SSO, for google: "https://accounts.google.com/o/saml2/idp?idpid=XXXXXXXXX"
SOCIAL_LOGIN_SAML_IDP_X509CERT = "-----BEGIN CERTIFICATE-----.....-----END CERTIFICATE-----" # the X509 IDP CERT
SOCIAL_LOGIN_SAML_ATTRIBUTE_MAPPING={
"uid": "uid",
"email": "email",
"email_verified": "email_verified",
"first_name": "first_name",
"last_name": "last_name"
}
SOCIAL_LOGIN_SAML_ALLOW_SINGLE_LABEL_DOMAINS = False # important for Unit testing
APP_HOST = "example.com" the hostname of this backend
Contributing
Contributions to this project are welcomed! The Contributing Guide is still under construction.
When creating a pull request make sure to use the following template:
Change Summary
- item one
- item two
Related issue number
- issue a
- issue b
Checklist
[ ] code is ready
[ ] add tests
[ ] all tests passing
[ ] test coverage did not drop
[ ] PR is ready for review
License
dj-rest-auth-saml is licensed under the MIT License - see the LICENSE file for details.
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
File details
Details for the file dj-rest-auth-saml-0.0.1.tar.gz
.
File metadata
- Download URL: dj-rest-auth-saml-0.0.1.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2491983b8e9906e568ec63d39063d8e5a8842a99bb5e46a40a5a4a050d3fe7a |
|
MD5 | ae2febaf4eb6a26173fc9f4624b557f0 |
|
BLAKE2b-256 | 363921a2908642b3da30af1cefcf8ca216cdf5ac8e35f443d9b49b50cc8920ca |
File details
Details for the file dj_rest_auth_saml-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: dj_rest_auth_saml-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28441fd97199584dc7fd17fc40bf143640cb285966c7b34dfb13fc6463f7a182 |
|
MD5 | 3ac11999f773d8b06c550054f7fb4835 |
|
BLAKE2b-256 | 8b8fc356e5a0c453e1b75ce22c99aa1702b2af61f947599c05f2adb6e0f56c86 |