Description
Django profile objects refers to objects that are typically related to the User
object using OneToOneField
and store extra information about user. The documentation states:
If you are using Django user profile objects to store extra attributes about your user you can add those attributes to the SAML_ATTRIBUTE_MAPPING dictionary. For each (key, value) pair, djangosaml2 will try to store the attribute in the User model if there is a matching field in that model. Otherwise it will try to do the same with your profile custom model.
However, this is not the case and it confused the hell out of me trying to get it to work. This excerpt from authentication backend method handles attribute updates and it does not appear to look for profile object:
for attr in django_attrs:
if attr == user_lookup_key:
# Don't update user_lookup_key (e.g. username) (issue #245)
# It was just used to find/create this user and might have
# been changed by `clean_user_main_attribute`
continue
elif hasattr(user, attr):
user_attr = getattr(user, attr)
if callable(user_attr):
modified = user_attr(attr_value_list)
else:
modified = set_attribute(user, attr, attr_value_list[0])
has_updated_fields = has_updated_fields or modified
else:
logger.debug(f'Could not find attribute "{attr}" on user "{user}"')
If this is indeed true, let me know and I will send a PR with updated description.