Class ClientCredentialsHttpClientFilter

java.lang.Object
io.micronaut.security.oauth2.client.clientcredentials.propagation.ClientCredentialsHttpClientFilter
All Implemented Interfaces:
io.micronaut.core.order.Ordered, io.micronaut.http.filter.HttpClientFilter, io.micronaut.http.filter.HttpFilter

@Filter("/**") public class ClientCredentialsHttpClientFilter extends Object implements io.micronaut.http.filter.HttpClientFilter
An HttpClientFilter to add an access token to outgoing request thanks to a Client Credentials request.
Since:
2.2.0
Author:
Sergio del Amo
  • Field Details

    • outgoingHttpRequestProcessor

      protected final io.micronaut.http.util.OutgoingHttpRequestProcessor outgoingHttpRequestProcessor
    • oauthClientConfigurationCollection

      protected final List<OauthClientConfiguration> oauthClientConfigurationCollection
    • beanContext

      protected final io.micronaut.context.BeanContext beanContext
    • clientCredentialsClientsByName

      protected final Map<String,ClientCredentialsClient> clientCredentialsClientsByName
    • clientCredentialsTokenHandlerByName

      protected final Map<String,ClientCredentialsTokenPropagator> clientCredentialsTokenHandlerByName
  • Constructor Details

    • ClientCredentialsHttpClientFilter

      public ClientCredentialsHttpClientFilter(io.micronaut.http.util.OutgoingHttpRequestProcessor outgoingHttpRequestProcessor, Stream<OauthClientConfiguration> oauthClientConfigurationStream, ClientCredentialsTokenPropagator defaultTokenPropagator, io.micronaut.context.BeanContext beanContext)
      Parameters:
      outgoingHttpRequestProcessor - Utility to decide whether to process the request
      oauthClientConfigurationStream - OAuth 2.0 Clients configuration stream
      defaultTokenPropagator - The default token propagator
      beanContext - Bean Context
  • Method Details

    • doFilter

      public org.reactivestreams.Publisher<? extends io.micronaut.http.HttpResponse<?>> doFilter(io.micronaut.http.MutableHttpRequest<?> request, io.micronaut.http.filter.ClientFilterChain chain)
      Specified by:
      doFilter in interface io.micronaut.http.filter.HttpClientFilter
    • getScope

      @Nullable protected @Nullable String getScope(@NonNull @NonNull OauthClientConfiguration oauthClient)
      Parameters:
      oauthClient - OAuth 2.0 Client configuration
      Returns:
      The desired scope for client credentials grant or null if no scope should be specified
    • getClient

      protected Optional<ClientCredentialsClient> getClient(@NonNull @NonNull OauthClientConfiguration oauthClient)
      Parameters:
      oauthClient - OAuth 2.0 Client configuration
      Returns:
      The Client credentials client for the OAuth 2.0 Client.
    • getTokenHandler

      protected ClientCredentialsTokenPropagator getTokenHandler(@NonNull @NonNull OauthClientConfiguration oauthClient)
      Parameters:
      oauthClient - OAuth 2.0 Client configuration
      Returns:
      The Client credentials token propagator for the OAuth 2.0 Client.
    • getClientConfiguration

      protected Optional<OauthClientConfiguration> getClientConfiguration(io.micronaut.http.HttpRequest<?> request)
      Parameters:
      request - Http Request
      Returns:
      An OAuth 2.0 Client configuration which has client credentials configuration set and should process the request