Created
February 11, 2024 15:04
-
-
Save jjylik/fff2cfa966b8ee2f7e739a6b3d3d41ba to your computer and use it in GitHub Desktop.
django-allauth SAML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AcmeSocialAccountAdapter(DefaultSocialAccountAdapter): | |
# ...or save_user | |
def populate_user(self, request: Request, sociallogin: SocialLogin, data: dict) -> Any: | |
user = super().populate_user(request, sociallogin, data) | |
roles = sociallogin.account.extra_data.get("roles", []) | |
# Do something with extra attributes incoming from the SAML authentication response | |
user.roles = map_to_your_app_roles(roles) | |
return user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOCIALACCOUNT_PROVIDERS = { | |
"saml": { | |
"APPS": [ | |
# Apps can be configured in the DB or listed here | |
], | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment