Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions shibboleth/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ def authenticate(self, remote_user, shib_meta):
if self.create_unknown_user:
user, created = User.objects.get_or_create(username=username, defaults=shib_user_params)
if created:
"""
@note: setting password for user needs on initial creation of user instead of after auth.login() of middleware.
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 everytime he logs in.
"""
user.set_unusable_password()
user.save()
user = self.configure_user(user)
else:
try:
Expand Down
3 changes: 1 addition & 2 deletions shibboleth/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def process_request(self, request):
# by logging the user in.
request.user = user
auth.login(request, user)
user.set_unusable_password()
user.save()

# Upgrade user groups if configured in the settings.py
# If activated, the user will be associated with those groups.
if GROUP_ATTRIBUTES:
Expand Down