com.vaadin.flow.spring.security.
Class VaadinDefaultRequestCache
All Implemented Interfaces:
org.springframework.security.web.savedrequest.RequestCache
A default request cache implementation which aims to ignore requests that are not for routes.
For the requests that are not ignored, delegates the actual saving to the
other RequestCache
instance. Uses an internal
HttpSessionRequestCache
for delegating to, unless a custom delegate
is set using the
setDelegateRequestCache(RequestCache)
method.
Using this class helps with redirecting the user to the correct route after login instead of redirecting to some internal URL like a service worker or some data the service worker has fetched.
Custom request matchers can be provided using the ignoreRequests
method to fine-tune which URLs should be excluded from being cached, in
addition to the default exclusions. This is useful for ignoring
application-specific paths that should never be used as redirect targets
after authentication.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjakarta.servlet.http.HttpServletRequest
getMatchingRequest
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) org.springframework.security.web.savedrequest.SavedRequest
getRequest
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) void
ignoreRequests
(org.springframework.security.web.util.matcher.RequestMatcher requestMatcher) Allows further restricting requests to be saved.
void
removeRequest
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) void
saveRequest
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) void
setDelegateRequestCache
(org.springframework.security.web.savedrequest.RequestCache delegateRequestCache) Sets the cache implementation that is used for the actual saving of the requests that are not ignored.
-
Constructor Details
-
VaadinDefaultRequestCache
public VaadinDefaultRequestCache()
-
-
Method Details
-
saveRequest
public void saveRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Specified by:
saveRequest
in interfaceorg.springframework.security.web.savedrequest.RequestCache
-
getRequest
public org.springframework.security.web.savedrequest.SavedRequest getRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Specified by:
getRequest
in interfaceorg.springframework.security.web.savedrequest.RequestCache
-
getMatchingRequest
public jakarta.servlet.http.HttpServletRequest getMatchingRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Specified by:
getMatchingRequest
in interfaceorg.springframework.security.web.savedrequest.RequestCache
-
removeRequest
public void removeRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Specified by:
removeRequest
in interfaceorg.springframework.security.web.savedrequest.RequestCache
-
setDelegateRequestCache
public void setDelegateRequestCache(org.springframework.security.web.savedrequest.RequestCache delegateRequestCache) Sets the cache implementation that is used for the actual saving of the requests that are not ignored.
Parameters:
delegateRequestCache
- the delegate request cache -
ignoreRequests
public void ignoreRequests(org.springframework.security.web.util.matcher.RequestMatcher requestMatcher) Allows further restricting requests to be saved.
If set, matching requests will not be cached.
Parameters:
requestMatcher
- a request matching strategy which defines which requests should not be cached.
-