Skip to content

Commit 1764170

Browse files
committed
refac
1 parent 188b928 commit 1764170

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

backend/open_webui/config.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -588,20 +588,6 @@ def oidc_oauth_register(client):
588588

589589
STATIC_DIR = Path(os.getenv("STATIC_DIR", OPEN_WEBUI_DIR / "static")).resolve()
590590

591-
592-
def override_static(path: str, content: str):
593-
# Ensure path is safe
594-
if "/" in path or ".." in path:
595-
log.error(f"Invalid path: {path}")
596-
return
597-
598-
file_path = os.path.join(STATIC_DIR, path)
599-
os.makedirs(os.path.dirname(file_path), exist_ok=True)
600-
601-
with open(file_path, "wb") as f:
602-
f.write(base64.b64decode(content)) # Convert Base64 back to raw binary
603-
604-
605591
frontend_favicon = FRONTEND_BUILD_DIR / "static" / "favicon.png"
606592

607593
if frontend_favicon.exists():

backend/open_webui/utils/auth.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import hmac
66
import hashlib
77
import requests
8+
import os
89

910

1011
from datetime import UTC, datetime, timedelta
@@ -13,8 +14,7 @@
1314
from open_webui.models.users import Users
1415

1516
from open_webui.constants import ERROR_MESSAGES
16-
from open_webui.config import override_static
17-
from open_webui.env import WEBUI_SECRET_KEY, TRUSTED_SIGNATURE_KEY
17+
from open_webui.env import WEBUI_SECRET_KEY, TRUSTED_SIGNATURE_KEY, STATIC_DIR
1818

1919
from fastapi import Depends, HTTPException, Request, Response, status
2020
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
@@ -47,6 +47,19 @@ def verify_signature(payload: str, signature: str) -> bool:
4747
return False
4848

4949

50+
def override_static(path: str, content: str):
51+
# Ensure path is safe
52+
if "/" in path or ".." in path:
53+
print(f"Invalid path: {path}")
54+
return
55+
56+
file_path = os.path.join(STATIC_DIR, path)
57+
os.makedirs(os.path.dirname(file_path), exist_ok=True)
58+
59+
with open(file_path, "wb") as f:
60+
f.write(base64.b64decode(content)) # Convert Base64 back to raw binary
61+
62+
5063
def get_license_data(app, key):
5164
if key:
5265
try:

0 commit comments

Comments
 (0)