[Mapbender-commits] r9837 - trunk/mapbender/http_auth/http

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jan 2 06:45:58 PST 2018


Author: armin11
Date: 2018-01-02 06:45:58 -0800 (Tue, 02 Jan 2018)
New Revision: 9837

Modified:
   trunk/mapbender/http_auth/http/index.php
Log:
allow forceBasicAuth=true get parameter also for secured wms interfaces

Modified: trunk/mapbender/http_auth/http/index.php
===================================================================
--- trunk/mapbender/http_auth/http/index.php	2018-01-02 14:14:46 UTC (rev 9836)
+++ trunk/mapbender/http_auth/http/index.php	2018-01-02 14:45:58 UTC (rev 9837)
@@ -346,12 +346,14 @@
             			$requestFull .= $request . '&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS';
         		}
 			if ($authType == 'basic') {
-				$requestFull .= "&forceBasicAuth=true";
+				$extraParameter = "&forceBasicAuth=true";
+			} else {
+				$extraParameter = false;
 			}
         		if (isset($auth)) {
-            			getCapabilities($request, $requestFull, $auth);
+            			getCapabilities($request, $requestFull, $extraParameter, $auth);
         		} else {
-            			getCapabilities($request, $requestFull);
+            			getCapabilities($request, $requestFull, $extraParameter);
         		}
 		break;
 	
@@ -966,13 +968,13 @@
     return $id;
 }
 
-function getCapabilities($request, $requestFull)
+function getCapabilities($request, $requestFull, $extraParameter)
 {
     global $arrayOnlineresources;
     global $layerId;
     header("Content-Type: application/xml");
-    if (func_num_args() == 3) { //new for HTTP Authentication
-        $auth = func_get_arg(2);
+    if (func_num_args() == 4) { //new for HTTP Authentication
+        $auth = func_get_arg(3);
 	$d = new connector($requestFull, $auth);
     } else {
 	$d = new connector($requestFull);
@@ -1015,13 +1017,13 @@
         $href = $capFromFascadeXmlObject->xpath($xpath);
         $e = new mb_notice("old href: " . $href[0]);
         $e = new mb_notice("href replaced: " . replaceOwsUrls($href[0], $layerId));
-        $href[0][0] = replaceOwsUrls($href[0], $layerId);
+        $href[0][0] = replaceOwsUrls($href[0], $layerId, $extraParameter);
     }
     echo $capFromFascadeXmlObject->asXML();
 }
 
-function replaceOwsUrls($owsUrl, $layerId)
-{
+function replaceOwsUrls($owsUrl, $layerId, $extraParameter)
+{	
     $new = "http_auth/" . $layerId . "?";
     $pattern = "#owsproxy/[a-z0-9]{32}\/[a-z0-9]{32}\?#m";
     $httpAuthUrl = preg_replace($pattern, $new, $owsUrl);
@@ -1043,6 +1045,9 @@
             $httpAuthUrl = preg_replace("#:80/#", ":443/", $httpAuthUrl);
         }
     }
+    if ($extraParameter !== false) {	
+	$httpAuthUrl .= $extraParameter;
+    }
     return $httpAuthUrl;
 }
 



More information about the Mapbender_commits mailing list