Skip to content

Commit

Permalink
Merge pull request #317 from bmarwell/SHIRO-678
Browse files Browse the repository at this point in the history
[SHIRO-678] only query parameters for sessionID if found
  • Loading branch information
bmarwell committed Aug 18, 2021
2 parents 0c0d9da + 3077275 commit 41fb3ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Expand Up @@ -130,11 +130,15 @@ private Serializable getReferencedSessionId(ServletRequest request, ServletRespo
//try the URI path segment parameters first:
id = getUriPathSegmentParamValue(request, ShiroHttpSession.DEFAULT_SESSION_ID_NAME);

if (id == null) {
if (id == null && request instanceof HttpServletRequest) {
//not a URI path segment parameter, try the query parameters:
String name = getSessionIdName();
id = request.getParameter(name);
if (id == null) {
HttpServletRequest httpServletRequest = WebUtils.toHttp(request);
String queryString = httpServletRequest.getQueryString();
if (queryString != null && queryString.contains(name)) {
id = request.getParameter(name);
}
if (id == null && queryString != null && queryString.contains(name.toLowerCase())) {
//try lowercase:
id = request.getParameter(name.toLowerCase());
}
Expand Down
Expand Up @@ -158,6 +158,7 @@ public class DefaultWebSessionManagerTest {

expect(cookie.getName()).andReturn(ShiroHttpSession.DEFAULT_SESSION_ID_NAME);
expect(request.getRequestURI()).andReturn("/foo/bar?JSESSIONID=$id" as String)
expect(request.getQueryString()).andReturn("JSESSIONID=$id" as String)
expect(request.getParameter(ShiroHttpSession.DEFAULT_SESSION_ID_NAME)).andReturn(id);
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE,
ShiroHttpServletRequest.URL_SESSION_ID_SOURCE);
Expand Down Expand Up @@ -193,8 +194,8 @@ public class DefaultWebSessionManagerTest {
String id = "12345";

expect(cookie.getName()).andReturn(ShiroHttpSession.DEFAULT_SESSION_ID_NAME);
expect(request.getRequestURI()).andReturn("/foo/bar?JSESSIONID=$id" as String)
expect(request.getParameter(ShiroHttpSession.DEFAULT_SESSION_ID_NAME)).andReturn(null);
expect(request.getRequestURI()).andReturn("/foo/bar?jsessionid=$id" as String)
expect(request.getQueryString()).andReturn("jsessionid=$id" as String)
expect(request.getParameter(ShiroHttpSession.DEFAULT_SESSION_ID_NAME.toLowerCase())).andReturn(id);
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE,
ShiroHttpServletRequest.URL_SESSION_ID_SOURCE);
Expand Down

0 comments on commit 41fb3ac

Please sign in to comment.