Package io.micronaut.security.endpoints
Class LoginController<B>
java.lang.Object
io.micronaut.security.endpoints.LoginController<B>
- Type Parameters:
B
- The HTTP Request Body type
@Requires(property="micronaut.security.endpoints.login.enabled",notEquals="false",defaultValue="true") @Requires(classes=io.micronaut.http.annotation.Controller.class) @Requires(beans={LoginHandler.class,Authenticator.class})
@Controller("${micronaut.security.endpoints.login.path:/login}")
@Secured("isAnonymous()")
public class LoginController<B>
extends Object
Handles login requests.
- Since:
- 1.0
- Author:
- Sergio del Amo, Graeme Rocher
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Authenticator<io.micronaut.http.HttpRequest<B>>
protected final io.micronaut.http.server.util.HttpHostResolver
protected final io.micronaut.http.server.util.locale.HttpLocaleResolver
protected final io.micronaut.context.event.ApplicationEventPublisher<LoginFailedEvent>
protected final LoginHandler<io.micronaut.http.HttpRequest<?>,
io.micronaut.http.MutableHttpResponse<?>> protected final io.micronaut.context.event.ApplicationEventPublisher<LoginSuccessfulEvent>
-
Constructor Summary
ConstructorDescriptionLoginController
(Authenticator<io.micronaut.http.HttpRequest<B>> authenticator, LoginHandler<io.micronaut.http.HttpRequest<?>, io.micronaut.http.MutableHttpResponse<?>> loginHandler, io.micronaut.context.event.ApplicationEventPublisher<LoginSuccessfulEvent> loginSuccessfulEventPublisher, io.micronaut.context.event.ApplicationEventPublisher<LoginFailedEvent> loginFailedEventPublisher) Deprecated, for removal: This API element is subject to removal in a future version.LoginController
(Authenticator<io.micronaut.http.HttpRequest<B>> authenticator, LoginHandler<io.micronaut.http.HttpRequest<?>, io.micronaut.http.MutableHttpResponse<?>> loginHandler, io.micronaut.context.event.ApplicationEventPublisher<LoginSuccessfulEvent> loginSuccessfulEventPublisher, io.micronaut.context.event.ApplicationEventPublisher<LoginFailedEvent> loginFailedEventPublisher, io.micronaut.http.server.util.HttpHostResolver httpHostResolver, io.micronaut.http.server.util.locale.HttpLocaleResolver httpLocaleResolver) -
Method Summary
Modifier and TypeMethodDescriptionorg.reactivestreams.Publisher<io.micronaut.http.MutableHttpResponse<?>>
login
(@Valid UsernamePasswordCredentials usernamePasswordCredentials, io.micronaut.http.HttpRequest<B> request)
-
Field Details
-
authenticator
-
loginHandler
protected final LoginHandler<io.micronaut.http.HttpRequest<?>,io.micronaut.http.MutableHttpResponse<?>> loginHandler -
loginSuccessfulEventPublisher
protected final io.micronaut.context.event.ApplicationEventPublisher<LoginSuccessfulEvent> loginSuccessfulEventPublisher -
loginFailedEventPublisher
protected final io.micronaut.context.event.ApplicationEventPublisher<LoginFailedEvent> loginFailedEventPublisher -
httpHostResolver
protected final io.micronaut.http.server.util.HttpHostResolver httpHostResolver -
httpLocaleResolver
protected final io.micronaut.http.server.util.locale.HttpLocaleResolver httpLocaleResolver
-
-
Constructor Details
-
LoginController
@Inject public LoginController(Authenticator<io.micronaut.http.HttpRequest<B>> authenticator, LoginHandler<io.micronaut.http.HttpRequest<?>, io.micronaut.http.MutableHttpResponse<?>> loginHandler, io.micronaut.context.event.ApplicationEventPublisher<LoginSuccessfulEvent> loginSuccessfulEventPublisher, io.micronaut.context.event.ApplicationEventPublisher<LoginFailedEvent> loginFailedEventPublisher, io.micronaut.http.server.util.HttpHostResolver httpHostResolver, io.micronaut.http.server.util.locale.HttpLocaleResolver httpLocaleResolver) - Parameters:
authenticator
-Authenticator
collaboratorloginHandler
- A collaborator which helps to build HTTP response depending on success or failure.loginSuccessfulEventPublisher
- Application event publisher forLoginSuccessfulEvent
.loginFailedEventPublisher
- Application event publisher forLoginFailedEvent
.httpHostResolver
- The http host resolverhttpLocaleResolver
- The http locale resolver- Since:
- 4.7.0
-
LoginController
@Deprecated(forRemoval=true, since="4.7.0") public LoginController(Authenticator<io.micronaut.http.HttpRequest<B>> authenticator, LoginHandler<io.micronaut.http.HttpRequest<?>, io.micronaut.http.MutableHttpResponse<?>> loginHandler, io.micronaut.context.event.ApplicationEventPublisher<LoginSuccessfulEvent> loginSuccessfulEventPublisher, io.micronaut.context.event.ApplicationEventPublisher<LoginFailedEvent> loginFailedEventPublisher) Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
authenticator
-Authenticator
collaboratorloginHandler
- A collaborator which helps to build HTTP response depending on success or failure.loginSuccessfulEventPublisher
- Application event publisher forLoginSuccessfulEvent
.loginFailedEventPublisher
- Application event publisher forLoginFailedEvent
.
-
-
Method Details
-
login
@Consumes({"application/x-www-form-urlencoded","application/json"}) @Post @SingleResult public org.reactivestreams.Publisher<io.micronaut.http.MutableHttpResponse<?>> login(@Valid @Body @Valid UsernamePasswordCredentials usernamePasswordCredentials, io.micronaut.http.HttpRequest<B> request) - Parameters:
usernamePasswordCredentials
- An instance ofUsernamePasswordCredentials
in the body payloadrequest
- TheHttpRequest
being executed- Returns:
- An AccessRefreshToken encapsulated in the HttpResponse or a failure indicated by the HTTP status
-
LoginController(Authenticator, LoginHandler, ApplicationEventPublisher, ApplicationEventPublisher)
instead