diff --git a/api/http/handler/auth/authenticate_oauth.go b/api/http/handler/auth/authenticate_oauth.go index 0e198f35f..b090cb98f 100644 --- a/api/http/handler/auth/authenticate_oauth.go +++ b/api/http/handler/auth/authenticate_oauth.go @@ -35,8 +35,7 @@ func (handler *Handler) authenticateOAuth(code string, settings *portainer.OAuth username, err := handler.OAuthService.Authenticate(code, settings) if err != nil { - log.Printf("[DEBUG] - Unable to authenticate user via OAuth: %v", err) - return "", nil + return "", err } return username, nil diff --git a/api/oauth/oauth.go b/api/oauth/oauth.go index 7b6866c90..f0bf6b102 100644 --- a/api/oauth/oauth.go +++ b/api/oauth/oauth.go @@ -88,6 +88,13 @@ func getUsername(token string, configuration *portainer.OAuthSettings) (string, } username := values.Get(configuration.UserIdentifier) + if username == "" { + return username, &oauth2.RetrieveError{ + Response: resp, + Body: body, + } + } + return username, nil } diff --git a/app/portainer/oauth/components/oauth-settings/oauth-settings.html b/app/portainer/oauth/components/oauth-settings/oauth-settings.html index f6703c812..ead2b6fca 100644 --- a/app/portainer/oauth/components/oauth-settings/oauth-settings.html +++ b/app/portainer/oauth/components/oauth-settings/oauth-settings.html @@ -56,7 +56,7 @@ Client secret
- +