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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidhandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Supplier<CsrfToken> deferredCsrfToken) Handles a request using aCsrfToken.final voidsetCsrfRequestAttributeName(String csrfRequestAttributeName) TheCsrfTokenis 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, waitMethods inherited from interface org.springframework.security.web.csrf.CsrfTokenRequestHandler
resolveCsrfTokenValue
-
Constructor Details
-
CsrfTokenRequestAttributeHandler
public CsrfTokenRequestAttributeHandler()
-
-
Method Details
-
setCsrfRequestAttributeName
TheCsrfTokenis 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:CsrfTokenRequestHandlerHandles a request using aCsrfToken.- Specified by:
handlein interfaceCsrfTokenRequestHandler- Parameters:
request- theHttpServletRequestbeing handledresponse- theHttpServletResponsebeing handleddeferredCsrfToken- theCsrfTokencreated by theCsrfTokenRepository
-