-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity_config.py
More file actions
27 lines (19 loc) · 841 Bytes
/
security_config.py
File metadata and controls
27 lines (19 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
from typing import Dict
RUNTIME_SECRET_PLACEHOLDERS = {
"ADMIN_API_KEY": {"your-universal-api-key", "default-key"},
"FLASK_SECRET_KEY": {"your-flask-secret-key", "your-secret-key"},
"JWT_SECRET": {"your-jwt-secret-key", "your-secret-key"},
}
def require_runtime_secret(name: str) -> str:
value = (os.environ.get(name) or "").strip()
if not value:
raise RuntimeError(f"{name} must be configured before starting MultiLLM-Proxy")
if value in RUNTIME_SECRET_PLACEHOLDERS.get(name, set()):
raise RuntimeError(f"{name} must be replaced with a real secret before starting MultiLLM-Proxy")
return value
def validate_runtime_secrets() -> Dict[str, str]:
return {
name: require_runtime_secret(name)
for name in ("ADMIN_API_KEY", "FLASK_SECRET_KEY", "JWT_SECRET")
}