From 6536373c51f211e1aee2bd3827dc097e295b3901 Mon Sep 17 00:00:00 2001 From: Michael Kelly Date: Fri, 3 Dec 2021 10:17:21 -0800 Subject: [PATCH] Fix issues in existing client credentials change This fixes two issues in the existing client credentials change: - client_credentials was not listed as a supported grant type - access tokens are not the storage ID Signed-off-by: Michael Kelly --- server/handlers.go | 8 +++++++- server/server.go | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/server/handlers.go b/server/handlers.go index 6578a12e47..2e6bc08300 100755 --- a/server/handlers.go +++ b/server/handlers.go @@ -1029,7 +1029,13 @@ func (s *Server) handleClientCredentialsGrant(w http.ResponseWriter, r *http.Req claims := storage.Claims{UserID: client.ID} - accessToken := storage.NewID() + accessToken, err := s.newAccessToken(client.ID, claims, scopes, nonce, "client") + if err != nil { + s.logger.Errorf("failed to create new access token: %v", err) + s.tokenErrHelper(w, errServerError, err.Error(), http.StatusInternalServerError) + return + } + idToken, expiry, err := s.newIDToken(client.ID, claims, scopes, nonce, accessToken, "", "client") if err != nil { s.tokenErrHelper(w, errServerError, fmt.Sprintf("failed to create ID token: %v", err), http.StatusInternalServerError) diff --git a/server/server.go b/server/server.go index ecd6c935ed..0ed464e125 100755 --- a/server/server.go +++ b/server/server.go @@ -222,7 +222,12 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy) supportedRes[respType] = true } - supportedGrant := []string{grantTypeAuthorizationCode, grantTypeRefreshToken, grantTypeDeviceCode} // default + supportedGrant := []string{ + grantTypeAuthorizationCode, + grantTypeRefreshToken, + grantTypeDeviceCode, + grantTypeClientCredentials, + } // default if c.PasswordConnector != "" { supportedGrant = append(supportedGrant, grantTypePassword) }