chore: make api rate limit configurable through environment variable (#6730)
This commit is contained in:
parent
6157900b23
commit
9ba2ed7d89
5 changed files with 15 additions and 2 deletions
|
|
@ -41,3 +41,6 @@ NGINX_PORT=80
|
||||||
|
|
||||||
# Force HTTPS for handling SSL Termination
|
# Force HTTPS for handling SSL Termination
|
||||||
MINIO_ENDPOINT_SSL=0
|
MINIO_ENDPOINT_SSL=0
|
||||||
|
|
||||||
|
# API key rate limit
|
||||||
|
API_KEY_RATE_LIMIT="60/minute"
|
||||||
|
|
|
||||||
|
|
@ -63,3 +63,6 @@ HARD_DELETE_AFTER_DAYS=60
|
||||||
|
|
||||||
# Force HTTPS for handling SSL Termination
|
# Force HTTPS for handling SSL Termination
|
||||||
MINIO_ENDPOINT_SSL=0
|
MINIO_ENDPOINT_SSL=0
|
||||||
|
|
||||||
|
# API key rate limit
|
||||||
|
API_KEY_RATE_LIMIT="60/minute"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
|
# python imports
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Third party imports
|
||||||
from rest_framework.throttling import SimpleRateThrottle
|
from rest_framework.throttling import SimpleRateThrottle
|
||||||
|
|
||||||
|
|
||||||
class ApiKeyRateThrottle(SimpleRateThrottle):
|
class ApiKeyRateThrottle(SimpleRateThrottle):
|
||||||
scope = "api_key"
|
scope = "api_key"
|
||||||
rate = "60/minute"
|
rate = os.environ.get("API_KEY_RATE_LIMIT", "60/minute")
|
||||||
|
|
||||||
def get_cache_key(self, request, view):
|
def get_cache_key(self, request, view):
|
||||||
# Retrieve the API key from the request header
|
# Retrieve the API key from the request header
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ x-app-env: &app-env
|
||||||
DATABASE_URL: ${DATABASE_URL:-postgresql://plane:plane@plane-db/plane}
|
DATABASE_URL: ${DATABASE_URL:-postgresql://plane:plane@plane-db/plane}
|
||||||
SECRET_KEY: ${SECRET_KEY:-60gp0byfz2dvffa45cxl20p1scy9xbpf6d8c5y0geejgkyp1b5}
|
SECRET_KEY: ${SECRET_KEY:-60gp0byfz2dvffa45cxl20p1scy9xbpf6d8c5y0geejgkyp1b5}
|
||||||
AMQP_URL: ${AMQP_URL:-amqp://plane:plane@plane-mq:5672/plane}
|
AMQP_URL: ${AMQP_URL:-amqp://plane:plane@plane-mq:5672/plane}
|
||||||
|
API_KEY_RATE_LIMIT: ${API_KEY_RATE_LIMIT:-60/minute}
|
||||||
|
|
||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
|
|
|
||||||
|
|
@ -58,3 +58,5 @@ GUNICORN_WORKERS=1
|
||||||
# UNCOMMENT `DOCKER_PLATFORM` IF YOU ARE ON `ARM64` AND DOCKER IMAGE IS NOT AVAILABLE FOR RESPECTIVE `APP_RELEASE`
|
# UNCOMMENT `DOCKER_PLATFORM` IF YOU ARE ON `ARM64` AND DOCKER IMAGE IS NOT AVAILABLE FOR RESPECTIVE `APP_RELEASE`
|
||||||
# DOCKER_PLATFORM=linux/amd64
|
# DOCKER_PLATFORM=linux/amd64
|
||||||
|
|
||||||
|
# API key rate limit
|
||||||
|
API_KEY_RATE_LIMIT="60/minute"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue