From 35fa9d6981d1eb869fb43c1f0de2be853826ac51 Mon Sep 17 00:00:00 2001 From: Chaim Lev-Ari Date: Tue, 18 Aug 2020 15:38:58 +0300 Subject: [PATCH] fix(oauth): if username is empty, fail to login (#4232) * fix(oauth): if username is empty, fail to login * fix(oauth): return err when failing to find username * fix(oauth): disable autofill --- api/http/handler/auth/authenticate_oauth.go | 3 +-- api/oauth/oauth.go | 7 +++++++ .../oauth/components/oauth-settings/oauth-settings.html | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) 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
- +