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
  • Constructor Details

    • SessionCsrfTokenRepository

      public SessionCsrfTokenRepository(CsrfConfiguration csrfConfiguration)
      Parameters:
      csrfConfiguration - CSRF Configuration
  • Method Details

    • findCsrfToken

      @NonNull public @NonNull Optional<String> findCsrfToken(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request)
      Specified by:
      findCsrfToken in interface CsrfTokenRepository<io.micronaut.http.HttpRequest<?>>
      Parameters:
      request - Request
      Returns:
      A CSRF token or an empty optional.