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

OAuth: Return SocialError on membership check failure #98330

Merged

Conversation

Daniel-Davies
Copy link
Contributor

What is this feature?

Propagation of a public facing error message using the existing SocialError construct that is already used in Azure OAuth in a similar context.

Details in existing issue. A quick bottom line: for the generic oauth plugin, the server administrator can specify that a user must be a member of certain oauth groups to access grafana. Currently, if a user fails this check, they are presented with an error screen that specifies 'InternalError' with no context. This is obviously very confusing to users, who then assume that Grafana is in an outage state or misconfigured.

Why do we need this feature?

See existing issue: #95800

We are facing significant user confusion in the current state. When a user is not a member of the teams that have been configured by a server administrator, they are met with an InternalError. This makes no sense.

Which issue(s) does this PR fix?:

Fixes #95800

Special notes for your reviewer:

Please check that:

  • [ X ] It works as expected from a user's perspective. (Yes - set up testing locally with keycloak)
  • The docs are updated, and if this is a notable improvement (Don't believe this to be the case)

@Daniel-Davies Daniel-Davies requested a review from a team as a code owner December 20, 2024 16:35
@Daniel-Davies Daniel-Davies requested review from dmihai and kalleep and removed request for a team December 20, 2024 16:35
@github-actions github-actions bot added this to the 11.5.x milestone Dec 20, 2024
@grafana-pr-automation grafana-pr-automation bot added area/backend pr/external This PR is from external contributor labels Dec 20, 2024
@@ -320,11 +319,11 @@ func (s *SocialGenericOAuth) UserInfo(ctx context.Context, client *http.Client,
}

if !s.isTeamMember(ctx, client) {
return nil, errors.New("user not a member of one of the required teams")
return nil, &SocialError{"User not a member of one of the required teams"}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This follows what the current setup for other OAuth providers is. See below:

errMissingGroupMembership = &SocialError{"user not a member of one of the required groups"}

@Daniel-Davies
Copy link
Contributor Author

Daniel-Davies commented Dec 20, 2024

Here is what the frontend looks like now:

397171902-acb2065f-a534-41ec-b0f3-7b794b61600f

@Daniel-Davies
Copy link
Contributor Author

Can this be backported to version 11.2.x and above by any chance?

@mgyongyosi mgyongyosi added no-changelog Skip including change in changelog/release notes type/bug labels Jan 13, 2025
@mgyongyosi mgyongyosi self-requested a review January 13, 2025 09:25
@mgyongyosi mgyongyosi changed the title Return SocialError on membership check failure OAuth: Return SocialError on membership check failure Jan 13, 2025
@mgyongyosi mgyongyosi enabled auto-merge (squash) January 13, 2025 09:38
@mgyongyosi mgyongyosi merged commit ddca09f into grafana:main Jan 13, 2025
31 checks passed
@mgyongyosi
Copy link
Contributor

Thank you @Daniel-Davies for your contribution!

@mgyongyosi mgyongyosi added backport v11.2.x Mark PR for automatic backport to v11.2.x backport v11.3.x Mark PR for automatic backport to v11.3.x labels Jan 13, 2025
grafana-delivery-bot bot pushed a commit that referenced this pull request Jan 13, 2025
grafana-delivery-bot bot pushed a commit that referenced this pull request Jan 13, 2025
@mgyongyosi mgyongyosi added the backport v11.4.x Mark PR for automatic backport to v11.4.x label Jan 13, 2025
grafana-delivery-bot bot pushed a commit that referenced this pull request Jan 13, 2025
mgyongyosi pushed a commit that referenced this pull request Jan 13, 2025
OAuth: Return SocialError on membership check failure (#98330)

use socialerror

(cherry picked from commit ddca09f)

Co-authored-by: Daniel-Davies <33356828+Daniel-Davies@users.noreply.github.com>
mgyongyosi pushed a commit that referenced this pull request Jan 13, 2025
OAuth: Return SocialError on membership check failure (#98330)

use socialerror

(cherry picked from commit ddca09f)

Co-authored-by: Daniel-Davies <33356828+Daniel-Davies@users.noreply.github.com>
mgyongyosi pushed a commit that referenced this pull request Jan 13, 2025
OAuth: Return SocialError on membership check failure (#98330)

use socialerror

(cherry picked from commit ddca09f)

Co-authored-by: Daniel-Davies <33356828+Daniel-Davies@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend backport v11.2.x Mark PR for automatic backport to v11.2.x backport v11.3.x Mark PR for automatic backport to v11.3.x backport v11.4.x Mark PR for automatic backport to v11.4.x no-changelog Skip including change in changelog/release notes pr/external This PR is from external contributor type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OAuth team check failure should be more descriptive
2 participants