Class CsrfTokenRequestProcessor
- java.lang.Object
-
- org.springframework.security.web.csrf.CsrfTokenRequestProcessor
-
- All Implemented Interfaces:
CsrfTokenRequestAttributeHandler
,CsrfTokenRequestResolver
public class CsrfTokenRequestProcessor extends java.lang.Object implements CsrfTokenRequestAttributeHandler, CsrfTokenRequestResolver
An implementation of theCsrfTokenRequestAttributeHandler
andCsrfTokenRequestResolver
interfaces that is capable of making theCsrfToken
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
Constructors Constructor Description CsrfTokenRequestProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.function.Supplier<CsrfToken> csrfToken)
Handles a request using aCsrfToken
.java.lang.String
resolveCsrfTokenValue(javax.servlet.http.HttpServletRequest request, CsrfToken csrfToken)
Returns the token value resolved from the providedHttpServletRequest
andCsrfToken
ornull
if not available.void
setCsrfRequestAttributeName(java.lang.String csrfRequestAttributeName)
TheCsrfToken
is available as a request attribute namedCsrfToken.class.getName()
.
-
-
-
Method Detail
-
setCsrfRequestAttributeName
public final void setCsrfRequestAttributeName(java.lang.String csrfRequestAttributeName)
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(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.function.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 java.lang.String resolveCsrfTokenValue(javax.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
-
-