Package: dj-rest-auth-saml
dj-rest-auth-samlOverviewdj-rest-auth-samlis a Django App that is actually a plugin for thedj-rest-auththat gives it the possibility to interact withdjango-allauthwith SAML 2.0 support.Requirements:Make sure thatdjango-allauthis installed with the SAML 2.0 extension:pipinstalldjango-allauth[SAML]InstallationTo installdj-rest-auth-samlrun:pipinstalldj-rest-auth-samlIn 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=1MIDDLEWARE=["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=TrueSOCIALACCOUNT_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.htmlalternatively you can add a migration that adds your SAML provider to the database using the utility functiondj_rest_auth_saml.utils.add_default_saml_applicationthat requires the following configurations to be set in thesettings.pyfile: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 IDPSOCIAL_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 CERTSOCIAL_LOGIN_SAML_ATTRIBUTE_MAPPING={"uid":"uid","email":"email","email_verified":"email_verified","first_name":"first_name","last_name":"last_name"}SOCIAL_LOGIN_SAML_AUTHN_REQUEST_SIGNED=False# authn_request_signedSOCIAL_LOGIN_SAML_DIGEST_ALGORITHM=digest_algorithm='http://www.w3.org/2001/04/xmlenc#sha256'# OneLogin_Saml2_Constants.SHA256,SOCIAL_LOGIN_SAML_LOGOUT_REQUEST_SINGED=False# logout_request_signedSOCIAL_LOGIN_SAML_LOGOUT_RESPONSE_SIGNED=False# logout_response_signedSOCIAL_LOGIN_SAML_SIGNATURE_ALGORITHM='http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'# signature_algorithm OneLogin_Saml2_Constants.RSA_SHA256SOCIAL_LOGIN_SAML_METADATA_SIGNED=False# metadata_signedSOCIAL_LOGIN_SAML_WANT_ASSERTION_ENCRYPTED=False# want_assertion_encryptedSOCIAL_LOGIN_SAML_WANT_ASSERTION_SIGNED=False# want_assertion_signedSOCIAL_LOGIN_SAML_WANT_MESSAGE_SIGNED=False# want_message_signedSOCIAL_LOGIN_SAML_NAME_ID_ENCRYPTED=False# name_id_encryptedSOCIAL_LOGIN_SAML_WANT_NAME_ID_ENCRYPTED=False# want_name_id_encryptedSOCIAL_LOGIN_SAML_ALLOW_SINGLE_LABEL_DOMAINS=False# important for Unit testingSOCIAL_LOGIN_SAML_REJECT_DEPRECATED_ALGORITHM=True# reject_deprecated_algorithmSOCIAL_LOGIN_SAML_WANT_NAME_ID=False# want_name_idSOCIAL_LOGIN_SAML_WANT_ATTRIBUTE_STATEMENT=True# want_attribute_statementSOCIAL_LOGIN_SAML_ALLOW_REPEAT_ATTRIBUTE_NAME=True# allow_repeat_attribute_nameAPP_HOST="example.com"thehostnameofthisbackendAlso make sure to take a hard look at the django-allauth settings as well as at the dj-rest-auth settings.For instance, the following could be something you want to add to your applicationSOCIALACCOUNT_EMAIL_AUTHENTICATION_AUTO_CONNECT=TrueSOCIALACCOUNT_EMAIL_AUTHENTICATION=TrueACCOUNT_UNIQUE_EMAIL=TrueACCOUNT_EMAIL_VERIFICATION="mandatory"SAML flow:ContributingContributions 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 reviewLicensedj-rest-auth-saml is licensed under the MIT License - see the LICENSE file for details.