Class TokenCookieLoginHandler

java.lang.Object
io.micronaut.security.token.cookie.CookieLoginHandler
io.micronaut.security.token.cookie.TokenCookieLoginHandler
All Implemented Interfaces:
LoginHandler<io.micronaut.http.HttpRequest<?>,io.micronaut.http.MutableHttpResponse<?>>, RedirectingLoginHandler<io.micronaut.http.HttpRequest<?>,io.micronaut.http.MutableHttpResponse<?>>

@Requires(classes=io.micronaut.http.HttpRequest.class) @Requires(property="micronaut.security.authentication",value="cookie") @Singleton public class TokenCookieLoginHandler extends CookieLoginHandler
Since:
1.0
Author:
Sergio del Amo
  • Field Details

  • Constructor Details

  • Method Details

    • setTokenConfiguration

      @Deprecated(forRemoval=true, since="4.18.2") @Inject public final void setTokenConfiguration(@NonNull @NonNull TokenConfiguration tokenConfiguration)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Method injection is used only to keep the existing constructors of this class and of its subclasses working. This method will be removed in the next major release in favour of pure constructor injection, when the TokenConfiguration becomes a constructor parameter. Subclasses should not rely on it.
      Sets the Token Configuration used to name the authentication supplied to the LoginCookieProvider beans as token based authentication names the user from the issued token. Injected by method rather than by constructor so that subclasses using any constructor get the application's configuration. Defaults to the default micronaut.security.token.name-key, sub.
      Parameters:
      tokenConfiguration - Token Configuration
      Since:
      4.18.2
    • getCookies

      public List<io.micronaut.http.cookie.Cookie> getCookies(Authentication authentication, io.micronaut.http.HttpRequest<?> request)
      Description copied from class: CookieLoginHandler
      Return the cookies for the given parameters. This method will generate new cookies based on the current configuration.
      Specified by:
      getCookies in class CookieLoginHandler
      Parameters:
      authentication - The Authenticated user's representation
      request - The current request
      Returns:
      A list of cookies
    • getCookies

      public List<io.micronaut.http.cookie.Cookie> getCookies(Authentication authentication, String refreshToken, io.micronaut.http.HttpRequest<?> request)
      Description copied from class: CookieLoginHandler
      Return the cookies for the given parameters. This method will generate new cookies based on the current configuration.
      Specified by:
      getCookies in class CookieLoginHandler
      Parameters:
      authentication - The Authenticated user's representation
      refreshToken - The access refresh token
      request - The current request
      Returns:
      A list of cookies
    • getCookies

      @NonNull protected @NonNull List<io.micronaut.http.cookie.Cookie> getCookies(@NonNull @NonNull Authentication authentication, @NonNull @NonNull AccessRefreshToken accessRefreshToken, @NonNull @NonNull io.micronaut.http.HttpRequest<?> request)
      Return the cookies for the given parameters. The cookies supplied by the LoginCookieProvider beans are generated for the authenticated user via LoginCookieProvider.provideCookie(Object, Authentication), with the authentication named as token based authentication names the user from the issued token (the micronaut.security.token.name-key claim, falling back to the principal name). The cookies are obtained from getCookies(AccessRefreshToken, HttpRequest), so that subclasses overriding it keep their customizations, and the values of the cookies supplied by the LoginCookieProvider beans are then replaced with the ones generated for the authenticated user.
      Parameters:
      authentication - The Authenticated user's representation
      accessRefreshToken - The access refresh token
      request - The current request
      Returns:
      A list of cookies
      Since:
      4.18.2
    • getCookies

      @Deprecated(forRemoval=true, since="4.18.2") protected List<io.micronaut.http.cookie.Cookie> getCookies(AccessRefreshToken accessRefreshToken, io.micronaut.http.HttpRequest<?> request)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Override getCookies(Authentication, AccessRefreshToken, HttpRequest) instead. This method is still invoked on login by getCookies(Authentication, AccessRefreshToken, HttpRequest), which then replaces the values of the cookies supplied by LoginCookieProvider beans with the ones bound to the authenticated user, so an override keeps its customizations; the cookies it supplies via LoginCookieProvider.provideCookie(Object) are not bound to the user by themselves.
      Return the cookies for the given parameters.
      Parameters:
      accessRefreshToken - The access refresh token
      request - The current request
      Returns:
      A list of cookies
    • accessTokenCookie

      @NonNull protected @NonNull io.micronaut.http.cookie.Cookie accessTokenCookie(@NonNull @NonNull AccessRefreshToken accessRefreshToken, @NonNull @NonNull io.micronaut.http.HttpRequest<?> request)
      Instantiates an Access Token Cookie.
      Parameters:
      accessRefreshToken - The access refresh token
      request - The current request
      Returns:
      Access Token Cookie
    • refreshTokenCookie

      @NonNull protected @NonNull Optional<io.micronaut.http.cookie.Cookie> refreshTokenCookie(@NonNull @NonNull AccessRefreshToken accessRefreshToken, @NonNull @NonNull io.micronaut.http.HttpRequest<?> request)
      Instantiates a Refresh Token Cookie.
      Parameters:
      accessRefreshToken - The access refresh token
      request - The current request
      Returns:
      Refresh Token Cookie