diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-05-29 12:18:10 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-06-18 22:11:55 +0200 |
commit | 4bbc21cb216c51ab22f31089c9c09a3dec8980dc (patch) | |
tree | 5f2322a324a87bea1f8586e0789d602f99773c94 /lib/private/Authentication/Token | |
parent | 4c0d7104792cb89b8bc013c08b9c9fcb63dcf0da (diff) | |
download | nextcloud-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.php | 14 |
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 { |