summaryrefslogtreecommitdiffstats
path: root/lib/private/Authentication
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-10-08 11:01:53 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2019-10-09 10:10:37 +0200
commit5122629bb0ff59a1688029d65e919ce31db8eced (patch)
tree367a89874edd75bc63c89fc0812a49ab5a9a64bc /lib/private/Authentication
parentf663154adfb81848295bbb6ddcc7ac9582c3a475 (diff)
downloadnextcloud-server-5122629bb0ff59a1688029d65e919ce31db8eced.tar.gz
nextcloud-server-5122629bb0ff59a1688029d65e919ce31db8eced.zip
Make renewSessionToken return the new token
Avoids directly getting the token again. We just inserted it so it and have all the info. So that query is just a waste. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Authentication')
-rw-r--r--lib/private/Authentication/Token/DefaultTokenProvider.php5
-rw-r--r--lib/private/Authentication/Token/IProvider.php3
-rw-r--r--lib/private/Authentication/Token/Manager.php7
-rw-r--r--lib/private/Authentication/Token/PublicKeyTokenProvider.php6
4 files changed, 14 insertions, 7 deletions
diff --git a/lib/private/Authentication/Token/DefaultTokenProvider.php b/lib/private/Authentication/Token/DefaultTokenProvider.php
index 98609a3f14b..6bd7c2c6dc8 100644
--- a/lib/private/Authentication/Token/DefaultTokenProvider.php
+++ b/lib/private/Authentication/Token/DefaultTokenProvider.php
@@ -196,8 +196,9 @@ class DefaultTokenProvider implements IProvider {
* @param string $oldSessionId
* @param string $sessionId
* @throws InvalidTokenException
+ * @return IToken
*/
- public function renewSessionToken(string $oldSessionId, string $sessionId) {
+ public function renewSessionToken(string $oldSessionId, string $sessionId): IToken {
$token = $this->getToken($oldSessionId);
$newToken = new DefaultToken();
@@ -214,6 +215,8 @@ class DefaultTokenProvider implements IProvider {
$newToken->setLastActivity($this->time->getTime());
$this->mapper->insert($newToken);
$this->mapper->delete($token);
+
+ return $newToken;
}
/**
diff --git a/lib/private/Authentication/Token/IProvider.php b/lib/private/Authentication/Token/IProvider.php
index 860b93e16c2..ba8df30eb8d 100644
--- a/lib/private/Authentication/Token/IProvider.php
+++ b/lib/private/Authentication/Token/IProvider.php
@@ -84,8 +84,9 @@ interface IProvider {
* @param string $sessionId
* @throws InvalidTokenException
* @throws \RuntimeException when OpenSSL reports a problem
+ * @return IToken The new token
*/
- public function renewSessionToken(string $oldSessionId, string $sessionId);
+ public function renewSessionToken(string $oldSessionId, string $sessionId): IToken;
/**
* Invalidate (delete) the given session token
diff --git a/lib/private/Authentication/Token/Manager.php b/lib/private/Authentication/Token/Manager.php
index 76c0dfb8695..ea94efce54d 100644
--- a/lib/private/Authentication/Token/Manager.php
+++ b/lib/private/Authentication/Token/Manager.php
@@ -158,14 +158,15 @@ class Manager implements IProvider {
* @param string $oldSessionId
* @param string $sessionId
* @throws InvalidTokenException
+ * @return IToken
*/
- public function renewSessionToken(string $oldSessionId, string $sessionId) {
+ public function renewSessionToken(string $oldSessionId, string $sessionId): IToken {
try {
- $this->publicKeyTokenProvider->renewSessionToken($oldSessionId, $sessionId);
+ return $this->publicKeyTokenProvider->renewSessionToken($oldSessionId, $sessionId);
} catch (ExpiredTokenException $e) {
throw $e;
} catch (InvalidTokenException $e) {
- $this->defaultTokenProvider->renewSessionToken($oldSessionId, $sessionId);
+ return $this->defaultTokenProvider->renewSessionToken($oldSessionId, $sessionId);
}
}
diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
index 4ef9afb3442..624e2c0cadc 100644
--- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php
+++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
@@ -129,7 +129,7 @@ class PublicKeyTokenProvider implements IProvider {
return $token;
}
- public function renewSessionToken(string $oldSessionId, string $sessionId) {
+ public function renewSessionToken(string $oldSessionId, string $sessionId): IToken {
$this->cache->clear();
$token = $this->getToken($oldSessionId);
@@ -144,7 +144,7 @@ class PublicKeyTokenProvider implements IProvider {
$password = $this->decryptPassword($token->getPassword(), $privateKey);
}
- $this->generateToken(
+ $newToken = $this->generateToken(
$sessionId,
$token->getUID(),
$token->getLoginName(),
@@ -155,6 +155,8 @@ class PublicKeyTokenProvider implements IProvider {
);
$this->mapper->delete($token);
+
+ return $newToken;
}
public function invalidateToken(string $token) {