Class Authenticator<T>

java.lang.Object
io.micronaut.security.authentication.Authenticator<T>
Type Parameters:
T - Request Context Type

@Requires(condition=io.micronaut.security.authentication.AuthenticatorCondition.class) @Singleton public class Authenticator<T> extends Object
An Authenticator operates on several ReactiveAuthenticationProvider instances returning the first authenticated AuthenticationResponse.

Providers are evaluated one at a time in Ordered precedence order. With the default AuthenticationStrategy.ANY strategy the response of the highest precedence provider that authenticates the request wins, regardless of how fast lower precedence providers answer, and lower precedence providers are not subscribed to once a provider has authenticated the request.

Since:
1.0
Author:
Sergio del Amo, Graeme Rocher
  • Field Details

  • Constructor Details

  • Method Details

    • authenticate

      public org.reactivestreams.Publisher<AuthenticationResponse> authenticate(T requestContext, AuthenticationRequest<?,?> authenticationRequest)
      Authenticates the user with the provided credentials.
      Parameters:
      requestContext - The HTTP request
      authenticationRequest - Represents a request to authenticate.
      Returns:
      A publisher that emits AuthenticationResponse objects
    • isImperativeAuthenticationProviderIsBlocking

      protected boolean isImperativeAuthenticationProviderIsBlocking(AuthenticationProvider<?,?,?> authenticationProvider)
      Returns true if the authentication provider is an ExecutorAuthenticationProvider, whatever the executor it names via ExecutorAuthenticationProvider.getExecutorName(), or if its authenticate method or its class is annotated with Blocking. Such providers declare that they block, so they are never invoked on the thread that subscribes to the authentication publisher (for example the Netty event loop). Executor providers are subscribed on the executor they name; Blocking providers on the blocking executor.

      The Blocking annotation is read from the compile-time bean definition metadata, so it is only honoured for providers created by the bean context (not for instances registered at runtime or constructed by hand).

      Parameters:
      authenticationProvider - An authentication provider
      Returns:
      Whether the authentication provider is blocking.