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

Auth: Enable case insensitive logins/emails by default #84840

Merged
merged 4 commits into from
Mar 22, 2024

Conversation

eleijonmarck
Copy link
Contributor

@eleijonmarck eleijonmarck commented Mar 20, 2024

What is this feature?

Enables lower case sql queries for all users login, emails across grafanas users.

Why do we need this feature?

To make logins and emails lowercased across grafanas users and enforce use of lowercase in signing up for Grafana. This is to consolidate a standard.

Release notice breaking change

This is a breaking change for users who use uppercase in their login or emails. The users are by default now using lowercase as part of their login and emails.

Before this code change, users would be able to still log in as either aUser@user.com or auser@user.com, users are now only able to login and signup with grafana using lowercasing auser@user.com.

We recommend reviewing our blog post about using the CLI introduced in Grafana 9.3 and why this is important for us to consolidate our security efforts.

@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.0.x milestone Mar 20, 2024
@eleijonmarck eleijonmarck changed the title [WIP] Enable case insensitive logins/emails by default Case-insensitive: Enable case insensitive logins/emails by default Mar 21, 2024
@eleijonmarck eleijonmarck changed the title Case-insensitive: Enable case insensitive logins/emails by default Auth: Enable case insensitive logins/emails by default Mar 21, 2024
@eleijonmarck eleijonmarck requested a review from Jguer March 21, 2024 13:33
@eleijonmarck eleijonmarck self-assigned this Mar 21, 2024
@eleijonmarck eleijonmarck added breaking change Relevant for changelog generation no-backport Skip backport of PR labels Mar 21, 2024
@eleijonmarck eleijonmarck marked this pull request as ready for review March 21, 2024 13:37
@eleijonmarck eleijonmarck requested review from a team as code owners March 21, 2024 13:37
@eleijonmarck eleijonmarck requested review from papagian, diegommm and idafurjes and removed request for a team March 21, 2024 13:37
@eleijonmarck eleijonmarck force-pushed the eleijonmarck/caseinsensitive-on-by-default branch 2 times, most recently from 5c3934e to adde92c Compare March 22, 2024 12:05
@eleijonmarck eleijonmarck force-pushed the eleijonmarck/caseinsensitive-on-by-default branch from adde92c to f3b61fc Compare March 22, 2024 14:07
Copy link
Member

@aarongodin aarongodin left a comment

Choose a reason for hiding this comment

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

The code looks fine to me. It was a little confusing to figure out because of your claim of the breaking change:

This is a breaking change for users who use uppercase in their login or emails. The users are by default now using lowercase as part of their login and emails.

Am I correct in thinking that it's only a breaking change if for some reason you had two user records with the same characters but different casing? (e.g. one user record for agodin@grafana.com and another for aGodin@grafana.com).

Before this code change, I guess you'd be able to still log in as either, so it makes sense that it is a breaking change in that regard. Just want to clarify my understanding.

@eleijonmarck
Copy link
Contributor Author

The code looks fine to me. It was a little confusing to figure out because of your claim of the breaking change:

This is a breaking change for users who use uppercase in their login or emails. The users are by default now using lowercase as part of their login and emails.

Am I correct in thinking that it's only a breaking change if for some reason you had two user records with the same characters but different casing? (e.g. one user record for agodin@grafana.com and another for aGodin@grafana.com).

Before this code change, I guess you'd be able to still log in as either, so it makes sense that it is a breaking change in that regard. Just want to clarify my understanding.

thx! i clarified the breaking change a bit more, to account for users reading this in the change log. Thx for the review

@eleijonmarck eleijonmarck merged commit 2f7fd72 into main Mar 22, 2024
13 checks passed
@eleijonmarck eleijonmarck deleted the eleijonmarck/caseinsensitive-on-by-default branch March 22, 2024 15:45
return err
}
if err := ss.userCaseInsensitiveLoginConflict(ctx, sess, usr.Login, usr.Email); err != nil {
return err
}
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Call to function can be inlined

cfg.CaseInsensitiveLogin = users.Key("case_insensitive_login").MustBool(true)
// Deprecated
// cfg.CaseInsensitiveLogin = users.Key("case_insensitive_login").MustBool(true)
cfg.CaseInsensitiveLogin = true
Copy link
Contributor

Choose a reason for hiding this comment

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

This option can just be removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/backend breaking change Relevant for changelog generation no-backport Skip backport of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants