From 580c3f4ffe9608d2beb56d418c68b3b112420e76 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Nov 2019 12:49:51 +0000 Subject: another bulk of composer updates (cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce) --- vendor/sabre/dav/lib/DAV/Auth/Plugin.php | 91 ++++++++++++++------------------ 1 file changed, 39 insertions(+), 52 deletions(-) (limited to 'vendor/sabre/dav/lib/DAV/Auth/Plugin.php') diff --git a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php index bbb5d180d..9be90283f 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php @@ -1,5 +1,7 @@ addBackend($authBackend); } - } /** * Adds an authentication backend to the plugin. * * @param Backend\BackendInterface $authBackend - * @return void */ - function addBackend(Backend\BackendInterface $authBackend) { - + public function addBackend(Backend\BackendInterface $authBackend) + { $this->backends[] = $authBackend; - } /** - * Initializes the plugin. This function is automatically called by the server + * Initializes the plugin. This function is automatically called by the server. * * @param Server $server - * @return void */ - function initialize(Server $server) { - - $server->on('beforeMethod', [$this, 'beforeMethod'], 10); - + public function initialize(Server $server) + { + $server->on('beforeMethod:*', [$this, 'beforeMethod'], 10); } /** @@ -96,10 +93,9 @@ class Plugin extends ServerPlugin { * * @return string */ - function getPluginName() { - + public function getPluginName() + { return 'auth'; - } /** @@ -114,23 +110,22 @@ class Plugin extends ServerPlugin { * * @return string|null */ - function getCurrentPrincipal() { - + public function getCurrentPrincipal() + { return $this->currentPrincipal; - } /** - * This method is called before any HTTP method and forces users to be authenticated + * This method is called before any HTTP method and forces users to be authenticated. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return bool */ - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { if ($this->currentPrincipal) { - // We already have authentication information. This means that the // event has already fired earlier, and is now likely fired for a // sub-request. @@ -144,7 +139,6 @@ class Plugin extends ServerPlugin { // // See issue #580 for more information about that. return; - } $authResult = $this->check($request, $response); @@ -153,11 +147,10 @@ class Plugin extends ServerPlugin { // Auth was successful $this->currentPrincipal = $authResult[1]; $this->loginFailedReasons = null; + return; } - - // If we got here, it means that no authentication backend was // successful in authenticating the user. $this->currentPrincipal = null; @@ -167,7 +160,6 @@ class Plugin extends ServerPlugin { $this->challenge($request, $response); throw new NotAuthenticated(implode(', ', $authResult[1])); } - } /** @@ -184,24 +176,24 @@ class Plugin extends ServerPlugin { * unsuccessful. For every auth backend there will be one reason, so usually * there's just one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { if (!$this->backends) { throw new \Sabre\DAV\Exception('No authentication backends were configured on this server.'); } $reasons = []; foreach ($this->backends as $backend) { - $result = $backend->check( $request, $response ); - if (!is_array($result) || count($result) !== 2 || !is_bool($result[0]) || !is_string($result[1])) { + if (!is_array($result) || 2 !== count($result) || !is_bool($result[0]) || !is_string($result[1])) { throw new \Sabre\DAV\Exception('The authentication backend did not return a correct value from the check() method.'); } @@ -211,11 +203,9 @@ class Plugin extends ServerPlugin { return [true, $result[1]]; } $reasons[] = $result[1]; - } return [false, $reasons]; - } /** @@ -225,16 +215,16 @@ class Plugin extends ServerPlugin { * WWW-Authorization header, indicating to the client that it should * authenticate. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { foreach ($this->backends as $backend) { $backend->challenge($request, $response); } - } /** @@ -255,10 +245,9 @@ class Plugin extends ServerPlugin { * * @return string[]|null */ - function getLoginFailedReasons() { - + public function getLoginFailedReasons() + { return $this->loginFailedReasons; - } /** @@ -272,14 +261,12 @@ class Plugin extends ServerPlugin { * * @return array */ - function getPluginInfo() { - + public function getPluginInfo() + { return [ - 'name' => $this->getPluginName(), + 'name' => $this->getPluginName(), 'description' => 'Generic authentication plugin', - 'link' => 'http://sabre.io/dav/authentication/', + 'link' => 'http://sabre.io/dav/authentication/', ]; - } - } -- cgit v1.2.3