Class CsrfTokenRequestProcessor
java.lang.Object
org.springframework.security.web.csrf.CsrfTokenRequestProcessor
- All Implemented Interfaces:
CsrfTokenRequestAttributeHandler
,CsrfTokenRequestResolver
public class CsrfTokenRequestProcessor
extends Object
implements CsrfTokenRequestAttributeHandler, CsrfTokenRequestResolver
An implementation of the
CsrfTokenRequestAttributeHandler
and
CsrfTokenRequestResolver
interfaces that is capable of making the
CsrfToken
available as a request attribute and resolving the token value as
either a header or parameter value of the request.- Since:
- 5.8
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
handle
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Supplier<CsrfToken> csrfToken) Handles a request using aCsrfToken
.resolveCsrfTokenValue
(jakarta.servlet.http.HttpServletRequest request, CsrfToken csrfToken) Returns the token value resolved from the providedHttpServletRequest
andCsrfToken
ornull
if not available.final void
setCsrfRequestAttributeName
(String csrfRequestAttributeName) TheCsrfToken
is available as a request attribute namedCsrfToken.class.getName()
.
-
Constructor Details
-
CsrfTokenRequestProcessor
public CsrfTokenRequestProcessor()
-
-
Method Details
-
setCsrfRequestAttributeName
TheCsrfToken
is available as a request attribute namedCsrfToken.class.getName()
. By default, an additional request attribute that is the same asCsrfToken.getParameterName()
is set. This attribute allows overriding the additional attribute.- Parameters:
csrfRequestAttributeName
- the name of an additional request attribute with the value of the CsrfToken. Default isCsrfToken.getParameterName()
-
handle
public void handle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Supplier<CsrfToken> csrfToken) Description copied from interface:CsrfTokenRequestAttributeHandler
Handles a request using aCsrfToken
.- Specified by:
handle
in interfaceCsrfTokenRequestAttributeHandler
- Parameters:
request
- theHttpServletRequest
being handledresponse
- theHttpServletResponse
being handledcsrfToken
- theCsrfToken
created by theCsrfTokenRepository
-
resolveCsrfTokenValue
public String resolveCsrfTokenValue(jakarta.servlet.http.HttpServletRequest request, CsrfToken csrfToken) Description copied from interface:CsrfTokenRequestResolver
Returns the token value resolved from the providedHttpServletRequest
andCsrfToken
ornull
if not available.- Specified by:
resolveCsrfTokenValue
in interfaceCsrfTokenRequestResolver
- Parameters:
request
- theHttpServletRequest
being processedcsrfToken
- theCsrfToken
created by theCsrfTokenRepository
- Returns:
- the token value resolved from the request
-