fix(litellm): gate OAuth routes on real credentials
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user