-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Open
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triagedtype: bugA general bugA general bug
Description
Describe the bug
RequestCache.getRequest returns the SavedRequest. However, CookieRequestCache.getRequest implementation returns a SavedRequest without parameters; Hence, calling getParameterValues will always return null. On the other hand, HttpSessionRequestCache implementation works as expected.
As a workaround, I rely on SavedRequest.getRedirectUrl and extract the parameters from there.
To Reproduce
For example, use CookieRequestCache and go through an oauth2 flow. On callback, the SavedRequest has no parameters.
Expected behavior
SavedRequest.getParameterValues should return the parameters if they are available in the url.
Proposed solution
class CookieRequestCache
@Override
public @Nullable SavedRequest getRequest(HttpServletRequest request, HttpServletResponse response) {
Cookie savedRequestCookie = WebUtils.getCookie(request, COOKIE_NAME);
if (savedRequestCookie == null) {
return null;
}
String originalURI = decodeCookie(savedRequestCookie.getValue());
if (originalURI == null) {
return null;
}
UriComponents uriComponents = UriComponentsBuilder.fromUriString(originalURI).build();
DefaultSavedRequest.Builder builder = new DefaultSavedRequest.Builder();
int port = getPort(uriComponents);
MultiValueMap<String, String> queryParams = uriComponents.getQueryParams();
Map<String, String[]> parameterMap = queryParams.entrySet().stream().collect(
Collectors.toMap(
Map.Entry::getKey,
entry -> entry.getValue().toArray(new String[0])));
return builder.setScheme(uriComponents.getScheme())
.setServerName(uriComponents.getHost())
.setRequestURI(uriComponents.getPath())
.setQueryString(uriComponents.getQuery())
.setServerPort(port)
.setMethod(request.getMethod())
.setLocales(Collections.list(request.getLocales()))
.setParameters(parameterMap)
.build();
}
Metadata
Metadata
Assignees
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triagedtype: bugA general bugA general bug