Skip to content
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

remove backend for ratelimiter #2058

Merged
merged 7 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/cli_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
jobs:
Test-Envs:
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 25
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The types of changes are:

* Timing issues with bulk DSR reprocessing, specifically when analytics are enabled [#2015](https://github.com/ethyca/fides/pull/2015)
* Error caused by running erasure requests with disabled connectors [#2045](https://github.com/ethyca/fides/pull/2045)
* Changes the SlowAPI ratelimiter's backend to use memory instead of Redis [#2054](https://github.com/ethyca/fides/pull/2058)

## [2.2.2](https://github.com/ethyca/fides/compare/2.2.1...2.2.2)

Expand Down
1 change: 0 additions & 1 deletion src/fides/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
key_prefix=CONFIG.security.rate_limit_prefix,
key_func=get_remote_address,
retry_after="http-date",
storage_uri=CONFIG.redis.connection_url,
)
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
app.add_middleware(SlowAPIMiddleware)
Expand Down
12 changes: 1 addition & 11 deletions tests/ops/api/test_ratelimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def api_client_for_rate_limiting() -> Generator:
key_prefix=CONFIG.security.rate_limit_prefix,
key_func=get_remote_address,
retry_after="http-date",
storage_uri=CONFIG.redis.connection_url,
)
with TestClient(app) as c:
yield c
Expand All @@ -34,11 +33,10 @@ def api_client_for_rate_limiting() -> Generator:
key_prefix=CONFIG.security.rate_limit_prefix,
key_func=get_remote_address,
retry_after="http-date",
storage_uri=CONFIG.redis.connection_url,
)


def test_requests_rate_limited(api_client_for_rate_limiting, cache):
def test_requests_rate_limited(api_client_for_rate_limiting):
"""
Asserts that incremental HTTP requests above the ratelimit threshold are
rebuffed from the API with a 429 response.
Expand All @@ -54,14 +52,6 @@ def test_requests_rate_limited(api_client_for_rate_limiting, cache):
response = api_client_for_rate_limiting.get(HEALTH)
assert response.status_code == 429

ratelimiter_cache_keys = [key for key in cache.keys() if key.startswith("LIMITER/")]
for key in ratelimiter_cache_keys:
# Depending on what requests have been stored previously, the ratelimtier will
# store keys in the format `LIMITER/fides-/127.0.0.1//health/100/1/minute`
assert key.startswith(f"LIMITER/{CONFIG.security.rate_limit_prefix}")
# Reset the cache to not interere with any other tests
cache.delete(key)


def test_rate_limit_validation():
"""Tests `SecuritySettings.validate_request_rate_limit`"""
Expand Down