From bac7aeb9ef404bedfc97d92e073ab63f0a0724d4 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Sun, 3 Jun 2018 08:34:32 +0000 Subject: [PATCH] "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 --- .../java/org/apache/ofbiz/webapp/control/LoginWorker.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java index abe5ab33a4..46b46dde04 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java @@ -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");