]> git.ipfire.org Git - dbl.git/commitdiff
api: Add ratelimiting to the searches
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 3 Mar 2026 17:03:36 +0000 (17:03 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 3 Mar 2026 17:03:36 +0000 (17:03 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/dbl/api/__init__.py
src/dbl/api/domains.py

index aba9f50b9c9e2c19177a59a325f93bac59ccc26d..d051a1d26517704ee6d3ec0a3c5619928007eaa0 100644 (file)
@@ -135,6 +135,7 @@ def index():
 # Search
 
 @app.get("/search", tags=["Search"])
+@limit(minutes=1, limit=10, auth_limit=100)
 async def search(q: str):
        """
                Performs a simple search
index ef65c34dcf768cb4780c9dacee4806b60660d475..e2c63fb869ab5f5f39384ceea8b9b852288948ca 100644 (file)
@@ -27,6 +27,7 @@ from .. import domains
 # Import the main app
 from . import app
 from . import backend
+from . import limit
 
 # Create a router
 router = fastapi.APIRouter(
@@ -35,6 +36,7 @@ router = fastapi.APIRouter(
 )
 
 @router.get("/{name}")
+@limit(minutes=1, limit=10, auth_limit=100, key="/domains")
 def get_domain(name: str):
        # Fetch all domains that match the name
        domains = backend.domains.get_by_name(name)