summaryrefslogtreecommitdiffstats
path: root/lib/private/Authentication/Token
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-05-29 12:18:10 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2018-06-18 22:11:55 +0200
commit4bbc21cb216c51ab22f31089c9c09a3dec8980dc (patch)
tree5f2322a324a87bea1f8586e0789d602f99773c94 /lib/private/Authentication/Token
parent4c0d7104792cb89b8bc013c08b9c9fcb63dcf0da (diff)
downloadnextcloud-server-4bbc21cb216c51ab22f31089c9c09a3dec8980dc.tar.gz
nextcloud-server-4bbc21cb216c51ab22f31089c9c09a3dec8980dc.zip
SetPassword on PublicKeyTokens
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Authentication/Token')
-rw-r--r--lib/private/Authentication/Token/PublicKeyTokenProvider.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
index 926e3c678d4..5c97877e730 100644
--- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php
+++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
@@ -215,9 +215,19 @@ class PublicKeyTokenProvider implements IProvider {
}
public function setPassword(IToken $token, string $tokenId, string $password) {
- // Kill all temp tokens except the current token
+ if (!($token instanceof PublicKeyToken)) {
+ throw new InvalidTokenException();
+ }
+
+ // Update the password for all tokens
+ $tokens = $this->mapper->getTokenByUser($token->getUID());
+ foreach ($tokens as $t) {
+ $publicKey = $token->getPublicKey();
+ $t->setPassword($this->encryptPassword($password, $publicKey));
+ $this->updateToken($t);
+ }
- // Update pass for all permanent tokens by rencrypting
+ //TODO: should we also do this for temp tokens?
}
public function rotate(IToken $token, string $oldTokenId, string $newTokenId): IToken {