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

refactor: lowercase email address search to match keycloak #3847

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

shreddedbacon
Copy link
Member

@shreddedbacon shreddedbacon commented Nov 21, 2024

General Checklist

  • Affected Issues have been mentioned in the Closing issues section
  • Documentation has been written/updated
  • PR title is ready for inclusion in changelog

Database Migrations

  • If your PR contains a database migation, it MUST be the latest in date order alphabetically

Creating a user in Lagoon with an uppercase email address ends up with Keycloak saving/storing it as lowercase. If a user then tries to query Lagoon for this user using the uppercase email, the Keycloak lookup fails because it does not match the lowercase saved email.

Keycloak saves all email addresses and usernames as lowercase when users are created, even if the provided email address contains uppercase. Confusingly though, it still respects case sensitivity in the API query params when doing lookups. It appears Keycloak have chosen to do this for some reason, probably for consistency, and there isn't any feature or parameter to change this behaviour.

There are numerous github issues and stack overflow posts where people have encountered issues with needing uppercase usernames or email address in Keycloak with no real clear indication if it can be changed.

While the mailbox local part of an email address should be case sensitive per RFC 5321 2.3.11 and 2.4, however, the majority of email service providers will ignore this to reduce confusion. For example, [email protected] and [email protected] according to RFC should be treated as different mailboxes.

The simplest solution for us is to just make sure we lowercase email addresses when we're performing user lookups against Keycloak, which is what this pull request does.

Additionally, I've renamed some of the user lookup functions to better suit their use, and also updated the allUser query to be more efficient when filtering on an email address or user ID by only looking up the requested filter query.

@shreddedbacon shreddedbacon added this to the 2.23.0 milestone Nov 21, 2024
@shreddedbacon shreddedbacon marked this pull request as ready for review November 25, 2024 03:18
Copy link
Member

@rocketeerbkw rocketeerbkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy win to reduce user confusion 👍

@tobybellwood tobybellwood merged commit 4417358 into main Dec 2, 2024
1 check passed
@shreddedbacon shreddedbacon deleted the email-case branch December 2, 2024 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants