Class IdTokenLoginHandler

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

@Requires(property="micronaut.security.authentication",value="idtoken") @Requires(classes=io.micronaut.http.HttpRequest.class) @Singleton public class IdTokenLoginHandler extends CookieLoginHandler
Sets CookieLoginHandler`s cookie value to the idtoken received from an authentication provider. The cookie expiration is set to the expiration of the IDToken exp claim.
Since:
2.0.0
Author:
Sergio del Amo
  • Constructor Details

    • IdTokenLoginHandler

      public IdTokenLoginHandler(AccessTokenCookieConfiguration accessTokenCookieConfiguration, RedirectConfiguration redirectConfiguration, RedirectService redirectService, @Nullable @Nullable PriorToLoginPersistence<io.micronaut.http.HttpRequest<?>,io.micronaut.http.MutableHttpResponse<?>> priorToLoginPersistence)
      Parameters:
      accessTokenCookieConfiguration - Access token cookie configuration
      redirectConfiguration - Redirect configuration
      redirectService - Redirect service
      priorToLoginPersistence - The prior to login persistence strategy
  • Method Details

    • getCookies

      public List<io.micronaut.http.cookie.Cookie> getCookies(Authentication authentication, io.micronaut.http.HttpRequest<?> request)
      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)
      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
    • parseIdToken

      protected Optional<String> parseIdToken(Authentication authentication)
      Parameters:
      authentication - User Details
      Returns:
      parse the idtoken from the user details attributes
    • cookieExpiration

      protected Duration cookieExpiration(Authentication authentication, io.micronaut.http.HttpRequest<?> request)
      Parameters:
      authentication - User Details
      request - The current request
      Returns:
      the expiration of the providers JWT