From 42d4e1e11c3d0217efe47f8c0e085e5019253c76 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Tue, 24 Sep 2019 11:03:44 +1200 Subject: [PATCH] fix(api): prevent panic in auth when OAuth is enabled (#3179) --- api/http/handler/auth/authenticate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/http/handler/auth/authenticate.go b/api/http/handler/auth/authenticate.go index a2f29e6f9..02159c275 100644 --- a/api/http/handler/auth/authenticate.go +++ b/api/http/handler/auth/authenticate.go @@ -52,7 +52,7 @@ func (handler *Handler) authenticate(w http.ResponseWriter, r *http.Request) *ht return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve a user with the specified username from the database", err} } - if err == portainer.ErrObjectNotFound && settings.AuthenticationMethod == portainer.AuthenticationInternal { + if err == portainer.ErrObjectNotFound && (settings.AuthenticationMethod == portainer.AuthenticationInternal || settings.AuthenticationMethod == portainer.AuthenticationOAuth) { return &httperror.HandlerError{http.StatusUnprocessableEntity, "Invalid credentials", portainer.ErrUnauthorized} }