1
0
Fork 0
mirror of https://github.com/Luzifer/nginx-sso.git synced 2024-12-20 12:51: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:
Knut Ahlers 2019-11-03 18:43:22 +01:00
parent e83dc6a124
commit 07b98e0a57
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -224,6 +224,10 @@ func (a *AuthOIDC) getOAuthConfig() *oauth2.Config {
func (a *AuthOIDC) getUserFromToken(ctx context.Context, token *oauth2.Token) (string, error) { func (a *AuthOIDC) getUserFromToken(ctx context.Context, token *oauth2.Token) (string, error) {
ui, err := a.provider.UserInfo(ctx, oauth2.StaticTokenSource(token)) ui, err := a.provider.UserInfo(ctx, oauth2.StaticTokenSource(token))
if err != nil { 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") return "", errors.Wrap(err, "Unable to fetch user info")
} }