mirror of
https://github.com/Luzifer/nginx-sso.git
synced 2024-12-20 04:41:17 +00:00
Fix: Handle Unauthorized as no user found instead of generic error
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
e83dc6a124
commit
07b98e0a57
1 changed files with 4 additions and 0 deletions
|
@ -224,6 +224,10 @@ func (a *AuthOIDC) getOAuthConfig() *oauth2.Config {
|
|||
func (a *AuthOIDC) getUserFromToken(ctx context.Context, token *oauth2.Token) (string, error) {
|
||||
ui, err := a.provider.UserInfo(ctx, oauth2.StaticTokenSource(token))
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "401 Unauthorized") {
|
||||
// Handle Unauthorized as no user found instead of generic error
|
||||
return "", plugins.ErrNoValidUserFound
|
||||
}
|
||||
return "", errors.Wrap(err, "Unable to fetch user info")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue