Skip to content

Commit 33329a5

Browse files
authored
Merge pull request #36576 from nextcloud/backport/36489/stable22
[stable22] Add bruteforce protection to password reset page
2 parents aea656b + 00353e5 commit 33329a5

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

core/Controller/LostController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ public function __construct(
128128
*
129129
* @PublicPage
130130
* @NoCSRFRequired
131+
* @BruteForceProtection(action=passwordResetEmail)
132+
* @AnonRateThrottle(limit=10, period=300)
131133
*
132134
* @param string $token
133135
* @param string $userId
@@ -141,12 +143,14 @@ public function resetform($token, $userId) {
141143
|| ($e instanceof InvalidTokenException
142144
&& !in_array($e->getCode(), [InvalidTokenException::TOKEN_NOT_FOUND, InvalidTokenException::USER_UNKNOWN]))
143145
) {
144-
return new TemplateResponse(
146+
$response = new TemplateResponse(
145147
'core', 'error', [
146148
"errors" => [["error" => $e->getMessage()]]
147149
],
148150
TemplateResponse::RENDER_AS_GUEST
149151
);
152+
$response->throttle();
153+
return $response;
150154
}
151155
return new TemplateResponse('core', 'error', [
152156
'errors' => [['error' => $this->l10n->t('Password reset is disabled')]]

tests/Core/Controller/LostControllerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public function testResetFormTokenError() {
165165
]
166166
],
167167
'guest');
168+
$expectedResponse->throttle();
168169
$this->assertEquals($expectedResponse, $response);
169170
}
170171

0 commit comments

Comments
 (0)