|
15 | 15 | IS_PRODUCTION = ENV == "production" |
16 | 16 | IS_DEVELOPMENT = not IS_PRODUCTION |
17 | 17 |
|
| 18 | +# Rate limit: enforced by default. Set CROSSBAR_RATE_LIMIT=false or 0 to disable. |
| 19 | +_rate_limit_env = os.getenv("CROSSBAR_RATE_LIMIT", "").lower() |
| 20 | +RATE_LIMITING_ENABLED = _rate_limit_env not in ("false", "0") |
| 21 | + |
18 | 22 | # Environment-specific settings |
19 | 23 | SETTINGS = { |
20 | 24 | "csrf_enabled": IS_PRODUCTION, |
21 | | - "rate_limiting_enabled": IS_PRODUCTION, |
| 25 | + "rate_limiting_enabled": RATE_LIMITING_ENABLED, |
22 | 26 | "debug_logging": IS_DEVELOPMENT, |
23 | 27 | # Rate limiting settings |
24 | 28 | "rate_limits": { |
25 | | - # Use a very large number in development mode instead of infinity |
26 | | - # to avoid JSON serialization issues |
27 | | - "minute": 6 if IS_PRODUCTION else 10000000, # Requests per minute |
28 | | - "hour": 20 if IS_PRODUCTION else 10000000, # Requests per hour |
29 | | - "day": 50 if IS_PRODUCTION else 10000000, # Requests per day |
| 29 | + # Use production limits when rate limiting is enabled; otherwise use |
| 30 | + # very large numbers (instead of infinity) to avoid JSON serialization issues |
| 31 | + "minute": 6 if RATE_LIMITING_ENABLED else 10000000, # Requests per minute |
| 32 | + "hour": 20 if RATE_LIMITING_ENABLED else 10000000, # Requests per hour |
| 33 | + "day": 50 if RATE_LIMITING_ENABLED else 10000000, # Requests per day |
30 | 34 | }, |
31 | 35 | } |
32 | 36 |
|
|
0 commit comments