"Applied fix from trunk for revision: 1832756"

------------------------------------------------------------------------
r1832756 | jleroux | 2018-06-03 10:33:09 +0200 (dim. 03 juin 2018) | 21 lignes

Fixed: Session fixation issue
(OFBIZ-10420)

Prevents the session fixation by making Tomcat generate a new jsessionId 
(ultimately put in cookie). Only do when really signing in to avoid unnecessary 
calls

This improves the way it's done by using request.changeSessionId() instead of 
creating a brand new session. So there is no possible side effects on client and
no need to set initial request info (using setInitialRequestInfo)

Thanks: Taher for asking about it









------------------------------------------------------------------------


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12@1832757 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacques Le Roux
2018-06-03 08:34:32 +00:00
parent c9c60234ad
commit bac7aeb9ef
@@ -327,13 +327,11 @@ public class LoginWorker {
* JSP should generate its own content. This allows an event to override the default content.
*/
public static String login(HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession();
HttpSession session = request.getSession();
// Prevent session fixation by making Tomcat generate a new jsessionId (ultimately put in cookie).
if (!session.isNew()) { // Only do when really signing in.
session.invalidate(); // If the client has disabled the use of cookies, then a session will be new on each request, not a good choice on client side!
session = request.getSession(true);
UtilHttp.setInitialRequestInfo(request); // We need to put that in place again
request.changeSessionId();
}
Delegator delegator = (Delegator) request.getAttribute("delegator");