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