diff --git a/api/http/handler/auth/authenticate.go b/api/http/handler/auth/authenticate.go index 02159c275..56441c33a 100644 --- a/api/http/handler/auth/authenticate.go +++ b/api/http/handler/auth/authenticate.go @@ -113,6 +113,11 @@ func (handler *Handler) authenticateLDAPAndCreateUser(w http.ResponseWriter, use log.Printf("Warning: unable to automatically add user into teams: %s\n", err.Error()) } + err = handler.AuthorizationService.UpdateUsersAuthorizations() + if err != nil { + return &httperror.HandlerError{http.StatusInternalServerError, "Unable to update user authorizations", err} + } + return handler.writeToken(w, user) } diff --git a/api/http/handler/auth/authenticate_oauth.go b/api/http/handler/auth/authenticate_oauth.go index 849859d9f..de0cbd8dc 100644 --- a/api/http/handler/auth/authenticate_oauth.go +++ b/api/http/handler/auth/authenticate_oauth.go @@ -133,6 +133,11 @@ func (handler *Handler) validateOAuth(w http.ResponseWriter, r *http.Request) *h return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist team membership inside the database", err} } } + + err = handler.AuthorizationService.UpdateUsersAuthorizations() + if err != nil { + return &httperror.HandlerError{http.StatusInternalServerError, "Unable to update user authorizations", err} + } } return handler.writeToken(w, user) diff --git a/api/http/handler/auth/handler.go b/api/http/handler/auth/handler.go index 8d10abf29..24a211f94 100644 --- a/api/http/handler/auth/handler.go +++ b/api/http/handler/auth/handler.go @@ -34,6 +34,7 @@ type Handler struct { EndpointGroupService portainer.EndpointGroupService RoleService portainer.RoleService ProxyManager *proxy.Manager + AuthorizationService *portainer.AuthorizationService } // NewHandler creates a handler to manage authentication operations. diff --git a/api/http/server.go b/api/http/server.go index 90a7abd68..066bc7bef 100644 --- a/api/http/server.go +++ b/api/http/server.go @@ -136,6 +136,7 @@ func (server *Server) Start() error { authHandler.EndpointGroupService = server.EndpointGroupService authHandler.RoleService = server.RoleService authHandler.ProxyManager = proxyManager + authHandler.AuthorizationService = authorizationService var roleHandler = roles.NewHandler(requestBouncer) roleHandler.RoleService = server.RoleService