From 232c9001fb721e1187b41f6fd0a7fb37bd9c7f6a Mon Sep 17 00:00:00 2001 From: D071517 Date: Wed, 7 Aug 2024 15:57:30 +0200 Subject: [PATCH] Use new introspect endpoint and auth via OAuth --- src/autoscaler/cf/oauth.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/autoscaler/cf/oauth.go b/src/autoscaler/cf/oauth.go index 8fe6c938dc..8bd570e1bf 100644 --- a/src/autoscaler/cf/oauth.go +++ b/src/autoscaler/cf/oauth.go @@ -86,7 +86,14 @@ func (c *CtxClient) getUserScope(ctx context.Context, userToken string) ([]strin c.logger.Error("Failed to create getuserscope request", err, lager.Data{"userScopeEndpoint": userScopeEndpoint}) return nil, err } - req.SetBasicAuth(c.conf.ClientID, c.conf.Secret) + + tokens, err := c.GetTokens(ctx) + if err != nil { + c.logger.Error("Failed to retrieve oauth token from cf client", err, lager.Data{"userScopeEndpoint": userScopeEndpoint}) + return nil, err + } + bearer := "Bearer " + tokens.AccessToken + req.Header.Add("Authorization", bearer) resp, err := c.Client.Do(req) if err != nil { @@ -176,6 +183,6 @@ func (c *CtxClient) getUserScopeEndpoint(ctx context.Context, userToken string) if err != nil { return "", err } - userScopeEndpoint := endpoints.Uaa.Url + "/check_token?" + parameters.Encode() + userScopeEndpoint := endpoints.Uaa.Url + "/introspect?" + parameters.Encode() return userScopeEndpoint, nil }