diff options
author | Christoph Wurst <christoph@owncloud.com> | 2016-05-31 10:48:14 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@owncloud.com> | 2016-05-31 17:07:49 +0200 |
commit | c58d8159d7bdee93a67a917e16b750fe99df9f99 (patch) | |
tree | 568acfd8c2f26bd675a151bb42130a626468633b /lib/private/Authentication/Token/DefaultTokenProvider.php | |
parent | 9a9c1b9439055fc6ad9f8372b354e4fc7ce3bc02 (diff) | |
download | nextcloud-server-c58d8159d7bdee93a67a917e16b750fe99df9f99.tar.gz nextcloud-server-c58d8159d7bdee93a67a917e16b750fe99df9f99.zip |
Create session tokens for apache auth users
Diffstat (limited to 'lib/private/Authentication/Token/DefaultTokenProvider.php')
-rw-r--r-- | lib/private/Authentication/Token/DefaultTokenProvider.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/private/Authentication/Token/DefaultTokenProvider.php b/lib/private/Authentication/Token/DefaultTokenProvider.php index dd6e264ed3d..84effc5f875 100644 --- a/lib/private/Authentication/Token/DefaultTokenProvider.php +++ b/lib/private/Authentication/Token/DefaultTokenProvider.php @@ -23,6 +23,7 @@ namespace OC\Authentication\Token; use Exception; use OC\Authentication\Exceptions\InvalidTokenException; +use OC\Authentication\Exceptions\PasswordlessTokenException; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; @@ -68,7 +69,7 @@ class DefaultTokenProvider implements IProvider { * @param string $token * @param string $uid * @param string $loginName - * @param string $password + * @param string|null $password * @param string $name * @param int $type token type * @return IToken @@ -77,7 +78,9 @@ class DefaultTokenProvider implements IProvider { $dbToken = new DefaultToken(); $dbToken->setUid($uid); $dbToken->setLoginName($loginName); - $dbToken->setPassword($this->encryptPassword($password, $token)); + if (!is_null($password)) { + $dbToken->setPassword($this->encryptPassword($password, $token)); + } $dbToken->setName($name); $dbToken->setToken($this->hashToken($token)); $dbToken->setType($type); @@ -136,10 +139,15 @@ class DefaultTokenProvider implements IProvider { * @param IToken $savedToken * @param string $tokenId session token * @throws InvalidTokenException + * @throws PasswordlessTokenException * @return string */ public function getPassword(IToken $savedToken, $tokenId) { - return $this->decryptPassword($savedToken->getPassword(), $tokenId); + $password = $savedToken->getPassword(); + if (is_null($password)) { + throw new PasswordlessTokenException(); + } + return $this->decryptPassword($password, $tokenId); } /** |