[Fusionforge-commits] r11282 - in trunk/src: common/docman/include www/docman

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Mon Nov 1 13:11:28 CET 2010


Author: nerville
Date: 2010-11-01 13:11:28 +0100 (Mon, 01 Nov 2010)
New Revision: 11282

Modified:
   trunk/src/common/docman/include/webdav.php
   trunk/src/www/docman/view.php
Log:
basic authent for webdav

Modified: trunk/src/common/docman/include/webdav.php
===================================================================
--- trunk/src/common/docman/include/webdav.php	2010-11-01 11:27:31 UTC (rev 11281)
+++ trunk/src/common/docman/include/webdav.php	2010-11-01 12:11:28 UTC (rev 11282)
@@ -29,10 +29,30 @@
 
 class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
 
-    function check_auth($type,$user,$pass) {
-        return true;
-    }
+    function checkAuth($group_id,$user,$pass) {
+		$g =& group_get_object($group_id);
+		if (!$g || !is_object($g))
+			return false;
 
+		/* is this group using docman ? */
+		if (!$g->usesDocman())
+            return false;
+
+        if (!$g->useWebdav())
+            return false;
+
+		if ($g->isError())
+            return false;
+
+		if (!session_login_valid($user,$pass)) {
+			if (forge_check_perm ('docman',$group_id,'read')) {
+				return true;
+			}
+			return false;
+		}
+		return true;
+	}
+
     function HEAD(&$options) {
         return true;
     }

Modified: trunk/src/www/docman/view.php
===================================================================
--- trunk/src/www/docman/view.php	2010-11-01 11:27:31 UTC (rev 11281)
+++ trunk/src/www/docman/view.php	2010-11-01 12:11:28 UTC (rev 11282)
@@ -120,6 +120,14 @@
 	}
 } else if ( $docid == 'webdav' ) {
 	$_SERVER['SCRIPT_NAME'] = '';
+	/* we need the group id for check authentification. */
+	$_SERVER["AUTH_TYPE"] = $group_id;
+	if (!isset($_SERVER['PHP_AUTH_USER'])) {
+		header('WWW-Authenticate: Basic realm="Webdav Access" (For anonymous access : click enter)');
+		header('HTTP/1.0 401 Unauthorized');
+		echo _('Webdav Access Canceled by user');
+		die();
+	}
 	$server = new HTTP_WebDAV_Server_Docman;
 	$server->ServeRequest();
 } else {




More information about the Fusionforge-commits mailing list