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
-
Field Summary
Fields inherited from class io.micronaut.security.token.cookie.CookieLoginHandler
accessTokenCookieConfiguration, loginFailure, loginSuccess, priorToLoginPersistence, refresh
-
Constructor Summary
ConstructorDescriptionIdTokenLoginHandler
(AccessTokenCookieConfiguration accessTokenCookieConfiguration, RedirectConfiguration redirectConfiguration, RedirectService redirectService, @Nullable PriorToLoginPersistence<io.micronaut.http.HttpRequest<?>, io.micronaut.http.MutableHttpResponse<?>> priorToLoginPersistence) Deprecated, for removal: This API element is subject to removal in a future version.IdTokenLoginHandler
(AccessTokenCookieConfiguration accessTokenCookieConfiguration, RedirectConfiguration redirectConfiguration, RedirectService redirectService, @Nullable PriorToLoginPersistence<io.micronaut.http.HttpRequest<?>, io.micronaut.http.MutableHttpResponse<?>> priorToLoginPersistence, List<LoginCookieProvider<io.micronaut.http.HttpRequest<?>>> loginCookieProviders) -
Method Summary
Modifier and TypeMethodDescriptionprotected Duration
cookieExpiration
(Authentication authentication, io.micronaut.http.HttpRequest<?> request) List<io.micronaut.http.cookie.Cookie>
getCookies
(Authentication authentication, io.micronaut.http.HttpRequest<?> request) Return the cookies for the given parameters.List<io.micronaut.http.cookie.Cookie>
getCookies
(Authentication authentication, String refreshToken, io.micronaut.http.HttpRequest<?> request) Return the cookies for the given parameters.parseIdToken
(Authentication authentication) Methods inherited from class io.micronaut.security.token.cookie.CookieLoginHandler
applyCookies, createRefreshResponse, createSuccessResponse, loginFailed, loginRefresh, loginSuccess
-
Constructor Details
-
IdTokenLoginHandler
@Inject public IdTokenLoginHandler(AccessTokenCookieConfiguration accessTokenCookieConfiguration, RedirectConfiguration redirectConfiguration, RedirectService redirectService, @Nullable @Nullable PriorToLoginPersistence<io.micronaut.http.HttpRequest<?>, io.micronaut.http.MutableHttpResponse<?>> priorToLoginPersistence, List<LoginCookieProvider<io.micronaut.http.HttpRequest<?>>> loginCookieProviders) - Parameters:
accessTokenCookieConfiguration
- Access token cookie configurationredirectConfiguration
- Redirect configurationredirectService
- Redirect servicepriorToLoginPersistence
- The prior to login persistence strategyloginCookieProviders
- List of beans of typeLoginCookieProvider
-
IdTokenLoginHandler
@Deprecated(forRemoval=true, since="4.11.0") public IdTokenLoginHandler(AccessTokenCookieConfiguration accessTokenCookieConfiguration, RedirectConfiguration redirectConfiguration, RedirectService redirectService, @Nullable @Nullable PriorToLoginPersistence<io.micronaut.http.HttpRequest<?>, io.micronaut.http.MutableHttpResponse<?>> priorToLoginPersistence) Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
accessTokenCookieConfiguration
- Access token cookie configurationredirectConfiguration
- Redirect configurationredirectService
- Redirect servicepriorToLoginPersistence
- 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 classCookieLoginHandler
- Parameters:
authentication
- The Authenticated user's representationrequest
- 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 classCookieLoginHandler
- Parameters:
authentication
- The Authenticated user's representationrefreshToken
- The access refresh tokenrequest
- The current request- Returns:
- A list of cookies
-
parseIdToken
- 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 Detailsrequest
- The current request- Returns:
- the expiration of the providers JWT
-
IdTokenLoginHandler(AccessTokenCookieConfiguration, RedirectConfiguration, RedirectService, PriorToLoginPersistence, List)
instead.