forked from phoenix/litellm-mirror
(feat) add litellm login to proxy
This commit is contained in:
parent
21450b9a73
commit
f966cce26a
1 changed files with 78 additions and 0 deletions
|
@ -3103,6 +3103,84 @@ async def user_info(
|
|||
)
|
||||
|
||||
|
||||
html_form = """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>LiteLLM Login</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
form {
|
||||
background-color: #fff;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
margin-bottom: 16px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
background-color: #4caf50;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input[type="submit"]:hover {
|
||||
background-color: #45a049;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form action="/login" method="post">
|
||||
<h2>LiteLLM Login</h2>
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" id="username" name="username" required>
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
from fastapi import FastAPI, Form
|
||||
from fastapi.responses import HTMLResponse
|
||||
|
||||
|
||||
@router.get("/login/page")
|
||||
async def login_page():
|
||||
return HTMLResponse(content=html_form, status_code=200)
|
||||
|
||||
|
||||
@router.get("/login")
|
||||
async def login(username: str = Form(...), password: str = Form(...)):
|
||||
# Here you can perform authentication logic
|
||||
# For simplicity, let's just print the received credentials
|
||||
# print(f"Received username: {username}, password: {password}")
|
||||
return {"message": "Login successful"}
|
||||
|
||||
|
||||
@router.post(
|
||||
"/user/update", tags=["user management"], dependencies=[Depends(user_api_key_auth)]
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue