mitre / HTTP-Proxy-Servlet

Smiley's HTTP Proxy implemented as a Java servlet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

issue:The path of the cookie is changed. More sessions will be created for the same user

javaofferss opened this issue · comments

commented

图片

The path of the cookie is changed. More sessions will be created for the same user

old code:
protected Cookie createProxyCookie(HttpServletRequest servletRequest, HttpCookie cookie) {
String proxyCookieName = getProxyCookieName(cookie);
Cookie servletCookie = new Cookie(proxyCookieName, cookie.getValue());
servletCookie.setPath(buildProxyCookiePath(servletRequest)); //set to the path of the proxy servlet
servletCookie.setComment(cookie.getComment());
servletCookie.setMaxAge((int) cookie.getMaxAge());
// don't set cookie domain
servletCookie.setSecure(cookie.getSecure());
servletCookie.setVersion(cookie.getVersion());
servletCookie.setHttpOnly(cookie.isHttpOnly());
return servletCookie;
}

protected String buildProxyCookiePath(HttpServletRequest servletRequest) {
String path = servletRequest.getContextPath(); // path starts with / or is empty string
path += servletRequest.getServletPath(); // servlet path starts with / or is empty string
if (path.isEmpty()) {
path = "/";
}
return path;
}