Add rate limiting support to API keys
This commit is contained in:
4
app.py
4
app.py
@@ -171,6 +171,10 @@ async def execute_http_function(user_id, function):
|
||||
api_key = db.get_api_key(api_key_value)
|
||||
|
||||
if api_key and api_key['user_id'] == user_id:
|
||||
# Check rate limit
|
||||
if not db.check_and_increment_api_key_usage(api_key['id']):
|
||||
return jsonify({'error': 'Rate limit exceeded'}), 429
|
||||
|
||||
# Check Scopes
|
||||
scopes = api_key['scopes']
|
||||
if isinstance(scopes, str):
|
||||
|
||||
Reference in New Issue
Block a user