Class CsrfTokenRequestAttributeHandler
java.lang.Object
org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler
- All Implemented Interfaces:
CsrfTokenRequestHandler
,CsrfTokenRequestResolver
- Direct Known Subclasses:
XorCsrfTokenRequestAttributeHandler
An implementation of the
CsrfTokenRequestHandler
interface 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> deferredCsrfToken) Handles a request using aCsrfToken
.final void
setCsrfRequestAttributeName
(String csrfRequestAttributeName) TheCsrfToken
is available as a request attribute namedCsrfToken.class.getName()
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.security.web.csrf.CsrfTokenRequestHandler
resolveCsrfTokenValue
-
Constructor Details
-
CsrfTokenRequestAttributeHandler
public CsrfTokenRequestAttributeHandler()
-
-
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> deferredCsrfToken) Description copied from interface:CsrfTokenRequestHandler
Handles a request using aCsrfToken
.- Specified by:
handle
in interfaceCsrfTokenRequestHandler
- Parameters:
request
- theHttpServletRequest
being handledresponse
- theHttpServletResponse
being handleddeferredCsrfToken
- theCsrfToken
created by theCsrfTokenRepository
-