From d696e3547b1cde2c19c47efc2c1c81cd39ad75d2 Mon Sep 17 00:00:00 2001 From: Hans Bakker Date: Mon, 10 Jan 2011 08:26:04 +0000 Subject: [PATCH] When a load balancer is in front of the ofbiz system and takes care of the ssl certificate, ofbiz is now reading the Header[X-Forwarded-Proto] parameters to check if the request was secure or not. It still works the old way if these request parameters are not present git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1057115 13f79535-47bb-0310-9956-ffa450edef68 --- .../webapp/src/org/ofbiz/webapp/control/RequestHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java b/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java index ee3564d8dc..707e41e4df 100644 --- a/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java +++ b/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java @@ -183,7 +183,9 @@ public class RequestHandler { } boolean forceHttpSession = "true".equals(context.getInitParameter("forceHttpSession")); // Check if we SHOULD be secure and are not. - if (!request.isSecure() && requestMap.securityHttps) { + String forwardedProto = request.getHeader("X-Forwarded-Proto"); + boolean isForwardedSecure = UtilValidate.isNotEmpty(forwardedProto) && "HTTPS".equals(forwardedProto.toUpperCase()); + if ((!request.isSecure() && !isForwardedSecure) && requestMap.securityHttps) { // If the request method was POST then return an error to avoid problems with XSRF where the request may have come from another machine/program and had the same session ID but was not encrypted as it should have been (we used to let it pass to not lose data since it was too late to protect that data anyway) if (request.getMethod().equalsIgnoreCase("POST")) { // we can't redirect with the body parameters, and for better security from XSRF, just return an error message