Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit 8218906

Browse files
committed
refac
1 parent 3b856b6 commit 8218906

File tree

4 files changed

+48
-36
lines changed

4 files changed

+48
-36
lines changed

backend/open_webui/config.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,6 @@ def override_static(path: str, content: str):
609609
shutil.copyfile(frontend_favicon, STATIC_DIR / "favicon.png")
610610
except Exception as e:
611611
logging.error(f"An error occurred: {e}")
612-
else:
613-
logging.warning(f"Frontend favicon not found at {frontend_favicon}")
614612

615613
frontend_splash = FRONTEND_BUILD_DIR / "static" / "splash.png"
616614

@@ -619,12 +617,18 @@ def override_static(path: str, content: str):
619617
shutil.copyfile(frontend_splash, STATIC_DIR / "splash.png")
620618
except Exception as e:
621619
logging.error(f"An error occurred: {e}")
622-
else:
623-
logging.warning(f"Frontend splash not found at {frontend_splash}")
620+
621+
frontend_loader = FRONTEND_BUILD_DIR / "static" / "loader.js"
622+
623+
if frontend_loader.exists():
624+
try:
625+
shutil.copyfile(frontend_loader, STATIC_DIR / "loader.js")
626+
except Exception as e:
627+
logging.error(f"An error occurred: {e}")
624628

625629

626630
####################################
627-
# CUSTOM_NAME
631+
# CUSTOM_NAME (Legacy)
628632
####################################
629633

630634
CUSTOM_NAME = os.environ.get("CUSTOM_NAME", "")

backend/open_webui/main.py

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
from open_webui.models.users import UserModel, Users
8989

9090
from open_webui.config import (
91-
override_static,
9291
LICENSE_KEY,
9392
# Ollama
9493
ENABLE_OLLAMA_API,
@@ -316,7 +315,7 @@
316315
from open_webui.utils.access_control import has_access
317316

318317
from open_webui.utils.auth import (
319-
verify_signature,
318+
get_license_data,
320319
decode_token,
321320
get_admin_user,
322321
get_verified_user,
@@ -373,31 +372,8 @@ async def lifespan(app: FastAPI):
373372
if RESET_CONFIG_ON_START:
374373
reset_config()
375374

376-
key = app.state.config.LICENSE_KEY
377-
if key:
378-
try:
379-
res = requests.post(
380-
"https://api.openwebui.com/api/v1/license",
381-
json={"key": key, "version": "1"},
382-
timeout=5,
383-
)
384-
385-
if getattr(res, "ok", False):
386-
payload = getattr(res, "json", lambda: {})()
387-
for k, v in payload.items():
388-
if k == "resources":
389-
for p, c in v.items():
390-
globals().get("override_static", lambda a, b: None)(p, c)
391-
elif k == "user_count":
392-
setattr(app.state, "USER_COUNT", v)
393-
elif k == "webui_name":
394-
setattr(app.state, "WEBUI_NAME", v)
395-
else:
396-
log.error(
397-
f"License retrieval issue: {getattr(res, 'text', 'unknown error')}"
398-
)
399-
except Exception as ex:
400-
log.error(f"Uncaught Exception: {ex}")
375+
if app.state.config.LICENSE_KEY:
376+
get_license_data(app, app.state.config.LICENSE_KEY)
401377

402378
asyncio.create_task(periodic_usage_pool_cleanup())
403379
yield
@@ -414,9 +390,8 @@ async def lifespan(app: FastAPI):
414390

415391
app.state.config = AppConfig()
416392

417-
app.state.config.LICENSE_KEY = LICENSE_KEY
418-
419393
app.state.WEBUI_NAME = WEBUI_NAME
394+
app.state.config.LICENSE_KEY = LICENSE_KEY
420395

421396
########################################
422397
#

backend/open_webui/utils/auth.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
import base64
55
import hmac
66
import hashlib
7+
import requests
8+
79

810
from datetime import UTC, datetime, timedelta
911
from typing import Optional, Union, List, Dict
1012

1113
from open_webui.models.users import Users
1214

1315
from open_webui.constants import ERROR_MESSAGES
16+
from open_webui.config import override_static
1417
from open_webui.env import WEBUI_SECRET_KEY, TRUSTED_SIGNATURE_KEY
1518

1619
from fastapi import Depends, HTTPException, Request, Response, status
@@ -44,6 +47,36 @@ def verify_signature(payload: str, signature: str) -> bool:
4447
return False
4548

4649

50+
def get_license_data(app, key):
51+
if key:
52+
try:
53+
res = requests.post(
54+
"https://api.openwebui.com/api/v1/license",
55+
json={"key": key, "version": "1"},
56+
timeout=5,
57+
)
58+
59+
if getattr(res, "ok", False):
60+
payload = getattr(res, "json", lambda: {})()
61+
for k, v in payload.items():
62+
if k == "resources":
63+
for p, c in v.items():
64+
globals().get("override_static", lambda a, b: None)(p, c)
65+
elif k == "user_count":
66+
setattr(app.state, "USER_COUNT", v)
67+
elif k == "webui_name":
68+
setattr(app.state, "WEBUI_NAME", v)
69+
70+
return True
71+
else:
72+
print(
73+
f"License: retrieval issue: {getattr(res, 'text', 'unknown error')}"
74+
)
75+
except Exception as ex:
76+
print(f"License: Uncaught Exception: {ex}")
77+
return False
78+
79+
4780
bearer_security = HTTPBearer(auto_error=False)
4881
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
4982

src/lib/components/admin/Settings/General.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170

171171
<div class="mb-2.5">
172172
<div class="flex w-full justify-between items-center">
173-
<div class="text-xs">
173+
<div class="text-xs pr-2">
174174
<div class="">
175175
{$i18n.t('Help')}
176176
</div>
@@ -180,7 +180,7 @@
180180
</div>
181181

182182
<a
183-
class=" text-xs font-medium underline"
183+
class="flex-shrink-0 text-xs font-medium underline"
184184
href="https://docs.openwebui.com/"
185185
target="_blank"
186186
>

0 commit comments

Comments
 (0)