diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-06-14 19:39:07 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-06-19 07:46:43 +0200 |
commit | 82959ca93e229e1f16e1843cd4a2f7523b8ac0bf (patch) | |
tree | 7feac2d142968d902e9a887e8b96a75bd5281fdf /lib | |
parent | 970dea926422a9d433a53b6932b792723dca3dfd (diff) | |
download | nextcloud-server-82959ca93e229e1f16e1843cd4a2f7523b8ac0bf.tar.gz nextcloud-server-82959ca93e229e1f16e1843cd4a2f7523b8ac0bf.zip |
Comments
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
5 files changed, 20 insertions, 6 deletions
diff --git a/lib/private/Authentication/Token/DefaultTokenProvider.php b/lib/private/Authentication/Token/DefaultTokenProvider.php index 078ab4ed8f2..8c2d8c33a97 100644 --- a/lib/private/Authentication/Token/DefaultTokenProvider.php +++ b/lib/private/Authentication/Token/DefaultTokenProvider.php @@ -35,7 +35,6 @@ use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\ILogger; -use OCP\IUser; use OCP\Security\ICrypto; class DefaultTokenProvider implements IProvider { @@ -299,7 +298,7 @@ class DefaultTokenProvider implements IProvider { * @param string $token * @return string */ - private function hashToken(string $token) { + private function hashToken(string $token): string { $secret = $this->config->getSystemValue('secret'); return hash('sha512', $token . $secret); } diff --git a/lib/private/Authentication/Token/Manager.php b/lib/private/Authentication/Token/Manager.php index 8dd41ce1096..254a1598943 100644 --- a/lib/private/Authentication/Token/Manager.php +++ b/lib/private/Authentication/Token/Manager.php @@ -25,7 +25,6 @@ namespace OC\Authentication\Token; use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Exceptions\PasswordlessTokenException; -use OCP\IUser; class Manager implements IProvider { @@ -92,6 +91,10 @@ class Manager implements IProvider { $provider->updateTokenActivity($token); } + /** + * @param string $uid + * @return IToken[] + */ public function getTokenByUser(string $uid): array { $old = $this->defaultTokenProvider->getTokenByUser($uid); $new = $this->publicKeyTokenProvider->getTokenByUser($uid); @@ -185,6 +188,13 @@ class Manager implements IProvider { $this->publicKeyTokenProvider->invalidateOldTokens(); } + /** + * @param IToken $token + * @param string $oldTokenId + * @param string $newTokenId + * @return IToken + * @throws InvalidTokenException + */ public function rotate(IToken $token, string $oldTokenId, string $newTokenId): IToken { if ($token instanceof DefaultToken) { try { @@ -203,6 +213,11 @@ class Manager implements IProvider { throw new InvalidTokenException(); } + /** + * @param IToken $token + * @return IProvider + * @throws InvalidTokenException + */ private function getProvider(IToken $token): IProvider { if ($token instanceof DefaultToken) { return $this->defaultTokenProvider; diff --git a/lib/private/Authentication/Token/PublicKeyToken.php b/lib/private/Authentication/Token/PublicKeyToken.php index 9d01fc9ecca..0e793ce8c7c 100644 --- a/lib/private/Authentication/Token/PublicKeyToken.php +++ b/lib/private/Authentication/Token/PublicKeyToken.php @@ -1,4 +1,5 @@ <?php +/** @noinspection ALL */ declare(strict_types=1); /** * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl> @@ -180,7 +181,7 @@ class PublicKeyToken extends Entity implements IToken { } public function setScope($scope) { - if (\is_array($scope)) { + if (is_array($scope)) { parent::setScope(json_encode($scope)); } else { parent::setScope((string)$scope); diff --git a/lib/private/Authentication/Token/PublicKeyTokenMapper.php b/lib/private/Authentication/Token/PublicKeyTokenMapper.php index 129b2a272bb..5e5c69dbc46 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenMapper.php +++ b/lib/private/Authentication/Token/PublicKeyTokenMapper.php @@ -115,7 +115,7 @@ class PublicKeyTokenMapper extends QBMapper { * where a high number of (session) tokens is generated * * @param string $uid - * @return DefaultToken[] + * @return PublicKeyToken[] */ public function getTokenByUser(string $uid): array { /* @var $qb IQueryBuilder */ diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index b7e0d1da332..f6a6fc3455f 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -29,7 +29,6 @@ use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\ILogger; -use OCP\IUser; use OCP\Security\ICrypto; class PublicKeyTokenProvider implements IProvider { |