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

Make email comparison for SAML case insensitive #1173

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion backend/iam/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SocialAccountAdapter(DefaultSocialAccountAdapter):
def pre_social_login(self, request, sociallogin):
email_address = next(iter(sociallogin.account.extra_data.values()))[0]
try:
user = User.objects.get(email=email_address)
user = User.objects.get(email=email_address.lower())
sociallogin.user = user
sociallogin.connect(request, user)
except User.DoesNotExist:
Expand Down
3 changes: 3 additions & 0 deletions backend/iam/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ def delete(self, *args, **kwargs):
logger.info("user deleted", user=self)

def save(self, *args, **kwargs):
# Make sure to always convert username to lowercase for easier comparison with SSO
if self.email:
self.email = self.email.lower()
super().save(*args, **kwargs)
logger.info("user saved", user=self)

Expand Down
2 changes: 1 addition & 1 deletion backend/iam/sso/saml/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def dispatch(self, request, organization_slug):
login.state["next"] = next_url
try:
email = auth._nameid
user = User.objects.get(email=email)
user = User.objects.get(email=email.lower())
idp_first_name = auth._attributes.get(
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname", [""]
)[0]
Expand Down
Loading