Description
I noticed that when SAML_USE_NAME_ID_AS_USERNAME
is False
, whatever attribute is determined to be the main attribute here https://github.com/knaperek/djangosaml2/blob/fd6a8237ed7b2b2308de97b11773c1860139b048/djangosaml2/backends.py#L88-L90 gets applied to the user both on creation and on update of the attributes.
This double update does not seem necessary and can cause problems if a cleaning is defined on the main attribute that is separate from the cleaning of the attributes.
Example:
-
Configure an
email
attribute to be sent from the IdP and be used as the main attribute / set to be the username within Django -
Define a cleaning on this main attribute that converts
@
to_
(e.g.,user@company
within IdP --->user_company
Django user) -
When a user is created here, the username will be
user_company
as expected -
Once the user is created, the attributes will be updated here and the username will change to the attribute value of
user@company
, which is not desired.
Any suggestions / feedback on the above? I may be missing a best practice configuration here. Thanks!