Package org.springframework.security.web.server.csrf

# Interface ServerCsrfTokenRepository

All Known Implementing Classes:
  `CookieServerCsrfTokenRepository`, `WebSessionServerCsrfTokenRepository`

public interface ServerCsrfTokenRepository
An API to allow changing the method in which the expected `CsrfToken` is associated to the `ServerWebExchange`. For example, it may be stored in `WebSession`.

Since:
  5.0
See Also:
  - `WebSessionServerCsrfTokenRepository`

## Method Summary

Modifier and Type
Method
Description
`reactor.core.publisher.Mono<CsrfToken>`
`generateToken(org.springframework.web.server.ServerWebExchange exchange)`
Generates a `CsrfToken`
`reactor.core.publisher.Mono<CsrfToken>`
`loadToken(org.springframework.web.server.ServerWebExchange exchange)`
Loads the expected `CsrfToken` from the `ServerWebExchange`
`reactor.core.publisher.Mono<Void>`
`saveToken(org.springframework.web.server.ServerWebExchange exchange, CsrfToken token)`
Saves the `CsrfToken` using the `ServerWebExchange`.

## Method Details

### generateToken

reactor.core.publisher.Mono<CsrfToken> generateToken(org.springframework.web.server.ServerWebExchange exchange)
Generates a `CsrfToken`

Parameters:
  `exchange` - the `ServerWebExchange` to use
Returns:
  the `CsrfToken` that was generated. Cannot be null.

### saveToken

reactor.core.publisher.Mono<Void> saveToken(org.springframework.web.server.ServerWebExchange exchange, CsrfToken token)
Saves the `CsrfToken` using the `ServerWebExchange`. If the `CsrfToken` is null, it is the same as deleting it.

Parameters:
  `exchange` - the `ServerWebExchange` to use
  `token` - the `CsrfToken` to save or null to delete

### loadToken

reactor.core.publisher.Mono<CsrfToken> loadToken(org.springframework.web.server.ServerWebExchange exchange)
Loads the expected `CsrfToken` from the `ServerWebExchange`

Parameters:
  `exchange` - the `ServerWebExchange` to use
Returns:
  the `CsrfToken` or null if none exists