Class SessionCsrfTokenRepository
java.lang.Object
io.micronaut.security.csrf.session.SessionCsrfTokenRepository
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,CsrfTokenRepository<io.micronaut.http.HttpRequest<?>>
@Requires(classes=io.micronaut.http.HttpRequest.class) @Requires(beans=CsrfConfiguration.class) @Requires(property="micronaut.security.csrf.repositories.session.enabled",value="true",defaultValue="true")
@Singleton
public class SessionCsrfTokenRepository
extends Object
implements CsrfTokenRepository<io.micronaut.http.HttpRequest<?>>
Implementation of
CsrfTokenRepository
that retrieves the CSRF token from an HTTP session using the key defined in CsrfConfiguration.getHttpSessionName()
.- 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
-
SessionCsrfTokenRepository
- 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.
-