Django SAML2 Authentication Made Easy. Easily integrate with SAML2 SSO identity providers like Okta
Project description
Django SAML2
Django SAML2 Authentication Made Easy.
Full documentation for the project is available at https://djangosaml.readthedocs.io/en/latest/.
Requirements
- Python 3.6+
- Django 5.0, 4.2, 4.1, 4.0, 3.2, 3.1, 3.0
- PySAML2 requires
xmlsec1
which can be installed using:
apt install xmlsec1
// or
yum install xmlsec1
// or
brew install xmlsec1
Installation
Install using pip
...
pip install djangosaml
Add 'djangosaml'
to your INSTALLED_APPS
setting.
INSTALLED_APPS = [
...
'djangosaml',
]
Now update your root urls.py
:
import django_saml2_auth.views
urlpatterns = [
...
path('djangosaml/', include('djangosaml.urls')),
# The following line will replace the default user login with SAML2 (optional)
# If you want to specific the after-login-redirect-URL, use parameter "?next=/the/path/you/want"
path('login/', django_saml2_auth.views.signin),
]
Copy your metadata.xml
into root directory.
In settings.py
, add the SAML2 related configuration.
SAML2_AUTH = {
# Metadata is required, local file path
'METADATA_LOCAL_FILE_PATH': BASE_DIR / 'metadata.xml',
# Populates the Issuer element in authn request
'ENTITY_ID': 'https://your-domain/saml2_auth/acs/',
# Change Email/UserName/FirstName/LastName to corresponding SAML2 userprofile attributes.
'ATTRIBUTES_MAP': {
'email': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress',
'username': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier',
'first_name': 'http://schemas.auth0.com/nickname',
'last_name': 'http://schemas.auth0.com/nickname',
},
}
In your SAML2 SSO identity provider, set the Single-sign-on URL and Audience URI(SP Entity ID) to:
https://your-domain/saml2_auth/acs/
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
djangosaml-1.0.1.tar.gz
(6.8 kB
view hashes)
Built Distribution
Close
Hashes for djangosaml-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa2c5474ddb54b930e4b2f96eb1c8c1dd118700c3b891cd61c6e6406c8d057b5 |
|
MD5 | 81f73af417095406c4e330a773c83b1a |
|
BLAKE2b-256 | 6102ef6502853991a02ed381e2f28673e7aa9ab4938fbb0c5d43482a9e0c03e9 |