Interface CsrfTokenRepository
- All Known Implementing Classes:
CookieCsrfTokenRepository
,HttpSessionCsrfTokenRepository
,LazyCsrfTokenRepository
public interface CsrfTokenRepository
An API to allow changing the method in which the expected
CsrfToken
is
associated to the HttpServletRequest
. For example, it may be stored in
HttpSession
.- Since:
- 3.2
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongenerateToken
(jakarta.servlet.http.HttpServletRequest request) Generates aCsrfToken
loadToken
(jakarta.servlet.http.HttpServletRequest request) Loads the expectedCsrfToken
from theHttpServletRequest
void
saveToken
(CsrfToken token, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
-
Method Details
-
generateToken
Generates aCsrfToken
- Parameters:
request
- theHttpServletRequest
to use- Returns:
- the
CsrfToken
that was generated. Cannot be null.
-
saveToken
void saveToken(CsrfToken token, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Saves theCsrfToken
using theHttpServletRequest
andHttpServletResponse
. If theCsrfToken
is null, it is the same as deleting it.- Parameters:
token
- theCsrfToken
to save or null to deleterequest
- theHttpServletRequest
to useresponse
- theHttpServletResponse
to use
-
loadToken
Loads the expectedCsrfToken
from theHttpServletRequest
- Parameters:
request
- theHttpServletRequest
to use- Returns:
- the
CsrfToken
or null if none exists
-