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.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) -
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
-
-
Constructor Details
-
LoginController
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) - 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
-