Class CookieLoginHandler
java.lang.Object
io.micronaut.security.token.cookie.CookieLoginHandler
- All Implemented Interfaces:
LoginHandler<io.micronaut.http.HttpRequest<?>,
,io.micronaut.http.MutableHttpResponse<?>> RedirectingLoginHandler<io.micronaut.http.HttpRequest<?>,
io.micronaut.http.MutableHttpResponse<?>>
- Direct Known Subclasses:
IdTokenLoginHandler
,TokenCookieLoginHandler
public abstract class CookieLoginHandler
extends Object
implements RedirectingLoginHandler<io.micronaut.http.HttpRequest<?>,io.micronaut.http.MutableHttpResponse<?>>
Abstract class which defines an implementation of
RedirectingLoginHandler
where a redirect response is issued.
For a successful login a cookie is added to the response with a token.- Since:
- 2.0.0
- Author:
- Sergio del Amo
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AccessTokenCookieConfiguration
protected final @Nullable String
protected final @Nullable String
protected final PriorToLoginPersistence<io.micronaut.http.HttpRequest<?>,
io.micronaut.http.MutableHttpResponse<?>> protected final @Nullable String
-
Constructor Summary
ModifierConstructorDescriptionprotected
CookieLoginHandler
(AccessTokenCookieConfiguration accessTokenCookieConfiguration, RedirectConfiguration redirectConfiguration, RedirectService redirectService, @Nullable PriorToLoginPersistence priorToLoginPersistence) -
Method Summary
Modifier and TypeMethodDescriptionprotected io.micronaut.http.MutableHttpResponse<?>
applyCookies
(io.micronaut.http.MutableHttpResponse<?> response, List<io.micronaut.http.cookie.Cookie> cookies) protected io.micronaut.http.MutableHttpResponse<?>
createRefreshResponse
(io.micronaut.http.HttpRequest<?> request) protected io.micronaut.http.MutableHttpResponse<?>
createSuccessResponse
(io.micronaut.http.HttpRequest<?> request) abstract List<io.micronaut.http.cookie.Cookie>
getCookies
(Authentication authentication, io.micronaut.http.HttpRequest<?> request) Return the cookies for the given parameters.abstract List<io.micronaut.http.cookie.Cookie>
getCookies
(Authentication authentication, String refreshToken, io.micronaut.http.HttpRequest<?> request) Return the cookies for the given parameters.io.micronaut.http.MutableHttpResponse<?>
loginFailed
(AuthenticationResponse authenticationFailed, io.micronaut.http.HttpRequest<?> request) io.micronaut.http.MutableHttpResponse<?>
loginRefresh
(Authentication authentication, String refreshToken, io.micronaut.http.HttpRequest<?> request) io.micronaut.http.MutableHttpResponse<?>
loginSuccess
(Authentication authentication, io.micronaut.http.HttpRequest<?> request)
-
Field Details
-
accessTokenCookieConfiguration
-
priorToLoginPersistence
protected final PriorToLoginPersistence<io.micronaut.http.HttpRequest<?>,io.micronaut.http.MutableHttpResponse<?>> priorToLoginPersistence -
loginFailure
-
loginSuccess
-
refresh
-
-
Constructor Details
-
CookieLoginHandler
protected CookieLoginHandler(AccessTokenCookieConfiguration accessTokenCookieConfiguration, RedirectConfiguration redirectConfiguration, RedirectService redirectService, @Nullable @Nullable PriorToLoginPersistence priorToLoginPersistence) - Parameters:
accessTokenCookieConfiguration
- Access token cookie configurationredirectConfiguration
- Redirect configurationredirectService
- Redirect servicepriorToLoginPersistence
- The prior to login persistence strategy
-
-
Method Details
-
getCookies
public abstract 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.- Parameters:
authentication
- The Authenticated user's representationrequest
- The current request- Returns:
- A list of cookies
-
getCookies
public abstract 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.- Parameters:
authentication
- The Authenticated user's representationrefreshToken
- The access refresh tokenrequest
- The current request- Returns:
- A list of cookies
-
loginSuccess
public io.micronaut.http.MutableHttpResponse<?> loginSuccess(Authentication authentication, io.micronaut.http.HttpRequest<?> request) - Specified by:
loginSuccess
in interfaceLoginHandler<io.micronaut.http.HttpRequest<?>,
io.micronaut.http.MutableHttpResponse<?>> - Parameters:
authentication
- Authenticated user's representation.request
- The HTTP Request being executed- Returns:
- An HTTP Response. Eg. a redirect or an JWT token rendered to the response
-
loginFailed
public io.micronaut.http.MutableHttpResponse<?> loginFailed(AuthenticationResponse authenticationFailed, io.micronaut.http.HttpRequest<?> request) - Specified by:
loginFailed
in interfaceLoginHandler<io.micronaut.http.HttpRequest<?>,
io.micronaut.http.MutableHttpResponse<?>> - Parameters:
authenticationFailed
- Object encapsulates the Login failurerequest
- TheHttpRequest
being executed- Returns:
- A 303 HTTP Response or 401 HTTP Response if
loginFailure
is null, for example ifRedirectConfiguration
is disabled.
-
loginRefresh
public io.micronaut.http.MutableHttpResponse<?> loginRefresh(Authentication authentication, String refreshToken, io.micronaut.http.HttpRequest<?> request) - Specified by:
loginRefresh
in interfaceLoginHandler<io.micronaut.http.HttpRequest<?>,
io.micronaut.http.MutableHttpResponse<?>> - Parameters:
authentication
- Authenticated user's representation.refreshToken
- The refresh tokenrequest
- The HTTP Request being executed- Returns:
- An HTTP Response. Eg. a redirect or an JWT token rendered to the response
-
createSuccessResponse
protected io.micronaut.http.MutableHttpResponse<?> createSuccessResponse(io.micronaut.http.HttpRequest<?> request) - Parameters:
request
- The request- Returns:
- A 303 HTTP Response or 200 HTTP Response if
loginSuccess
is null, for example ifRedirectConfiguration
is disabled.
-
createRefreshResponse
protected io.micronaut.http.MutableHttpResponse<?> createRefreshResponse(io.micronaut.http.HttpRequest<?> request) - Parameters:
request
- The request- Returns:
- A 303 HTTP Response or 200 HTTP Response if
refresh
is null.
-
applyCookies
protected io.micronaut.http.MutableHttpResponse<?> applyCookies(io.micronaut.http.MutableHttpResponse<?> response, List<io.micronaut.http.cookie.Cookie> cookies) - Parameters:
response
- The responsecookies
- Cookies to be added to the response- Returns:
- A 303 HTTP Response with cookies
-