From 24bb5fefbdf93ce0969b7f56cc46c459ebb82a95 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Thu, 14 Apr 2016 16:24:44 +0200 Subject: Mise a jour et nettoyage depot --- .../common/src/Common/Auth/AuthHandler.php | 76 ---------------------- 1 file changed, 76 deletions(-) delete mode 100644 server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php (limited to 'server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php') diff --git a/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php b/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php deleted file mode 100644 index 61a07c9..0000000 --- a/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php +++ /dev/null @@ -1,76 +0,0 @@ -nextHandler = $nextHandler; - $this->tokenGenerator = $tokenGenerator; - $this->token = $token; - } - - /** - * This method is invoked before every HTTP request is sent to the API. When this happens, it - * checks to see whether a token is set and valid, and then sets the ``X-Auth-Token`` header - * for the HTTP request before letting it continue on its merry way. - * - * @param RequestInterface $request - * @param array $options - * - * @return mixed|void - */ - public function __invoke(RequestInterface $request, array $options) - { - $fn = $this->nextHandler; - - if ($this->shouldIgnore($request)) { - return $fn($request, $options); - } - - if (!$this->token || $this->token->hasExpired()) { - $this->token = call_user_func($this->tokenGenerator); - } - - $modify = ['set_headers' => ['X-Auth-Token' => $this->token->getId()]]; - - return $fn(modify_request($request, $modify), $options); - } - - /** - * Internal method which prevents infinite recursion. For certain requests, like the initial - * auth call itself, we do NOT want to send a token. - * - * @param RequestInterface $request - * - * @return bool - */ - private function shouldIgnore(RequestInterface $request): bool - { - return strpos((string) $request->getUri(), 'tokens') !== false && $request->getMethod() == 'POST'; - } -} -- cgit v1.2.3