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

    • CookieCsrfTokenRepository

      public CookieCsrfTokenRepository(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.