Update internal/oidc/token_exchange.go for latest Fosite version.

The `fosite.TokenEndpointHandler` changed and now requires some additional methods.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2021-03-01 13:08:41 -06:00
parent 234465789b
commit c832cab8d0
No known key found for this signature in database
GPG Key ID: EAE88AD172C5AE2D

View File

@ -40,8 +40,10 @@ type TokenExchangeHandler struct {
accessTokenStorage oauth2.AccessTokenStorage
}
var _ fosite.TokenEndpointHandler = (*TokenExchangeHandler)(nil)
func (t *TokenExchangeHandler) HandleTokenEndpointRequest(ctx context.Context, requester fosite.AccessRequester) error {
if !(requester.GetGrantTypes().ExactOne("urn:ietf:params:oauth:grant-type:token-exchange")) {
if !t.CanHandleTokenEndpointRequest(requester) {
return errors.WithStack(fosite.ErrUnknownRequest)
}
return nil
@ -139,3 +141,11 @@ func (t *TokenExchangeHandler) validateAccessToken(ctx context.Context, requeste
}
return originalRequester, nil
}
func (t *TokenExchangeHandler) CanSkipClientAuth(_ fosite.AccessRequester) bool {
return false
}
func (t *TokenExchangeHandler) CanHandleTokenEndpointRequest(requester fosite.AccessRequester) bool {
return requester.GetGrantTypes().ExactOne("urn:ietf:params:oauth:grant-type:token-exchange")
}