- Notifications
You must be signed in to change notification settings - Fork927
fix: Prevent infinite redirects on oidc errors#6550
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -56,6 +56,28 @@ func ExtractOAuth2(config OAuth2Config, client *http.Client) func(http.Handler) | ||
return | ||
} | ||
// OIDC errors can be returned as query parameters. This can happen | ||
// if for example we are providing and invalid scope. | ||
// We should terminate the OIDC process if we encounter an error. | ||
oidcError := r.URL.Query().Get("error") | ||
errorDescription := r.URL.Query().Get("error_description") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Perthe OIDC spec only the Also there is an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I do handle an empty I can add | ||
errorURI := r.URL.Query().Get("error_uri") | ||
if oidcError != "" { | ||
// Combine the errors into a single string if either is provided. | ||
if errorDescription == "" && errorURI != "" { | ||
errorDescription = fmt.Sprintf("error_uri: %s", errorURI) | ||
} else if errorDescription != "" && errorURI != "" { | ||
errorDescription = fmt.Sprintf("%s, error_uri: %s", errorDescription, errorURI) | ||
} | ||
oidcError = fmt.Sprintf("Encountered error in oidc process: %s", oidcError) | ||
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ | ||
Message: oidcError, | ||
// This message might be blank. This is ok. | ||
Detail: errorDescription, | ||
}) | ||
return | ||
} | ||
code := r.URL.Query().Get("code") | ||
state := r.URL.Query().Get("state") | ||