Skip to content

Commit

Permalink
TT-13271, PR cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-tyk committed Nov 1, 2024
1 parent 48e627d commit c323e18
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions gateway/mw_oauth2_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ func (cache *upstreamOAuthPasswordCache) getToken(r *http.Request, OAuthSpec *Up
}

if tokenData != "" {
if tokenData != "" {
tokenContents, err := unmarshalTokenData(tokenData)
if err != nil {
return "", err
}
decryptedToken := decrypt(getPaddedSecret(OAuthSpec.Gw.GetConfig().Secret), tokenContents.Token)
setExtraMetadata(r, OAuthSpec.Spec.UpstreamAuth.OAuth.PasswordAuthentication.ExtraMetadata, tokenContents.ExtraMetadata)
return decryptedToken, nil
tokenContents, err := unmarshalTokenData(tokenData)
if err != nil {
return "", err
}
decryptedToken := decrypt(getPaddedSecret(OAuthSpec.Gw.GetConfig().Secret), tokenContents.Token)
setExtraMetadata(r, OAuthSpec.Spec.UpstreamAuth.OAuth.PasswordAuthentication.ExtraMetadata, tokenContents.ExtraMetadata)
return decryptedToken, nil
}

token, err := cache.obtainToken(r.Context(), OAuthSpec)
Expand Down Expand Up @@ -355,20 +353,6 @@ func buildMetadataMap(token *oauth2.Token, extraMetadataKeys []string) map[strin
return metadataMap
}

//func setExtraMetadata(r *http.Request, keyList []string, token *oauth2.Token) {
// contextDataObject := ctxGetData(r)
// if contextDataObject == nil {
// contextDataObject = make(map[string]interface{})
// }
// for _, key := range keyList {
// val := token.Extra(key)
// if val != "" {
// contextDataObject[key] = val
// }
// }
// ctxSetData(r, contextDataObject)
//}

func setExtraMetadata(r *http.Request, keyList []string, token map[string]interface{}) {
contextDataObject := ctxGetData(r)
if contextDataObject == nil {
Expand Down

0 comments on commit c323e18

Please sign in to comment.