-- PostgreSQL database dump
--
-\restrict eKEDDgUfPNvnW4rVUzYeVjaWYWpaanMRnCSzmfxb3B7N83rA9qmJYZl5gCT8wnK
+\restrict djz8ldYp4Ibt0nuMIDjTvZxpbMpzfk5h4nJXJqevhuhHUcLnPp7CWYU7CqIZtDF
-- Dumped from database version 17.7 (Debian 17.7-0+deb13u1)
-- Dumped by pg_dump version 17.7 (Debian 17.7-0+deb13u1)
deleted_by text,
uid text NOT NULL,
can_impersonate boolean DEFAULT false NOT NULL,
- last_used_at timestamp with time zone
+ last_used_at timestamp with time zone,
+ is_ratelimited boolean DEFAULT true NOT NULL
);
-- PostgreSQL database dump complete
--
-\unrestrict eKEDDgUfPNvnW4rVUzYeVjaWYWpaanMRnCSzmfxb3B7N83rA9qmJYZl5gCT8wnK
+\unrestrict djz8ldYp4Ibt0nuMIDjTvZxpbMpzfk5h4nJXJqevhuhHUcLnPp7CWYU7CqIZtDF
Called when the API key has been used
"""
self.last_used_at = sqlmodel.func.current_timestamp()
+
+ # Is Ratelimited?
+
+ is_ratelimited: bool = True
"""
Returns True if the request is prohibited by the rate limiter
"""
+ # Fetch the API key
+ if self.api_key:
+ # Fetch the API key
+ key = await self.backend.auth(api_key)
+
+ # If the API key was found and is not ratelimited, we skip further checks
+ if key and not key.is_ratelimited:
+ return False
+
+ # Fetch the number of past requests
self.requests = await self.get_requests()
# The client is rate-limited when more requests have been