public final class ServletBearerExchangeFilterFunction
extends java.lang.Object
implements org.springframework.web.reactive.function.client.ExchangeFilterFunction
ExchangeFilterFunction that adds the
Bearer
Token from an existing AbstractOAuth2Token tied to the current
Authentication.
Suitable for Servlet applications, applying it to a typical
WebClient configuration:
@Bean
WebClient webClient() {
ServletBearerExchangeFilterFunction bearer = new ServletBearerExchangeFilterFunction();
return WebClient.builder()
.filter(bearer).build();
}
To locate the bearer token, this looks in the Reactor Context for a key of type
Authentication.
Registering
org.springframework.security.config.annotation.web.configuration.OAuth2ResourceServerConfiguration.OAuth2ResourceServerWebFluxSecurityConfiguration.BearerRequestContextSubscriberRegistrar,
as a @Bean will take care of this automatically, but certainly an application
can supply a Context of its own to override.| Constructor and Description |
|---|
ServletBearerExchangeFilterFunction() |
| Modifier and Type | Method and Description |
|---|---|
reactor.core.publisher.Mono<org.springframework.web.reactive.function.client.ClientResponse> |
filter(org.springframework.web.reactive.function.client.ClientRequest request,
org.springframework.web.reactive.function.client.ExchangeFunction next) |
public reactor.core.publisher.Mono<org.springframework.web.reactive.function.client.ClientResponse> filter(org.springframework.web.reactive.function.client.ClientRequest request,
org.springframework.web.reactive.function.client.ExchangeFunction next)
filter in interface org.springframework.web.reactive.function.client.ExchangeFilterFunction