forked from open-webui/open-webui
feat: multi-user support w/ RBAC
This commit is contained in:
parent
31e38df0a5
commit
921eef03b3
21 changed files with 1815 additions and 66 deletions
|
@ -1,4 +1,4 @@
|
|||
from flask import Flask, request, Response
|
||||
from flask import Flask, request, Response, jsonify
|
||||
from flask_cors import CORS
|
||||
|
||||
|
||||
|
@ -6,7 +6,10 @@ import requests
|
|||
import json
|
||||
|
||||
|
||||
from config import OLLAMA_API_BASE_URL
|
||||
from apps.web.models.users import Users
|
||||
from constants import ERROR_MESSAGES
|
||||
from utils import extract_token_from_auth_header
|
||||
from config import OLLAMA_API_BASE_URL, OLLAMA_WEBUI_AUTH
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(
|
||||
|
@ -28,6 +31,21 @@ def proxy(path):
|
|||
data = request.get_data()
|
||||
headers = dict(request.headers)
|
||||
|
||||
if OLLAMA_WEBUI_AUTH:
|
||||
if "Authorization" in headers:
|
||||
token = extract_token_from_auth_header(headers["Authorization"])
|
||||
user = Users.get_user_by_token(token)
|
||||
if user:
|
||||
print(user)
|
||||
pass
|
||||
else:
|
||||
return jsonify({"detail": ERROR_MESSAGES.UNAUTHORIZED}), 401
|
||||
else:
|
||||
return jsonify({"detail": ERROR_MESSAGES.UNAUTHORIZED}), 401
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
# Make a request to the target server
|
||||
target_response = requests.request(
|
||||
method=request.method,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue