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 Details

    • authenticator

      protected final Authenticator<io.micronaut.http.HttpRequest<B>> 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 collaborator
      loginHandler - A collaborator which helps to build HTTP response depending on success or failure.
      loginSuccessfulEventPublisher - Application event publisher for LoginSuccessfulEvent.
      loginFailedEventPublisher - Application event publisher for LoginFailedEvent.
  • 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 of UsernamePasswordCredentials in the body payload
      request - The HttpRequest being executed
      Returns:
      An AccessRefreshToken encapsulated in the HttpResponse or a failure indicated by the HTTP status