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

  • 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 from the ID token claims. 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)
      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