-
Notifications
You must be signed in to change notification settings - Fork 75
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
change order of user.set_unusable_password() #43
change order of user.set_unusable_password() #43
Conversation
setting a password for user needs to be before auth.login() because get_session_auth_hash() returns the salted_hmac value of salt and password. If it remains after the auth.login() it will return a different auth_hash than what's stored in session "request.session[HASH_SESSION_KEY]". Also we don't need to update the user's password every time he logs in.
Thanks for this PR! Would it work to move the set_unusable_password & save calls to the backend, when the user is created? Seems like that's the only time that set_unusable_password would need to be called, and that way it's only called once (and it's still called before login(), like you're looking for. |
I Believe
But by doing this way, In Addition, as we are using
That's why I believe my way doing is better. I am also new to django. Without 100% understanding of django |
Let me clarify: In this package, we have our own remote backend class in backends.py: I'm not suggesting we change the auth.authenticate call in middleware.py, but that we update the code in backends.py to run set_unusable_password there. So it could look something like this in backends.py (note the two added lines):
Does that make more sense? |
Yes. It makes sense. In |
You have to tell django in the settings which RemoteBackend you want to use. With this package, we tell django that we want to use the ShibbolethRemoteUserBackend. |
ok.. |
that'd be great if it fixed #41. Are you planning to update the PR? |
I have updated pull request. The reason, why I think it will address it, is: he has the same problem, he is losing a session after the first click, which is because user.save() after updating password is updating hash. so for next click request act like not loged-in user. I am not login any other mixins or middleware which cares about if user is login or not, but in his case he does. |
Merged - thanks for your contribution! |
setting a password for user needs to be before auth.login()
because get_session_auth_hash() returns the salted_hmac value of salt and password.
If it remains after the auth.login() it will return a different auth_hash
than what's stored in session "request.session[HASH_SESSION_KEY]".
Also we don't need to update the user's password every time he logs in.