Class TokenAuthenticationFetcher

java.lang.Object
io.micronaut.security.token.TokenAuthenticationFetcher
All Implemented Interfaces:
io.micronaut.core.order.Ordered, AuthenticationFetcher<io.micronaut.http.HttpRequest<?>>

@Requires(classes=io.micronaut.http.HttpRequest.class) @Singleton public class TokenAuthenticationFetcher extends Object implements AuthenticationFetcher<io.micronaut.http.HttpRequest<?>>
Attempts to retrieve a token form the HttpRequest and if existing validated. It uses a TokenResolver and the list of TokenValidator registered in the ApplicationContext.
Since:
1.0
Author:
Sergio del Amo, Graeme Rocher
  • Field Details

    • ORDER

      public static final Integer ORDER
      The order of the fetcher.
    • tokenValidators

      protected final Collection<TokenValidator<io.micronaut.http.HttpRequest<?>>> tokenValidators
    • tokenValidatedEventPublisher

      protected final io.micronaut.context.event.ApplicationEventPublisher<TokenValidatedEvent> tokenValidatedEventPublisher
  • Constructor Details

    • TokenAuthenticationFetcher

      public TokenAuthenticationFetcher(Collection<TokenValidator<io.micronaut.http.HttpRequest<?>>> tokenValidators, TokenResolver<io.micronaut.http.HttpRequest<?>> tokenResolver, io.micronaut.context.event.ApplicationEventPublisher<TokenValidatedEvent> tokenValidatedEventPublisher)
      Parameters:
      tokenValidators - The list of TokenValidator which attempt to validate the request
      tokenResolver - The TokenResolver which returns the first found token in the request.
      tokenValidatedEventPublisher - Application event publisher for TokenValidatedEvent.
  • Method Details

    • fetchAuthentication

      public org.reactivestreams.Publisher<Authentication> fetchAuthentication(io.micronaut.http.HttpRequest<?> request)
      Description copied from interface: AuthenticationFetcher
      Attempts to read an Authentication from an HTTP Request being executed.
      Specified by:
      fetchAuthentication in interface AuthenticationFetcher<io.micronaut.http.HttpRequest<?>>
      Parameters:
      request - an HTTP Request being executed.
      Returns:
      Authentication if found
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface io.micronaut.core.order.Ordered