|
11 | 11 | use OC\Authentication\TwoFactorAuth\Manager; |
12 | 12 | use OC_User; |
13 | 13 | use OCP\AppFramework\Controller; |
| 14 | +use OCP\AppFramework\Http\Attribute\BruteForceProtection; |
14 | 15 | use OCP\AppFramework\Http\Attribute\FrontpageRoute; |
15 | 16 | use OCP\AppFramework\Http\Attribute\NoAdminRequired; |
16 | 17 | use OCP\AppFramework\Http\Attribute\NoCSRFRequired; |
@@ -144,6 +145,7 @@ public function showChallenge(string $challengeProviderId, ?string $redirect_url |
144 | 145 | #[FrontpageRoute(verb: 'POST', url: '/login/challenge/{challengeProviderId}')] |
145 | 146 | #[TwoFactorSetUpDoneRequired] |
146 | 147 | #[UserRateLimit(limit: 5, period: 100)] |
| 148 | + #[BruteForceProtection(action: 'solveChallenge')] |
147 | 149 | public function solveChallenge(string $challengeProviderId, string $challenge, ?string $redirect_url = null): RedirectResponse { |
148 | 150 | $user = $this->userSession->getUser(); |
149 | 151 | $provider = $this->twoFactorManager->getProvider($user, $challengeProviderId); |
@@ -171,10 +173,12 @@ public function solveChallenge(string $challengeProviderId, string $challenge, ? |
171 | 173 | $uid = $user->getUID(); |
172 | 174 | $this->logger->warning("Two-factor challenge failed: $uid (Remote IP: $ip)"); |
173 | 175 | $this->session->set('two_factor_auth_error', true); |
174 | | - return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.showChallenge', [ |
| 176 | + $response = new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.showChallenge', [ |
175 | 177 | 'challengeProviderId' => $provider->getId(), |
176 | 178 | 'redirect_url' => $redirect_url, |
177 | 179 | ])); |
| 180 | + $response->throttle(['user' => $uid, 'provider' => $challengeProviderId]); |
| 181 | + return $response; |
178 | 182 | } |
179 | 183 |
|
180 | 184 | #[NoAdminRequired] |
|
0 commit comments