mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
fix(proxy_server.py): allow user to create key for themselves
This commit is contained in:
parent
766b946b94
commit
dfd027da35
3 changed files with 21 additions and 8 deletions
|
@ -37,14 +37,10 @@ http://0.0.0.0:8000/ui # <proxy_base_url>/ui
|
|||
|
||||
### 3. Create Key
|
||||
|
||||
<Image img={require('../../img/litellm_ui_login.png')} />
|
||||
<Image img={require('../../img/litellm_ui_create_key.png')} />
|
||||
|
||||
### 1. Start the proxy
|
||||
```
|
||||
litellm --config /path/to/config.yaml
|
||||
```
|
||||
|
||||
## 1. Setup SSO/Auth for UI
|
||||
## Setup SSO/Auth for UI
|
||||
|
||||
<Tabs>
|
||||
|
||||
|
|
BIN
docs/my-website/img/litellm_ui_create_key.png
Normal file
BIN
docs/my-website/img/litellm_ui_create_key.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 243 KiB |
|
@ -650,9 +650,26 @@ async def user_api_key_auth(
|
|||
elif route == "/model/info":
|
||||
# /model/info just shows models user has access to
|
||||
pass
|
||||
elif allow_user_auth == True and route == "/key/generate":
|
||||
pass
|
||||
elif route == "/key/generate":
|
||||
"""
|
||||
Make sure user can only create a key for themselves
|
||||
- if user_id passed in -> check if it matches the user id for that key
|
||||
"""
|
||||
request_data = await _read_request_body(request=request)
|
||||
user_id_passed_to_key_generate = request_data.get("user_id", None)
|
||||
if (
|
||||
user_id_passed_to_key_generate is not None
|
||||
and user_id_passed_to_key_generate != valid_token.user_id
|
||||
):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="key not allowed to crea this user's info",
|
||||
)
|
||||
elif allow_user_auth == True and route == "/key/delete":
|
||||
"""
|
||||
[TODO] Make sure user can only delete a key for themselves
|
||||
- if user_id passed in -> check if it matches the user id for that key
|
||||
"""
|
||||
pass
|
||||
elif route == "/spend/logs":
|
||||
# check if user can access this route
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue