fix(litellm): gate OAuth routes on real credentials

This commit is contained in:
Codex
2026-10-08 21:43:18 -07:00
parent 9a4020b7ec
commit 6473297555
4 changed files with 33 additions and 5 deletions
+10 -1
View File
@@ -1,10 +1,19 @@
"""Render only credential-ready routes; credentials remain environment references."""
import os
import json
from pathlib import Path
import yaml
def oauth_ready(path):
try:
record = json.loads(path.read_text())
return isinstance(record, dict) and bool(record.get('access_token'))
except (OSError, ValueError):
return False
def build_config(catalog, env, exists):
routes = []
@@ -49,7 +58,7 @@ def build_config(catalog, env, exists):
if __name__ == '__main__':
catalog = yaml.safe_load(Path('/etc/litellm/models.yaml').read_text())
config = build_config(catalog, os.environ, Path.is_file)
config = build_config(catalog, os.environ, oauth_ready)
output = Path('/tmp/litellm.yaml')
output.write_text(yaml.safe_dump(config, allow_unicode=True, sort_keys=False))
output.chmod(0o600)