feat: secure litellm api

This commit is contained in:
Timothy J. Baek 2024-02-23 22:44:56 -08:00
parent af388dfe62
commit b5bd07a06a
2 changed files with 30 additions and 2 deletions

View file

@ -58,6 +58,17 @@ def extract_token_from_auth_header(auth_header: str):
return auth_header[len("Bearer ") :]
def get_http_authorization_cred(auth_header: str):
try:
scheme, credentials = auth_header.split(" ")
return {
"scheme": scheme,
"credentials": credentials,
}
except:
raise ValueError(ERROR_MESSAGES.INVALID_TOKEN)
def get_current_user(
auth_token: HTTPAuthorizationCredentials = Depends(bearer_security),
):