mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 03:47:49 +01:00
feat(auth): add auth middleware
- refactored chat routes to use request.user instead of doing authentication in every route
This commit is contained in:
@@ -55,13 +55,13 @@ def extract_token_from_auth_header(auth_header: str):
|
||||
|
||||
def verify_token(request):
|
||||
try:
|
||||
bearer = request.headers["authorization"]
|
||||
if bearer:
|
||||
token = bearer[len("Bearer ") :]
|
||||
decoded = jwt.decode(
|
||||
authorization = request.headers["authorization"]
|
||||
if authorization:
|
||||
_, token = authorization.split()
|
||||
decoded_token = jwt.decode(
|
||||
token, JWT_SECRET_KEY, options={"verify_signature": False}
|
||||
)
|
||||
return decoded
|
||||
return decoded_token
|
||||
else:
|
||||
return None
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user