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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jun 27 01:25:19 PDT 2017


Author: armin11
Date: 2017-06-27 01:25:18 -0700 (Tue, 27 Jun 2017)
New Revision: 9750

Modified:
   trunk/mapbender/http_auth/http/index.php
Log:
Possibility to give access to proxied getcapabilities answer without aothorization if featuretypes are all freely available - wfs_confs accessible for PUBLIC_USER

Modified: trunk/mapbender/http_auth/http/index.php
===================================================================
--- trunk/mapbender/http_auth/http/index.php	2017-06-26 11:39:02 UTC (rev 9749)
+++ trunk/mapbender/http_auth/http/index.php	2017-06-27 08:25:18 UTC (rev 9750)
@@ -125,9 +125,31 @@
 }
 //$e = new mb_exception("http_auth/index.php: ".$typeNameParameter.": ".(string)$reqParams[$typeNameParameter]);
 if ($wfsId !== false) {
-	if ($reqParams[$typeNameParameter] !== false) {
+	if (isset($reqParams[$typeNameParameter]) && $reqParams[$typeNameParameter] !== false && $reqParams[$typeNameParameter] !== '') {
 		$user = new user(PUBLIC_USER);
 		$anonymousAccess = $user->areFeaturetypesAccessible($reqParams[$typeNameParameter], $wfsId);
+	} else {
+		//typename not requested - so check accessability for each featuretype of the service - only if all are accessable, give anonymous access to getcapabilities and other requests, that don't need a typename(s) parameter
+		$sql = "SELECT featuretype_name FROM wfs_featuretype WHERE fkey_wfs_id = $1";
+        	$v = array($wfsId);
+        	$t = array("i");
+    		$res = db_prep_query($sql, $v, $t);
+    		if (!($row = db_fetch_all($res))) {
+        		return false;
+    		} else {
+			if (count($row) == 1 && $row[0]['featuretype_name'] == null) {
+				return false;
+			} else {
+				$allTypenames = "";
+				foreach ($row as $singleRow) {
+					$allTypenames .= $singleRow['featuretype_name'] . ",";
+				}
+				$allTypenames = rtrim($allTypenames, ',');
+			}
+			//$e = new mb_exception("http_auth/index.php: allTypenames for wfs ".$wfsId." : ".$allTypenames);
+			$user = new user(PUBLIC_USER);
+			$anonymousAccess = $user->areFeaturetypesAccessible($allTypenames, $wfsId);
+		}
 	}
 }
 
@@ -363,7 +385,7 @@
         	$arrayOnlineresources = checkWfsStoredQueryPermission($owsproxyString, $storedQueryId, $userId);
 	} else {
 		$arrayFeatures = array($reqParams[$typeNameParameter]);
-		$e = new mb_exception("".$typeNameParameter.": ".$reqParams[$typeNameParameter]);
+		//$e = new mb_exception("".$typeNameParameter.": ".$reqParams[$typeNameParameter]);
         	$arrayOnlineresources = checkWfsPermission($owsproxyString, $arrayFeatures, $userId);
 	}
         $query->setOnlineResource($arrayOnlineresources['wfs_getfeature']);



More information about the Mapbender_commits mailing list