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

[v9.5.x] GenericOAuth: Set sub as auth id #73223

Merged
merged 1 commit into from Aug 14, 2023

Conversation

grafana-delivery-bot[bot]
Copy link
Contributor

Backport 7cd6018 from #65902


What is this feature?
When connecting with generic oauth we have never set authID in user_auth table.

This leads to some strange edge cases we need to handle to not create a new insert in user_auth table on every login,
see https://github.com/grafana/grafana/blob/main/pkg/services/authn/authnimpl/sync/user_sync.go#L323-L331

This prevents generic oauth to sync a new email because the email is always the primary identifier when using generic oauth. So if a user change their email in IDP a new user is created inside grafana.

If we use id token or userinfo endpoint the sub should always be present and can be used as a unique identifier. This will make it possible to be able to change the email for a user and still resolve it to the same one inside grafana. But in order for this to work properly the user first has to login with this changes in place to the auth id is correctly set.

I opted not to force the present of a sub initially because that can maybe break non oidc compatible idps, but we should enforce this in the future.

If we wan't to enforce it we should start with adding a deprecation log when a login is performed without the present of a sub claim

Fixes #64688

Special notes for your reviewer:

* GenericOAuth: Set sud as auth id

* GenericOAuth: Extract function to reduce complexity

(cherry picked from commit 7cd6018)
@grafana-delivery-bot grafana-delivery-bot bot requested a review from a team as a code owner August 14, 2023 08:56
@grafana-delivery-bot grafana-delivery-bot bot added this to the 9.5.x milestone Aug 14, 2023
@grafana-delivery-bot grafana-delivery-bot bot requested review from linoman and gamab and removed request for a team August 14, 2023 08:57
@grafana-delivery-bot grafana-delivery-bot bot added area/backend backport A backport PR no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes product-approved Pull requests that are approved by product/managers and are allowed to be backported labels Aug 14, 2023
@IevaVasiljeva IevaVasiljeva enabled auto-merge (squash) August 14, 2023 08:59
@IevaVasiljeva IevaVasiljeva merged commit aa80c1c into v9.5.x Aug 14, 2023
15 of 16 checks passed
@IevaVasiljeva IevaVasiljeva deleted the backport-65902-to-v9.5.x branch August 14, 2023 09:13
@guicaulada guicaulada modified the milestones: 9.5.x, 9.5.8 Aug 16, 2023
@IevaVasiljeva IevaVasiljeva added add to changelog and removed no-changelog Skip including change in changelog/release notes labels Aug 17, 2023
grafana-delivery-bot bot added a commit that referenced this pull request Aug 17, 2023
GenericOAuth: Set sub as auth id (#65902)

* GenericOAuth: Set sud as auth id

* GenericOAuth: Extract function to reduce complexity

(cherry picked from commit 7cd6018)

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/backend backport A backport PR no-backport Skip backport of PR product-approved Pull requests that are approved by product/managers and are allowed to be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants