KEMBAR78
Specify clientRegistrationId in TokenRelay filter by sjohnr · Pull Request #2922 · spring-cloud/spring-cloud-gateway · GitHub
Skip to content

Conversation

@sjohnr
Copy link
Contributor

@sjohnr sjohnr commented Apr 14, 2023

This PR adds the ability to specify a clientRegistrationId for the TokenRelay GatewayFilter.

  • If the clientRegistrationId is specified, it is used to build the OAuth2AuthorizeRequest.
  • Otherwise, if the user has logged in via oauth2Login(), the existing OAuth2AuthenticationToken.getAuthorizedClientRegistrationId() is used.

With this enhancement, the gateway can be used to manage many ClientRegistrations, and each route can determine which client registration to use. This is incredibly useful in scenarios where there are (for example):

a) multiple authorization servers in use simultaneously
b) multiple client authentication methods in use simultaneously
c) some/all downstream services require a distinct clientId, aud claim, etc.
d) some/all downstream services require different token formats (e.g. JWT, opaque)

@spencergibb spencergibb added this to the 4.1.0-M2 milestone Sep 6, 2023
@spencergibb spencergibb merged commit 984882f into spring-cloud:main Sep 6, 2023
@sjohnr sjohnr deleted the token-relay branch September 6, 2023 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants