java.lang.Object
org.springframework.security.oauth2.server.resource.web.reactive.function.client.ServletBearerExchangeFilterFunction
All Implemented Interfaces:
org.springframework.web.reactive.function.client.ExchangeFilterFunction

public final class ServletBearerExchangeFilterFunction extends Object implements org.springframework.web.reactive.function.client.ExchangeFilterFunction
An ExchangeFilterFunction that adds the Bearer Token from an existing OAuth2Token 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 , as a @Bean will take care of this automatically, but certainly an application can supply a Context of its own to override.
Since:
5.2
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.web.reactive.function.client.ExchangeFilterFunction

    andThen, apply
  • Constructor Details

    • ServletBearerExchangeFilterFunction

      public ServletBearerExchangeFilterFunction()
  • Method Details

    • filter

      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)
      Specified by:
      filter in interface org.springframework.web.reactive.function.client.ExchangeFilterFunction