Skip to content

Commit

Permalink
fix: case insensitive OIDC username lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
tymees committed Nov 21, 2024
1 parent bac1653 commit 91979d8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions humitifier-server/src/humitifier_server/oidc_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ def filter_users_by_claims(self, claims):
username = self.get_username(claims)
if not username:
return self.UserModel.objects.none()
return self.UserModel.objects.filter(username=username, is_local_account=False)
return self.UserModel.objects.filter(
username__iexact=username, is_local_account=False
)

def get_username(self, claims):
return claims.get("preferred_username")
return claims.get("preferred_username").lower()

def update_user(self, user, claims):
email = claims.get("email")
first_name = claims.get("given_name")
last_name = claims.get("family_name")

user.username = self.get_username(claims)
user.email = email
user.first_name = first_name
user.last_name = last_name
Expand Down

0 comments on commit 91979d8

Please sign in to comment.