add support for RFC8693 (Token Exchange / Token Delegation) #863
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RFC 8693 - OAuth 2.0 Token Exchange
This package implements
RFC 8693 - OAuth 2.0 Token Exchange for
Fosite.
Feedback welcome ! Harry Kodden, SURF harry.kodden - at - surf.nl
Overview
OAuth 2.0 Token Exchange allows clients to exchange one token for another token.
This is useful for scenarios such as:
identity provider) into a local token
reduced privileges
scopes
or services
Configuration
To enable RFC 8693 Token Exchange, you need to:
1. Enable Token Exchange in Configuration
2. Register the Handler
Usage
Client Authentication
The RFC 8693 Token Exchange endpoint supports both HTTP Basic Authentication and
form-based client authentication:
HTTP Basic Authentication (Recommended):
Form-Based Authentication:
Basic Token Exchange Request
Token Exchange with Form-Based Client Authentication
Token Exchange with Scope Restriction
Token Exchange with Actor (Delegation)
Successful Response
Token Types
The following token types are supported by default:
urn:ietf:params:oauth:token-type:access_token
- OAuth 2.0 access tokensurn:ietf:params:oauth:token-type:refresh_token
- OAuth 2.0 refresh tokensurn:ietf:params:oauth:token-type:id_token
- OpenID Connect ID tokensurn:ietf:params:oauth:token-type:jwt
- Generic JWT tokensYou can configure which token types are supported via the
TokenExchangeTokenTypes
configuration option.Parameters
Required Parameters
grant_type
: Must beurn:ietf:params:oauth:grant-type:token-exchange
subject_token
: The token to be exchangedsubject_token_type
: The type of the subject tokenOptional Parameters
requested_token_type
: The type of token being requested (defaults toaccess_token)
audience
: The intended audience for the issued tokenscope
: The requested scope (must be a subset of the subject token's scope)resource
: The physical or logical location of the target resourceactor_token
: Token representing the party authorized to use the issued tokenactor_token_type
: The type of the actor tokenError Responses
Token exchange can return the following error types:
invalid_request
- Missing or invalid required parametersinvalid_client
- Client authentication failedinvalid_grant
- Subject token is invalid, expired, or revokedinvalid_scope
- Requested scope exceeds subject token scopeinvalid_target
- Requested audience is not allowedunsupported_grant_type
- Token exchange is disabledSecurity Considerations
and form-based client authentication. HTTP Basic Authentication is
recommended as it keeps credentials out of the request body and logs.
requested audience
Example Implementation
See
example_storage.go
for a basic implementation that shows how to integratewith existing Fosite storage patterns.
Checklist
If this pull request addresses a security vulnerability,
I confirm that I got approval (please contact security@ory.sh) from the maintainers to push the changes.
Further comments