Class ClientCredentialsHeaderTokenPropagator

java.lang.Object
io.micronaut.security.oauth2.client.clientcredentials.propagation.ClientCredentialsHeaderTokenPropagator
All Implemented Interfaces:
io.micronaut.core.order.Ordered, ClientCredentialsTokenPropagator
Direct Known Subclasses:
DefaultClientCredentialsTokenPropagator

@Internal @EachBean(OauthClientConfiguration.class) @Requires(condition=ClientCredentialsEnabled.class) @Requires(condition=ClientCredentialsHeaderPropagatorEnabled.class) public class ClientCredentialsHeaderTokenPropagator extends Object implements ClientCredentialsTokenPropagator
Propagates a token obtained via client credentials based off of a header.
Since:
2.2.0
Author:
Sergio del Amo
  • Field Details

  • Constructor Details

  • Method Details

    • writeToken

      public void writeToken(@NonNull @NonNull io.micronaut.http.MutableHttpRequest<?> request, @NonNull @NonNull String token)
      Writes the token to the request.
      Specified by:
      writeToken in interface ClientCredentialsTokenPropagator
      Parameters:
      request - The MutableHttpRequest instance
      token - A token ( e.g. JWT token, basic auth token...)
    • findToken

      public Optional<String> findToken(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request)
      Search for a JWT token in a HTTP request.
      Specified by:
      findToken in interface ClientCredentialsTokenPropagator
      Parameters:
      request - The request to look for the token in
      Returns:
      if the JWT token is found it is returned, empty if not
    • headerValue

      protected String headerValue(String token)
      Parameters:
      token - the token being written
      Returns:
      the value which will be written to an HTTP Header
    • extractTokenFromAuthorization

      protected Optional<String> extractTokenFromAuthorization(String authorization)
      Parameters:
      authorization - Authorization header value
      Returns:
      If prefix is 'Bearer' for 'Bearer XXX' it returns 'XXX'
    • getConfiguration

      Returns:
      The HttpHeaderTokenPropagator Configuration