svn commit: r1784556 - in /ofbiz/branches: release14.12/framework/webapp/config/ release14.12/framework/webapp/src/org/ofbiz/webapp/website/ release15.12/framework/webapp/config/ release15.12/framework/webapp/src/org/ofbiz/webapp/website/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1784556 - in /ofbiz/branches: release14.12/framework/webapp/config/ release14.12/framework/webapp/src/org/ofbiz/webapp/website/ release15.12/framework/webapp/config/ release15.12/framework/webapp/src/org/ofbiz/webapp/website/

jleroux@apache.org
Author: jleroux
Date: Mon Feb 27 13:03:04 2017
New Revision: 1784556

URL: http://svn.apache.org/viewvc?rev=1784556&view=rev
Log:
"Partially backport fix from trunk framework for revision: 1784549  "
------------------------------------------------------------------------
r1784549 | jleroux | 2017-02-27 13:33:42 +0100 (lun. 27 fev. 2017) | 26 lignes

I kept getDefaultServerRootUrl() and simplified changes in url.properties


Fixed: "Login and logout process in demos shows a certificate issue"
(OFBIZ-9206)

Also fixes "16.11 ofbizUrl include host+port and break some reverse-proxy/docker
 setups"
(OFBIZ-9224)

It was an easy fix, I just imported
<SystemProperty systemPropertyId="port.https" systemResourceId="url"
systemPropertyValue=""/>
in trunk demo and all work perfectly.

I also tried to replace locally
port.https=8443
by
port.https=
in url.properties (w/o SystemProperty) and did not face any issue but with
portOffset. This is due to the WebSiteProperties class works and there is also
an easy fix: don't add twice the portOffset when it's build from the request,
and only then. Keep it as is when it's build from a WebSite GenericValue.
We then trust the user and don't rely on the request.

Thanks: Pierre Smits and Leonard Lin for reports
------------------------------------------------------------------------

Modified:
    ofbiz/branches/release14.12/framework/webapp/config/url.properties
    ofbiz/branches/release14.12/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java
    ofbiz/branches/release15.12/framework/webapp/config/url.properties
    ofbiz/branches/release15.12/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java

Modified: ofbiz/branches/release14.12/framework/webapp/config/url.properties
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/framework/webapp/config/url.properties?rev=1784556&r1=1784555&r2=1784556&view=diff
==============================================================================
--- ofbiz/branches/release14.12/framework/webapp/config/url.properties (original)
+++ ofbiz/branches/release14.12/framework/webapp/config/url.properties Mon Feb 27 13:03:04 2017
@@ -22,7 +22,8 @@
 
 # HTTPS Port (Secure port)
 port.https.enabled=Y
-port.https=8443
+# empty by default see OFBIZ-9206
+port.https=
 force.https.host=
 
 # HTTP Port (Not Secure port)

Modified: ofbiz/branches/release14.12/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java?rev=1784556&r1=1784555&r2=1784556&view=diff
==============================================================================
--- ofbiz/branches/release14.12/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java (original)
+++ ofbiz/branches/release14.12/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java Mon Feb 27 13:03:04 2017
@@ -57,6 +57,7 @@ public final class WebSiteProperties {
         Assert.notNull("request", request);
         WebSiteProperties webSiteProps = (WebSiteProperties) request.getAttribute("_WEBSITE_PROPS_");
         if (webSiteProps == null) {
+            Boolean dontAdd = false;
             Delegator delegator = (Delegator) request.getAttribute("delegator");
             WebSiteProperties defaults = new WebSiteProperties(delegator);
             String httpPort = defaults.getHttpPort();
@@ -95,6 +96,7 @@ public final class WebSiteProperties {
             }
             if (httpsPort.isEmpty() && request.isSecure()) {
                 httpsPort = String.valueOf(request.getServerPort());
+                dontAdd = true; // We take the port from the request, don't add the portOffset
             }
             if (httpsHost.isEmpty()) {
                 httpsHost = request.getServerName();
@@ -104,9 +106,12 @@ public final class WebSiteProperties {
                 Integer httpPortValue = Integer.valueOf(httpPort);
                 httpPortValue += Start.getInstance().getConfig().portOffset;
                 httpPort = httpPortValue.toString();
-                Integer httpsPortValue = Integer.valueOf(httpsPort);
-                httpsPortValue += Start.getInstance().getConfig().portOffset;
-                httpsPort = httpsPortValue.toString();
+                if (!dontAdd) {
+                    Integer httpsPortValue = Integer.valueOf(httpsPort);
+                    if (! httpsPort.isEmpty())
+                    httpsPortValue += Start.getInstance().getConfig().portOffset;
+                    httpsPort = httpsPortValue.toString();
+                }
             }                
             
             webSiteProps = new WebSiteProperties(httpPort, httpHost, httpsPort, httpsHost, enableHttps);
@@ -138,7 +143,7 @@ public final class WebSiteProperties {
             httpPortValue += Start.getInstance().getConfig().portOffset;
             httpPort = httpPortValue.toString();
             Integer httpsPortValue = Integer.valueOf(httpsPort);
-            httpsPortValue += Start.getInstance().getConfig().portOffset;
+            httpsPortValue += Start.getInstance().getConfig().portOffset; // Here unlike above we trust the user and don't rely on the request, no dontAdd.
             httpsPort = httpsPortValue.toString();
         }                
         

Modified: ofbiz/branches/release15.12/framework/webapp/config/url.properties
URL: http://svn.apache.org/viewvc/ofbiz/branches/release15.12/framework/webapp/config/url.properties?rev=1784556&r1=1784555&r2=1784556&view=diff
==============================================================================
--- ofbiz/branches/release15.12/framework/webapp/config/url.properties (original)
+++ ofbiz/branches/release15.12/framework/webapp/config/url.properties Mon Feb 27 13:03:04 2017
@@ -22,7 +22,8 @@
 
 # HTTPS Port (Secure port)
 port.https.enabled=Y
-port.https=8443
+# empty by default see OFBIZ-9206
+port.https=
 force.https.host=
 
 # HTTP Port (Not Secure port)

Modified: ofbiz/branches/release15.12/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release15.12/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java?rev=1784556&r1=1784555&r2=1784556&view=diff
==============================================================================
--- ofbiz/branches/release15.12/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java (original)
+++ ofbiz/branches/release15.12/framework/webapp/src/org/ofbiz/webapp/website/WebSiteProperties.java Mon Feb 27 13:03:04 2017
@@ -57,6 +57,7 @@ public final class WebSiteProperties {
         Assert.notNull("request", request);
         WebSiteProperties webSiteProps = (WebSiteProperties) request.getAttribute("_WEBSITE_PROPS_");
         if (webSiteProps == null) {
+            Boolean dontAdd = false;
             Delegator delegator = (Delegator) request.getAttribute("delegator");
             WebSiteProperties defaults = new WebSiteProperties(delegator);
             String httpPort = defaults.getHttpPort();
@@ -95,6 +96,7 @@ public final class WebSiteProperties {
             }
             if (httpsPort.isEmpty() && request.isSecure()) {
                 httpsPort = String.valueOf(request.getServerPort());
+                dontAdd = true; // We take the port from the request, don't add the portOffset
             }
             if (httpsHost.isEmpty()) {
                 httpsHost = request.getServerName();
@@ -104,9 +106,12 @@ public final class WebSiteProperties {
                 Integer httpPortValue = Integer.valueOf(httpPort);
                 httpPortValue += Start.getInstance().getConfig().portOffset;
                 httpPort = httpPortValue.toString();
-                Integer httpsPortValue = Integer.valueOf(httpsPort);
-                httpsPortValue += Start.getInstance().getConfig().portOffset;
-                httpsPort = httpsPortValue.toString();
+                if (!dontAdd) {
+                    Integer httpsPortValue = Integer.valueOf(httpsPort);
+                    if (! httpsPort.isEmpty())
+                    httpsPortValue += Start.getInstance().getConfig().portOffset;
+                    httpsPort = httpsPortValue.toString();
+                }
             }                
             
             webSiteProps = new WebSiteProperties(httpPort, httpHost, httpsPort, httpsHost, enableHttps);
@@ -138,7 +143,7 @@ public final class WebSiteProperties {
             httpPortValue += Start.getInstance().getConfig().portOffset;
             httpPort = httpPortValue.toString();
             Integer httpsPortValue = Integer.valueOf(httpsPort);
-            httpsPortValue += Start.getInstance().getConfig().portOffset;
+            httpsPortValue += Start.getInstance().getConfig().portOffset; // Here unlike above we trust the user and don't rely on the request, no dontAdd.
             httpsPort = httpsPortValue.toString();
         }