Class CookieCsrfTokenRepository
java.lang.Object
io.micronaut.security.csrf.repository.CookieCsrfTokenRepository
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,CsrfTokenRepository<io.micronaut.http.HttpRequest<?>>
@Requires(classes=io.micronaut.http.HttpRequest.class) @Requires(property="micronaut.security.csrf.repository.cookie.enabled",value="true",defaultValue="true")
@Singleton
public class CookieCsrfTokenRepository
extends Object
implements CsrfTokenRepository<io.micronaut.http.HttpRequest<?>>
Retrieves a CSRF Token from a Cookie named
CookieConfiguration.getCookieName()
, for example, in a Double Submit Cookie pattern.- Since:
- 4.11.0
- Author:
- Sergio del Amo
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfindCsrfToken
(@NonNull io.micronaut.http.HttpRequest<?> request) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
-
Constructor Details
-
CookieCsrfTokenRepository
- Parameters:
csrfConfiguration
- CSRF Configuration
-
-
Method Details
-
findCsrfToken
@NonNull public @NonNull Optional<String> findCsrfToken(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request) - Specified by:
findCsrfToken
in interfaceCsrfTokenRepository<io.micronaut.http.HttpRequest<?>>
- Parameters:
request
- Request- Returns:
- A CSRF token or an empty optional.
-