-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Storing extra attributes in custom user profile #395
Comments
watch this djangosaml2/djangosaml2/backends.py Line 100 in fcee903
the documentation means something like a custom user model (not the django one) at the same time you can inherit the backend and configure it here and then with your code you can do whatever you want, otherwise you can define a saml user model as well, as you can read here djangosaml2/djangosaml2/backends.py Line 50 in fcee903
all the way you read the backend file, you'll find the path that better fits your needs or taste. Could I ask you to use your dev experience to provide some improvements to the current documentation once you have solved your problem? that would be for the people like me and you thx! |
@peppelinux thank you for prompt response. Sure I would be happy to provide any improvements to the documentation based on my understanding through my challenges. I do have my AUTHENTICATION_BACKENDS set as shown above and I have a working setup for basic auth and now trying to save additional attributes needed for my app. My challenge has been, it appears that pre_user_save signals have be done away with from the code, based on some of the threads I read. Seemed easier to listen to the signal and update the attributes of my choice in my user profile model. My user profile model relies on django User model. May be there is reason for moving away from signals. Given I am extending an already existing user profile and not writing my own, my choices are limited. And only option now seems to be to override with class ModifiedSaml2Backend(Saml2Backend): and _update_user to get access to saml attributes and save it using a methods from my use profile, a little more full example would help new users like me. Unless you see there are other ways to communicate additional attributes elsewhere to other models? Thanks! |
you can use the signals as well, sure, sorry for not having mentioned them you have many way according to your tastes and design requirements |
Great, thanks I will give it a try. That mention on signals is certainly missing from the documentation https://djangosaml2.readthedocs.io/index.html |
@peppelinux BTW based on my digging support was removed for signals from the code. I see no corresponding sends for signals defined. Is that how you see it? Thanks! |
@peppelinux thx. It appears that signals file is just a skeleton without any part of the djangosaml2 code actually sending signals. Digging through further I stumbled upon #287. Here I see WiP from @DylannCordel were not incorporated. |
software is often affected by its author's tastes and completely personal positions. This project rather wants to be driven by its community and personally I have used both signals and inheritance in this kind of problem and with success. I am therefore completely neutral and would like both possibilities to be used by those who use djangosaml2. To do this I need contributors, people who request, develop and test the functionality. Following this we can make a release together |
@peppelinux I will give @DylannCordel WiP a shot and see if I can validate that. |
Dear djangosaml2 team,
I have a user profile with additional attributes to store from saml assertions, my user profile model uses default django User model with onetoonefiled -> User(django.contrib.auth.models)
My understanding from the below reading of the documentation is, if the additional attributes to store are specified in SAML_ATTRIBUTE_MAPPING then djangosaml2 will attempt to store the same in my custom profile if those attributes are not found in the User model.
Could you please help me clarify if this is true or not? My attempt to try to store extra attributes to user profile has been unsuccessful hence the question.
=> https://djangosaml2.readthedocs.io/contents/setup.html#configuration >
....
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. For multi-valued attributes only the first value is assigned to the destination field.
...
Thanks!
The text was updated successfully, but these errors were encountered: