diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-07-05 12:25:44 +0300 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-08-03 14:50:29 +0300 |
commit | bc29ff5567beead508ea551b424c53c91a40d000 (patch) | |
tree | 19b2942788ac820760300284ce3e4d8a9f9c36ba /apps/settings | |
parent | a08f995e80ec174081a8aa9d016dd834218e5dd7 (diff) |
Handle one time and large passwordsbackport/33407/stable23
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.
This adds an option to disable storing passwords in the database. This
might be desirable when using single use token as passwords or very
large passwords.
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/settings')
-rw-r--r-- | apps/settings/lib/Controller/ChangePasswordController.php | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/apps/settings/lib/Controller/ChangePasswordController.php b/apps/settings/lib/Controller/ChangePasswordController.php index 8dd1e6ba028..f595368563f 100644 --- a/apps/settings/lib/Controller/ChangePasswordController.php +++ b/apps/settings/lib/Controller/ChangePasswordController.php @@ -107,7 +107,7 @@ class ChangePasswordController extends Controller { } try { - if ($newpassword === null || $user->setPassword($newpassword) === false) { + if ($newpassword === null || strlen($newpassword) > 469 || $user->setPassword($newpassword) === false) { return new JSONResponse([ 'status' => 'error' ]); @@ -155,6 +155,16 @@ class ChangePasswordController extends Controller { ]); } + if (strlen($password) > 469) { + return new JSONResponse([ + 'status' => 'error', + 'data' => [ + 'message' => $this->l->t('Unable to change password. Password too long.'), + ], + ]); + } + + $currentUser = $this->userSession->getUser(); $targetUser = $this->userManager->get($username); if ($currentUser === null || $targetUser === null || |