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 Summary
FieldsModifier and TypeFieldDescriptionprotected final Collection<AuthenticationProvider<T>> Deprecated, for removal: This API element is subject to removal in a future version.Unused. -
Constructor Summary
ConstructorsConstructorDescriptionAuthenticator(io.micronaut.context.BeanContext beanContext, List<ReactiveAuthenticationProvider<T, ?, ?>> reactiveAuthenticationProviders, List<AuthenticationProvider<T, ?, ?>> authenticationProviders, SecurityConfiguration securityConfiguration) Deprecated.Authenticator(io.micronaut.context.BeanContext beanContext, List<ReactiveAuthenticationProvider<T, ?, ?>> reactiveAuthenticationProviders, List<AuthenticationProvider<T, ?, ?>> authenticationProviders, List<AuthenticationProvider<T>> deprecatedAuthenticationProviders, SecurityConfiguration securityConfiguration) Authenticator(Collection<AuthenticationProvider<T>> deprecatedAuthenticationProviders, SecurityConfiguration securityConfiguration) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionorg.reactivestreams.Publisher<AuthenticationResponse> authenticate(T requestContext, AuthenticationRequest<?, ?> authenticationRequest) Authenticates the user with the provided credentials.protected booleanisImperativeAuthenticationProviderIsBlocking(AuthenticationProvider<?, ?, ?> authenticationProvider) Returnstrueif the authentication provider is anExecutorAuthenticationProvider, whatever the executor it names viaExecutorAuthenticationProvider.getExecutorName(), or if itsauthenticatemethod or its class is annotated withBlocking.
-
Field Details
-
authenticationProviders
@Deprecated(forRemoval=true, since="4.5.0") protected final Collection<AuthenticationProvider<T>> authenticationProvidersDeprecated, for removal: This API element is subject to removal in a future version.Unused. To be removed in the next major version.
-
-
Constructor Details
-
Authenticator
@Inject public Authenticator(io.micronaut.context.BeanContext beanContext, List<ReactiveAuthenticationProvider<T, ?, ?>> reactiveAuthenticationProviders, List<AuthenticationProvider<T, ?, ?>> authenticationProviders, List<AuthenticationProvider<T>> deprecatedAuthenticationProviders, SecurityConfiguration securityConfiguration) - Parameters:
beanContext- Bean ContextreactiveAuthenticationProviders- A list of available Reactive authentication providersauthenticationProviders- A list of available imperative authentication providersdeprecatedAuthenticationProviders- A list of available deprecated authentication providerssecurityConfiguration- The security configuration
-
Authenticator
public Authenticator(io.micronaut.context.BeanContext beanContext, List<ReactiveAuthenticationProvider<T, ?, ?>> reactiveAuthenticationProviders, List<AuthenticationProvider<T, ?, ?>> authenticationProviders, SecurityConfiguration securityConfiguration) Deprecated.- Parameters:
beanContext- Bean ContextreactiveAuthenticationProviders- A list of available Reactive authentication providersauthenticationProviders- A list of available imperative authentication providerssecurityConfiguration- The security configuration
-
Authenticator
@Deprecated(forRemoval=true, since="4.5.0") public Authenticator(Collection<AuthenticationProvider<T>> deprecatedAuthenticationProviders, SecurityConfiguration securityConfiguration) Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
deprecatedAuthenticationProviders- A list of available authentication providerssecurityConfiguration- The security configuration
-
-
Method Details
-
authenticate
public org.reactivestreams.Publisher<AuthenticationResponse> authenticate(T requestContext, AuthenticationRequest<?, ?> authenticationRequest) Authenticates the user with the provided credentials.- Parameters:
requestContext- The HTTP requestauthenticationRequest- Represents a request to authenticate.- Returns:
- A publisher that emits
AuthenticationResponseobjects
-
isImperativeAuthenticationProviderIsBlocking
protected boolean isImperativeAuthenticationProviderIsBlocking(AuthenticationProvider<?, ?, ?> authenticationProvider) Returnstrueif the authentication provider is anExecutorAuthenticationProvider, whatever the executor it names viaExecutorAuthenticationProvider.getExecutorName(), or if itsauthenticatemethod or its class is annotated withBlocking. 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;Blockingproviders on theblockingexecutor.The
Blockingannotation 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.
-