Class CsrfTokenRequestAttributeHandler
- java.lang.Object
-
- org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler
-
- All Implemented Interfaces:
CsrfTokenRequestHandler
,CsrfTokenRequestResolver
- Direct Known Subclasses:
XorCsrfTokenRequestAttributeHandler
public class CsrfTokenRequestAttributeHandler extends java.lang.Object implements CsrfTokenRequestHandler
An implementation of theCsrfTokenRequestHandler
interface 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 CsrfTokenRequestAttributeHandler()
-
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> deferredCsrfToken)
Handles a request using aCsrfToken
.void
setCsrfRequestAttributeName(java.lang.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
-
-
-
-
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> 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
-
-