In my understanding, Spring Cloud Gateway must implement a HTTP client to make the reverse proxy requests. Spring framework provides just that, the WebClient. I don't know if Spring Cloud Gateway actually uses it internally.
If so, is possible to have access to the WebClient instance? This will allow to configure the client's attributes. One of the possibilities is to provide an OAuth2 authorized client to configure the requests with the Authorization header, like in here:
WebClient webClient;
@RegisteredOAuth2AuthorizedClient("client-id") OAuth2AuthorizedClient authorizedClient;
this.webClient
.get()
.uri(this.uri)
.attributes(oauth2AuthorizedClient(authorizedClient));
The need to do this is to integrate with the password authorization grant type, Spring doesn't provide a way to do this smoothly. Here you can find more about this scenario.
WebClient
. That said, you can access the request viaServerWebExchange
in a filter to add/modify/remove request headers. – spencergibb