Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add status code 429 for too many requests on ocs API requests
Signed-off-by: Akhil <[email protected]>
  • Loading branch information
akhil1508 committed Feb 16, 2024
commit 50f453ed931a2a360ee4ebdd1dce8be96a3c1650
3 changes: 3 additions & 0 deletions ocs/v1.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
OC_API::respond($ex->getResult(), OC_API::requestedFormat());
} catch (\OC\User\LoginException $e) {
OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_UNAUTHORISED, 'Unauthorised'));
} catch (\OCP\Security\Bruteforce\MaxDelayReached) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't already handled a few lines up (line 67 in this code block) due to recent #41937? Or do I need to finish drinking my morning coffee? :)

@akhil1508 Did you by chance see this in a slightly outdated environment in the wild (latest v26, v27, and v28 should all handle this already)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you by chance see this in a slightly outdated environment in the wild (latest v26, v27, and v28 should all handle this already)?

Ahhh yes, my bad. Apologies!

OC_API::setContentType();
http_response_code(429);
} catch (\Exception $e) {
\OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
OC_API::setContentType();
Expand Down