Skip to content

Add throttling to login api: 10 tentative per hour #3539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 29, 2025
Merged

Conversation

ildyria
Copy link
Member

@ildyria ildyria commented Jul 15, 2025

This pull request introduces a rate-limiting middleware to the login route in the API and adds a corresponding test to ensure the middleware functions as expected. The changes enhance security by mitigating brute-force login attempts.

Security Enhancements:

  • routes/api_v2.php: Added a throttle:10,60,login middleware to the /Auth::login route to limit login attempts to 10 requests per minute.

Testing Additions:

  • tests/Feature_v2/User/LoginTest.php: Created a new LoginTest class to verify the rate-limiting middleware. The test simulates 10 failed login attempts, ensuring the 11th attempt returns a 429 Too Many Requests status.

@ildyria ildyria requested a review from a team as a code owner July 15, 2025 17:02
@ildyria ildyria added Review: easy Easy review expected: probably just need a quick to go through. alpha-ready Branch is available in alpha labels Jul 15, 2025
Copy link

codecov bot commented Jul 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.77%. Comparing base (40a92b5) to head (ad9858d).
⚠️ Report is 21 commits behind head on master.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ildyria ildyria merged commit 93a2101 into master Jul 29, 2025
35 checks passed
@ildyria ildyria deleted the rate-limit-login branch July 29, 2025 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alpha-ready Branch is available in alpha Review: easy Easy review expected: probably just need a quick to go through.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants