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

generic oauth2 : use email as username if there is no "login" or "username" property in /userinfo #21525

Open
mathieupassenaud opened this issue Jan 15, 2020 · 2 comments

Comments

@mathieupassenaud
Copy link

What happened:
Grafana + keycloak as authentication provider.
Keycloak has porperty "Email as username" activated.

I log in with my keycloak account, it works fine. Then, I changed my email in keycloak, using the "account" builtin application.
Surprise, when I log in grafana I lost everything, it is a new account.

What you expected to happen:
email shouldn't be used as a user id. I expected my account unchanged exception my email address.

How to reproduce it (as minimally and precisely as possible):
keycloak as oauth provider
login with an account
change email

Anything else we need to know?:
It located in file https://github.com/grafana/grafana/blob/master/pkg/login/social/generic_oauth.go in "extractLogin" function. This function search for "login" or "username" in /userinfo endpoint.
Keycloak does not have those fields by default.
So the function returns email as user login.

workaround
In keycloak, open the client you created for grafana. Go to "mapper" and add a new one. Choose "user property" mapper type, the user property we want is "id" and add it to token claim "login".
This works perfectly

What we should have
Just like with email, we have the "email_attribute_path" configuration option. We should have the same for user_id attribute.

Environment:

  • Grafana version: 6.5.0
  • OS Grafana is installed on: docker
  • User OS & Browser: windows 10 & chrome
@aknuds1
Copy link
Contributor

aknuds1 commented Jan 16, 2020

Thanks for reporting this, we'll look into it.

@marefr marefr added the needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating label May 11, 2020
@marefr marefr added this to Inbox in Backend Platform Backlog via automation May 11, 2020
@marefr marefr added type/feature-request and removed needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating labels Jun 11, 2020
@marefr marefr moved this from Inbox to Epics & features in Backend Platform Backlog Jun 11, 2020
@bergquist bergquist removed this from Features in Backend Platform Backlog Jul 3, 2020
@praserx
Copy link

praserx commented May 11, 2023

Same issue with generic oauth. If user change his e-mail address, then login fails (user already exists). I thing that is quite common behavior, to change my primary e-mail. There is nothing wrong if user change his e-mail within some identity provider.

The workaround did not work for me. If the user has the same login name (username), but different e-mail address, e-mail is not updated and login attempt fails with error "User already exists".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants