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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user