Commit 9ba74dd1 by Őry Máté

dashboard: create user profile on saml logon

Closes #42
parent 6d5b7363
......@@ -382,3 +382,7 @@ if get_env_variable('DJANGO_SAML', 'FALSE') == 'TRUE':
'{"mail": ["email"], "sn": ["last_name"], '
'"uid": ["username"], "cn": ["first_name"]}'))
if get_env_variable('DJANGO_SAML_ORG_ID_ATTRIBUTE', None) is not None:
SAML_ORG_ID_ATTRIBUTE = get_env_variable(
......@@ -20,3 +20,18 @@ class Profile(Model):
org_id = CharField( # may be populated from eduPersonOrgId field
unique=True, blank=True, null=True, max_length=64,
help_text=_('Unique identifier of the person, e.g. a student number.'))
if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
from djangosaml2.signals import pre_user_save
def save_org_id(sender, attributes, user_modified):
atr = settings.SAML_ORG_ID_ATTRIBUTE
value = attributes[atr]
profile, created = Profile.objects.get_or_create(user=sender)
if created or profile.org_id != value:
profile.org_id = value
return False
pre_user_save.connect(save_org_id, weak=False)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment