mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-27 01:22:18 +00:00
* ci: fix the litellm-tests unit job with sysmon coverage, an env allowlist and coverage upload on failure * test: replace key-dependent proxy, enterprise and mcp unit tests with synthetic values and integration and e2e coverage * test: drop key reads at the legacy proxy, enterprise and mcp paths and wire the gemini pass-through split * ci: move caching, proxy-extras, gateway and enterprise tests into tests/unit and run them from litellm-tests under their legacy flags * ci: move caching, proxy-extras, gateway and enterprise tests into tests/unit and run them from litellm-tests under their legacy flags * ci: move tests/proxy_unit_tests to tests/unit/proxy and run the proxy-db shards from litellm-tests * ci: fail the unit shard when circleci tests split errors * test: drop restating comments from the gemini pass-through split * build: point the local proxy unit targets at the nested tests/unit/proxy tree * ci: exit the unit shard cleanly when circleci tests split assigns it no files --------- Co-authored-by: yuneng <yuneng@berri.ai>
22 lines
679 B
Python
22 lines
679 B
Python
from litellm.proxy._types import UserAPIKeyAuth
|
|
from fastapi import Request
|
|
from dotenv import load_dotenv
|
|
import os
|
|
|
|
load_dotenv()
|
|
|
|
|
|
async def user_api_key_auth(request: Request, api_key: str) -> UserAPIKeyAuth:
|
|
try:
|
|
print(f"api_key: {api_key}")
|
|
if api_key == "":
|
|
raise Exception(
|
|
f"CustomAuth - Malformed API Key passed in. Ensure Key has `Bearer` prefix"
|
|
)
|
|
if api_key == f"{os.getenv('PROXY_MASTER_KEY')}-1234":
|
|
return UserAPIKeyAuth(api_key=api_key)
|
|
raise Exception
|
|
except Exception as e:
|
|
if len(str(e)) > 0:
|
|
raise e
|
|
raise Exception("Failed custom auth")
|