Feature/rate limit login - #64
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64 +/- ##
==========================================
+ Coverage 85.39% 86.65% +1.25%
==========================================
Files 41 37 -4
Lines 3678 3312 -366
==========================================
- Hits 3141 2870 -271
+ Misses 537 442 -95
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…acks - Add Flask-Limiter dependency for rate limiting - Limit login endpoint to 5 requests/minute (prevents credential stuffing) - Limit file upload to 10 requests/minute (prevents upload flooding) - Limit file listing to 30 requests/minute (prevents enumeration) - Add 429 error handler with JSON response - Support memory storage by default, configurable via RATE_LIMIT_STORAGE_URI env var Security impact: Mitigates brute-force attacks on login and resource exhaustion via API endpoints.
cchwala
force-pushed
the
feature/rate-limit-login
branch
from
July 30, 2026 09:04
52b47f0 to
b3f2eaf
Compare
The logged_in_client fixture was using actual session-based login which
doesn't persist properly in test client when mocking is involved. This
caused mock_requests.request.call_args to be None, resulting in
'TypeError: cannot unpack non-iterable NoneType object' errors.
Updated to match pattern used in other passing tests (test_api_routes.py,
test_time_slider_api.py):
- Set LOGIN_DISABLED=True to bypass auth checks
- Mock current_user directly instead of relying on session
- Remove client.post('/login', ...) call that wasn't persisting
Fixes 3 failing CI tests:
- test_grafana_proxy_injects_webauth_user_header
- test_grafana_proxy_strips_client_webauth_user_header
- test_grafana_proxy_forwards_path
…ting Without ProxyFix, get_remote_address returns the nginx IP, putting all clients in the same rate limit bucket. Set PROXY_COUNT=1 in the deploy docker-compose override when running behind nginx.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Adds security hardening through rate limiting on sensitive endpoints and fixes test infrastructure issues.
Changes
Security Features
RATE_LIMIT_STORAGE_URIenv varInfrastructure
flask-limiterto webserver requirementsReverse Proxy Support
ProxyFixmiddleware: UnwrapsX-Forwarded-Forso rate limiting keys on the real client IP, not the nginx IP (which would put all users in the same bucket)PROXY_COUNTenv var: Defaults to0(direct); set to1in the deploy override when running behind nginxTest Fixes
logged_in_clientfixture with pattern used in 90+ passing testsTesting
All 95 webserver tests pass.