mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 11:57:51 +01:00
feat: multi-user support w/ RBAC
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user