Class ServerCsrfTokenRequestAttributeHandler
- java.lang.Object
-
- org.springframework.security.web.server.csrf.ServerCsrfTokenRequestAttributeHandler
-
- All Implemented Interfaces:
ServerCsrfTokenRequestHandler,ServerCsrfTokenRequestResolver
- Direct Known Subclasses:
XorServerCsrfTokenRequestAttributeHandler
public class ServerCsrfTokenRequestAttributeHandler extends java.lang.Object implements ServerCsrfTokenRequestHandler
An implementation of theServerCsrfTokenRequestHandlerinterface that is capable of making theCsrfTokenavailable as an exchange attribute and resolving the token value as either a form data value or header of the request.- Since:
- 5.8
-
-
Constructor Summary
Constructors Constructor Description ServerCsrfTokenRequestAttributeHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandle(org.springframework.web.server.ServerWebExchange exchange, reactor.core.publisher.Mono<CsrfToken> csrfToken)Handles a request using aCsrfToken.reactor.core.publisher.Mono<java.lang.String>resolveCsrfTokenValue(org.springframework.web.server.ServerWebExchange exchange, CsrfToken csrfToken)Returns the token value resolved from the providedServerWebExchangeandCsrfTokenorMono.empty()if not available.voidsetTokenFromMultipartDataEnabled(boolean tokenFromMultipartDataEnabled)Specifies if theServerCsrfTokenRequestResolvershould try to resolve the actual CSRF token from the body of multipart data requests.
-
-
-
Method Detail
-
handle
public void handle(org.springframework.web.server.ServerWebExchange exchange, reactor.core.publisher.Mono<CsrfToken> csrfToken)Description copied from interface:ServerCsrfTokenRequestHandlerHandles a request using aCsrfToken.- Specified by:
handlein interfaceServerCsrfTokenRequestHandler- Parameters:
exchange- theServerWebExchangewith the request being handledcsrfToken- theMono<CsrfToken>created by theServerCsrfTokenRepository
-
resolveCsrfTokenValue
public reactor.core.publisher.Mono<java.lang.String> resolveCsrfTokenValue(org.springframework.web.server.ServerWebExchange exchange, CsrfToken csrfToken)Description copied from interface:ServerCsrfTokenRequestResolverReturns the token value resolved from the providedServerWebExchangeandCsrfTokenorMono.empty()if not available.- Specified by:
resolveCsrfTokenValuein interfaceServerCsrfTokenRequestHandler- Specified by:
resolveCsrfTokenValuein interfaceServerCsrfTokenRequestResolver- Parameters:
exchange- theServerWebExchangewith the request being processedcsrfToken- theCsrfTokencreated by theServerCsrfTokenRepository- Returns:
- the token value resolved from the request
-
setTokenFromMultipartDataEnabled
public void setTokenFromMultipartDataEnabled(boolean tokenFromMultipartDataEnabled)
Specifies if theServerCsrfTokenRequestResolvershould try to resolve the actual CSRF token from the body of multipart data requests.- Parameters:
tokenFromMultipartDataEnabled- true if should read from multipart form body, else false. Default is false
-
-