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 Summary
FieldsModifier and TypeFieldDescriptionprotected final AccessRefreshTokenGeneratorprotected final AccessTokenConfigurationprotected final List<LoginCookieProvider<io.micronaut.http.HttpRequest<?>>> protected final RefreshTokenCookieConfigurationFields inherited from class io.micronaut.security.token.cookie.CookieLoginHandler
accessTokenCookieConfiguration, loginFailure, loginSuccess, priorToLoginPersistence, refresh -
Constructor Summary
ConstructorsConstructorDescriptionTokenCookieLoginHandler(RedirectService redirectService, RedirectConfiguration redirectConfiguration, AccessTokenCookieConfiguration accessTokenCookieConfiguration, RefreshTokenCookieConfiguration refreshTokenCookieConfiguration, AccessTokenConfiguration accessTokenConfiguration, AccessRefreshTokenGenerator accessRefreshTokenGenerator, @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.TokenCookieLoginHandler(RedirectService redirectService, RedirectConfiguration redirectConfiguration, AccessTokenCookieConfiguration accessTokenCookieConfiguration, RefreshTokenCookieConfiguration refreshTokenCookieConfiguration, AccessTokenConfiguration accessTokenConfiguration, AccessRefreshTokenGenerator accessRefreshTokenGenerator, @Nullable PriorToLoginPersistence<io.micronaut.http.HttpRequest<?>, io.micronaut.http.MutableHttpResponse<?>> priorToLoginPersistence, List<LoginCookieProvider<io.micronaut.http.HttpRequest<?>>> loginCookieProviders) -
Method Summary
Modifier and TypeMethodDescriptionprotected @NonNull io.micronaut.http.cookie.CookieaccessTokenCookie(@NonNull AccessRefreshToken accessRefreshToken, @NonNull io.micronaut.http.HttpRequest<?> request) Instantiates an Access Token Cookie.protected @NonNull List<io.micronaut.http.cookie.Cookie> getCookies(@NonNull Authentication authentication, @NonNull AccessRefreshToken accessRefreshToken, @NonNull io.micronaut.http.HttpRequest<?> request) Return the cookies for the given parameters.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.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.OverridegetCookies(Authentication, AccessRefreshToken, HttpRequest)instead.protected @NonNull Optional<io.micronaut.http.cookie.Cookie> refreshTokenCookie(@NonNull AccessRefreshToken accessRefreshToken, @NonNull io.micronaut.http.HttpRequest<?> request) Instantiates a Refresh Token Cookie.final voidsetTokenConfiguration(@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.Methods inherited from class io.micronaut.security.token.cookie.CookieLoginHandler
applyCookies, createRefreshResponse, createSuccessResponse, loginFailed, loginRefresh, loginSuccess
-
Field Details
-
accessRefreshTokenGenerator
-
refreshTokenCookieConfiguration
-
accessTokenConfiguration
-
loginCookieProviders
-
-
Constructor Details
-
TokenCookieLoginHandler
@Inject public TokenCookieLoginHandler(RedirectService redirectService, RedirectConfiguration redirectConfiguration, AccessTokenCookieConfiguration accessTokenCookieConfiguration, RefreshTokenCookieConfiguration refreshTokenCookieConfiguration, AccessTokenConfiguration accessTokenConfiguration, AccessRefreshTokenGenerator accessRefreshTokenGenerator, @Nullable @Nullable PriorToLoginPersistence<io.micronaut.http.HttpRequest<?>, io.micronaut.http.MutableHttpResponse<?>> priorToLoginPersistence, List<LoginCookieProvider<io.micronaut.http.HttpRequest<?>>> loginCookieProviders) - Parameters:
redirectService- Redirection ServiceredirectConfiguration- Redirect configurationaccessTokenCookieConfiguration- JWT Access Token Cookie ConfigurationrefreshTokenCookieConfiguration- Refresh Token Cookie ConfigurationaccessTokenConfiguration- JWT Generator ConfigurationaccessRefreshTokenGenerator- Access Refresh Token GeneratorpriorToLoginPersistence- Prior To Login Persistence MechanismloginCookieProviders- Login Cookie Providers
-
TokenCookieLoginHandler
@Deprecated(forRemoval=true, since="4.11.0") public TokenCookieLoginHandler(RedirectService redirectService, RedirectConfiguration redirectConfiguration, AccessTokenCookieConfiguration accessTokenCookieConfiguration, RefreshTokenCookieConfiguration refreshTokenCookieConfiguration, AccessTokenConfiguration accessTokenConfiguration, AccessRefreshTokenGenerator accessRefreshTokenGenerator, @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:
redirectService- Redirection ServiceredirectConfiguration- Redirect configurationaccessTokenCookieConfiguration- JWT Access Token Cookie ConfigurationrefreshTokenCookieConfiguration- Refresh Token Cookie ConfigurationaccessTokenConfiguration- JWT Generator ConfigurationaccessRefreshTokenGenerator- Access Refresh Token GeneratorpriorToLoginPersistence- Prior To Login Persistence Mechanism
-
-
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 theTokenConfigurationbecomes a constructor parameter. Subclasses should not rely on it.Sets the Token Configuration used to name the authentication supplied to theLoginCookieProviderbeans 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 defaultmicronaut.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:CookieLoginHandlerReturn the cookies for the given parameters. This method will generate new cookies based on the current configuration.- Specified by:
getCookiesin 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) Description copied from class:CookieLoginHandlerReturn the cookies for the given parameters. This method will generate new cookies based on the current configuration.- Specified by:
getCookiesin classCookieLoginHandler- Parameters:
authentication- The Authenticated user's representationrefreshToken- The access refresh tokenrequest- 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 theLoginCookieProviderbeans are generated for the authenticated user viaLoginCookieProvider.provideCookie(Object, Authentication), with the authentication named as token based authentication names the user from the issued token (themicronaut.security.token.name-keyclaim, falling back to the principal name). The cookies are obtained fromgetCookies(AccessRefreshToken, HttpRequest), so that subclasses overriding it keep their customizations, and the values of the cookies supplied by theLoginCookieProviderbeans are then replaced with the ones generated for the authenticated user.- Parameters:
authentication- The Authenticated user's representationaccessRefreshToken- The access refresh tokenrequest- 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.OverridegetCookies(Authentication, AccessRefreshToken, HttpRequest)instead. This method is still invoked on login bygetCookies(Authentication, AccessRefreshToken, HttpRequest), which then replaces the values of the cookies supplied byLoginCookieProviderbeans with the ones bound to the authenticated user, so an override keeps its customizations; the cookies it supplies viaLoginCookieProvider.provideCookie(Object)are not bound to the user by themselves.Return the cookies for the given parameters.- Parameters:
accessRefreshToken- The access refresh tokenrequest- 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 tokenrequest- 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 tokenrequest- The current request- Returns:
- Refresh Token Cookie
-
TokenCookieLoginHandler(RedirectService, RedirectConfiguration, AccessTokenCookieConfiguration, RefreshTokenCookieConfiguration, AccessTokenConfiguration, AccessRefreshTokenGenerator, PriorToLoginPersistence, List)instead.