|
29 | 29 | use OC\Authentication\TwoFactorAuth\Manager; |
30 | 30 | use OC_User; |
31 | 31 | use OCP\AppFramework\Controller; |
| 32 | +use OCP\AppFramework\Http\Attribute\BruteForceProtection; |
32 | 33 | use OCP\AppFramework\Http\Attribute\FrontpageRoute; |
33 | 34 | use OCP\AppFramework\Http\Attribute\OpenAPI; |
34 | 35 | use OCP\AppFramework\Http\Attribute\UseSession; |
@@ -178,6 +179,7 @@ public function showChallenge($challengeProviderId, $redirect_url) { |
178 | 179 | */ |
179 | 180 | #[UseSession] |
180 | 181 | #[FrontpageRoute(verb: 'POST', url: '/login/challenge/{challengeProviderId}')] |
| 182 | + #[BruteForceProtection(action: 'solveChallenge')] |
181 | 183 | public function solveChallenge($challengeProviderId, $challenge, $redirect_url = null) { |
182 | 184 | $user = $this->userSession->getUser(); |
183 | 185 | $provider = $this->twoFactorManager->getProvider($user, $challengeProviderId); |
@@ -205,10 +207,12 @@ public function solveChallenge($challengeProviderId, $challenge, $redirect_url = |
205 | 207 | $uid = $user->getUID(); |
206 | 208 | $this->logger->warning("Two-factor challenge failed: $uid (Remote IP: $ip)"); |
207 | 209 | $this->session->set('two_factor_auth_error', true); |
208 | | - return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.showChallenge', [ |
| 210 | + $response = new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.showChallenge', [ |
209 | 211 | 'challengeProviderId' => $provider->getId(), |
210 | 212 | 'redirect_url' => $redirect_url, |
211 | 213 | ])); |
| 214 | + $response->throttle(['user' => $uid, 'provider' => $challengeProviderId]); |
| 215 | + return $response; |
212 | 216 | } |
213 | 217 |
|
214 | 218 | /** |
|
0 commit comments