From 6e922035e1cb7b6f99f32c60dcc5eca8c3d52e7c Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 9 Aug 2012 17:32:45 +0200 Subject: add SabreDav 1.6.4 --- 3rdparty/Sabre/DAV/Auth/Plugin.php | 111 +++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100755 3rdparty/Sabre/DAV/Auth/Plugin.php (limited to '3rdparty/Sabre/DAV/Auth/Plugin.php') diff --git a/3rdparty/Sabre/DAV/Auth/Plugin.php b/3rdparty/Sabre/DAV/Auth/Plugin.php new file mode 100755 index 00000000000..55a4e391674 --- /dev/null +++ b/3rdparty/Sabre/DAV/Auth/Plugin.php @@ -0,0 +1,111 @@ +authBackend = $authBackend; + $this->realm = $realm; + + } + + /** + * Initializes the plugin. This function is automatically called by the server + * + * @param Sabre_DAV_Server $server + * @return void + */ + public function initialize(Sabre_DAV_Server $server) { + + $this->server = $server; + $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'),10); + + } + + /** + * Returns a plugin name. + * + * Using this name other plugins will be able to access other plugins + * using Sabre_DAV_Server::getPlugin + * + * @return string + */ + public function getPluginName() { + + return 'auth'; + + } + + /** + * Returns the current users' principal uri. + * + * If nobody is logged in, this will return null. + * + * @return string|null + */ + public function getCurrentUser() { + + $userInfo = $this->authBackend->getCurrentUser(); + if (!$userInfo) return null; + + return $userInfo; + + } + + /** + * This method is called before any HTTP method and forces users to be authenticated + * + * @param string $method + * @param string $uri + * @throws Sabre_DAV_Exception_NotAuthenticated + * @return bool + */ + public function beforeMethod($method, $uri) { + + $this->authBackend->authenticate($this->server,$this->realm); + + } + +} -- cgit v1.2.3