diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-07-05 11:37:14 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-07-05 11:37:14 +0200 |
commit | 1c23c029af1ef83935badb8b63cb4dffac59b1e4 (patch) | |
tree | 647370899a380f3e77906875428c289f7b4c936e /tests | |
parent | cdf3b60555eb559ea5f9b141903054afbc273062 (diff) | |
download | nextcloud-server-1c23c029af1ef83935badb8b63cb4dffac59b1e4.tar.gz nextcloud-server-1c23c029af1ef83935badb8b63cb4dffac59b1e4.zip |
Handler large passwords
For passwords bigger than 250 characters, use a bigger key since the
performance impact is minor (around one second to encrypt the password).
For passwords bigger than 470 characters, give up earlier and throw
exeception recommanding admin to either enable the previously enabled
configuration or use smaller passwords.
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php index 8e6f699f0b8..db61244db5b 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php @@ -121,6 +121,25 @@ class PublicKeyTokenProviderTest extends TestCase { $this->tokenProvider->getPassword($actual, $token); } + public function testGenerateTokenLongPassword() { + $token = 'token'; + $uid = 'user'; + $user = 'User'; + $password = ''; + for ($i = 0; $i < 500; $i++) { + $password .= 'e'; + } + $name = 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12'; + $type = IToken::PERMANENT_TOKEN; + $this->config->method('getSystemValueBool') + ->willReturnMap([ + ['auth.storeCryptedPassword', true, true], + ]); + $this->expectException(\RuntimeException::class); + + $actual = $this->tokenProvider->generateToken($token, $uid, $user, $password, $name, $type, IToken::DO_NOT_REMEMBER); + } + public function testGenerateTokenInvalidName() { $token = 'token'; $uid = 'user'; |