diff options
| author | Loic GUEGAN <loic@Manzerbredes.home> | 2016-04-16 19:10:27 +0200 |
|---|---|---|
| committer | Loic GUEGAN <loic@Manzerbredes.home> | 2016-04-16 19:10:27 +0200 |
| commit | a3ff4d243e2ac37d4516ae56ff86985eadc00eb8 (patch) | |
| tree | 32e71c42855cc46d95d9c6b74ad2c145eb9ec7eb /server/vendor/php-opencloud/common/src/Common/Auth | |
| parent | 396c90f921c30de2d15d2ce52d5d1beabf8eb52d (diff) | |
| parent | 31d2d0c158ad4daa3dde7a905f3c2e312c194f2e (diff) | |
Test
Diffstat (limited to 'server/vendor/php-opencloud/common/src/Common/Auth')
4 files changed, 0 insertions, 124 deletions
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 100755 index 61a07c9..0000000 --- a/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php declare(strict_types=1); - -namespace OpenCloud\Common\Auth; - -use function GuzzleHttp\Psr7\modify_request; -use Psr\Http\Message\RequestInterface; - -/** - * This class is responsible for three tasks: - * - * 1. performing the initial authentication for OpenCloud services - * 2. populating the ``X-Auth-Token`` header for every HTTP request - * 3. checking the token expiry before each request, and re-authenticating if necessary - */ -class AuthHandler -{ - /** @var callable */ - private $nextHandler; - - /** @var callable */ - private $tokenGenerator; - - /** @var Token */ - private $token; - - /** - * @param callable $nextHandler - * @param callable $tokenGenerator - */ - public function __construct(callable $nextHandler, callable $tokenGenerator, Token $token = null) - { - $this->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'; - } -} diff --git a/server/vendor/php-opencloud/common/src/Common/Auth/Catalog.php b/server/vendor/php-opencloud/common/src/Common/Auth/Catalog.php deleted file mode 100755 index 22ebc09..0000000 --- a/server/vendor/php-opencloud/common/src/Common/Auth/Catalog.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php declare(strict_types=1); - -namespace OpenCloud\Common\Auth; - -interface Catalog -{ - /** - * Attempts to retrieve the base URL for a service from the catalog according to the arguments provided. - * - * @param string $name The name of the service as it appears in the catalog - * @param string $type The type of the service as it appears in the catalog - * @param string $region The region of the service as it appears in the catalog - * @param string $urlType The URL type of the service as it appears in the catalog - * - * @throws \RuntimeException If no endpoint is matched - * - * @returns string - */ - public function getServiceUrl(string $name, string $type, string $region, string $urlType): string; -} diff --git a/server/vendor/php-opencloud/common/src/Common/Auth/IdentityService.php b/server/vendor/php-opencloud/common/src/Common/Auth/IdentityService.php deleted file mode 100755 index 1f1d91f..0000000 --- a/server/vendor/php-opencloud/common/src/Common/Auth/IdentityService.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php declare(strict_types=1); - -namespace OpenCloud\Common\Auth; - -interface IdentityService -{ - /** - * Authenticates and retrieves back a token and catalog. - * - * @return array The FIRST key is {@see Token} instance, the SECOND key is a {@see Catalog} instance - */ - public function authenticate(array $options): array; -} diff --git a/server/vendor/php-opencloud/common/src/Common/Auth/Token.php b/server/vendor/php-opencloud/common/src/Common/Auth/Token.php deleted file mode 100755 index 642ea46..0000000 --- a/server/vendor/php-opencloud/common/src/Common/Auth/Token.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php declare(strict_types=1); - -namespace OpenCloud\Common\Auth; - -interface Token -{ - public function getId(): string; - - /** - * Indicates whether the token has expired or not. - * - * @return bool TRUE if the token has expired, FALSE if it is still valid - */ - public function hasExpired(): bool; -} |
