Skip to content

Commit

Permalink
Fix api key limiter
Browse files Browse the repository at this point in the history
  • Loading branch information
raimannma committed Oct 21, 2024
1 parent 1b2deaa commit edfacb4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions deadlock_data_api/rate_limiter/limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ def apply_limits(
if api_key is not None and utils.is_valid_uuid(api_key.lstrip("HEXE-"))
else None
)
limits = (
get_extra_api_key_limits(api_key, request.url.path)
or key_default_limits
or ip_limits
if api_key
else ip_limits
)
status = [limit_by_key(f"{ip}:{key}", l) for l in limits]
limits = []
prefix = ip
if api_key:
limits = (
get_extra_api_key_limits(api_key, request.url.path) or key_default_limits
)
if limits:
prefix = api_key
if not limits:
limits = ip_limits
status = [limit_by_key(f"{prefix}:{key}", l) for l in limits]
for s in status:
LOGGER.info(
f"count: {s.count}, "
Expand Down

0 comments on commit edfacb4

Please sign in to comment.