mirror of
https://github.com/open-webui/open-webui
synced 2025-05-01 11:26:00 +00:00
refac
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
This commit is contained in:
parent
3b856b64ed
commit
82189066e8
@ -609,8 +609,6 @@ if frontend_favicon.exists():
|
|||||||
shutil.copyfile(frontend_favicon, STATIC_DIR / "favicon.png")
|
shutil.copyfile(frontend_favicon, STATIC_DIR / "favicon.png")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"An error occurred: {e}")
|
logging.error(f"An error occurred: {e}")
|
||||||
else:
|
|
||||||
logging.warning(f"Frontend favicon not found at {frontend_favicon}")
|
|
||||||
|
|
||||||
frontend_splash = FRONTEND_BUILD_DIR / "static" / "splash.png"
|
frontend_splash = FRONTEND_BUILD_DIR / "static" / "splash.png"
|
||||||
|
|
||||||
@ -619,12 +617,18 @@ if frontend_splash.exists():
|
|||||||
shutil.copyfile(frontend_splash, STATIC_DIR / "splash.png")
|
shutil.copyfile(frontend_splash, STATIC_DIR / "splash.png")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"An error occurred: {e}")
|
logging.error(f"An error occurred: {e}")
|
||||||
else:
|
|
||||||
logging.warning(f"Frontend splash not found at {frontend_splash}")
|
frontend_loader = FRONTEND_BUILD_DIR / "static" / "loader.js"
|
||||||
|
|
||||||
|
if frontend_loader.exists():
|
||||||
|
try:
|
||||||
|
shutil.copyfile(frontend_loader, STATIC_DIR / "loader.js")
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"An error occurred: {e}")
|
||||||
|
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# CUSTOM_NAME
|
# CUSTOM_NAME (Legacy)
|
||||||
####################################
|
####################################
|
||||||
|
|
||||||
CUSTOM_NAME = os.environ.get("CUSTOM_NAME", "")
|
CUSTOM_NAME = os.environ.get("CUSTOM_NAME", "")
|
||||||
|
@ -88,7 +88,6 @@ from open_webui.models.models import Models
|
|||||||
from open_webui.models.users import UserModel, Users
|
from open_webui.models.users import UserModel, Users
|
||||||
|
|
||||||
from open_webui.config import (
|
from open_webui.config import (
|
||||||
override_static,
|
|
||||||
LICENSE_KEY,
|
LICENSE_KEY,
|
||||||
# Ollama
|
# Ollama
|
||||||
ENABLE_OLLAMA_API,
|
ENABLE_OLLAMA_API,
|
||||||
@ -316,7 +315,7 @@ from open_webui.utils.middleware import process_chat_payload, process_chat_respo
|
|||||||
from open_webui.utils.access_control import has_access
|
from open_webui.utils.access_control import has_access
|
||||||
|
|
||||||
from open_webui.utils.auth import (
|
from open_webui.utils.auth import (
|
||||||
verify_signature,
|
get_license_data,
|
||||||
decode_token,
|
decode_token,
|
||||||
get_admin_user,
|
get_admin_user,
|
||||||
get_verified_user,
|
get_verified_user,
|
||||||
@ -373,31 +372,8 @@ async def lifespan(app: FastAPI):
|
|||||||
if RESET_CONFIG_ON_START:
|
if RESET_CONFIG_ON_START:
|
||||||
reset_config()
|
reset_config()
|
||||||
|
|
||||||
key = app.state.config.LICENSE_KEY
|
if app.state.config.LICENSE_KEY:
|
||||||
if key:
|
get_license_data(app, app.state.config.LICENSE_KEY)
|
||||||
try:
|
|
||||||
res = requests.post(
|
|
||||||
"https://api.openwebui.com/api/v1/license",
|
|
||||||
json={"key": key, "version": "1"},
|
|
||||||
timeout=5,
|
|
||||||
)
|
|
||||||
|
|
||||||
if getattr(res, "ok", False):
|
|
||||||
payload = getattr(res, "json", lambda: {})()
|
|
||||||
for k, v in payload.items():
|
|
||||||
if k == "resources":
|
|
||||||
for p, c in v.items():
|
|
||||||
globals().get("override_static", lambda a, b: None)(p, c)
|
|
||||||
elif k == "user_count":
|
|
||||||
setattr(app.state, "USER_COUNT", v)
|
|
||||||
elif k == "webui_name":
|
|
||||||
setattr(app.state, "WEBUI_NAME", v)
|
|
||||||
else:
|
|
||||||
log.error(
|
|
||||||
f"License retrieval issue: {getattr(res, 'text', 'unknown error')}"
|
|
||||||
)
|
|
||||||
except Exception as ex:
|
|
||||||
log.error(f"Uncaught Exception: {ex}")
|
|
||||||
|
|
||||||
asyncio.create_task(periodic_usage_pool_cleanup())
|
asyncio.create_task(periodic_usage_pool_cleanup())
|
||||||
yield
|
yield
|
||||||
@ -414,9 +390,8 @@ oauth_manager = OAuthManager(app)
|
|||||||
|
|
||||||
app.state.config = AppConfig()
|
app.state.config = AppConfig()
|
||||||
|
|
||||||
app.state.config.LICENSE_KEY = LICENSE_KEY
|
|
||||||
|
|
||||||
app.state.WEBUI_NAME = WEBUI_NAME
|
app.state.WEBUI_NAME = WEBUI_NAME
|
||||||
|
app.state.config.LICENSE_KEY = LICENSE_KEY
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
#
|
#
|
||||||
|
@ -4,6 +4,8 @@ import jwt
|
|||||||
import base64
|
import base64
|
||||||
import hmac
|
import hmac
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
from datetime import UTC, datetime, timedelta
|
from datetime import UTC, datetime, timedelta
|
||||||
from typing import Optional, Union, List, Dict
|
from typing import Optional, Union, List, Dict
|
||||||
@ -11,6 +13,7 @@ from typing import Optional, Union, List, Dict
|
|||||||
from open_webui.models.users import Users
|
from open_webui.models.users import Users
|
||||||
|
|
||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
|
from open_webui.config import override_static
|
||||||
from open_webui.env import WEBUI_SECRET_KEY, TRUSTED_SIGNATURE_KEY
|
from open_webui.env import WEBUI_SECRET_KEY, TRUSTED_SIGNATURE_KEY
|
||||||
|
|
||||||
from fastapi import Depends, HTTPException, Request, Response, status
|
from fastapi import Depends, HTTPException, Request, Response, status
|
||||||
@ -44,6 +47,36 @@ def verify_signature(payload: str, signature: str) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def get_license_data(app, key):
|
||||||
|
if key:
|
||||||
|
try:
|
||||||
|
res = requests.post(
|
||||||
|
"https://api.openwebui.com/api/v1/license",
|
||||||
|
json={"key": key, "version": "1"},
|
||||||
|
timeout=5,
|
||||||
|
)
|
||||||
|
|
||||||
|
if getattr(res, "ok", False):
|
||||||
|
payload = getattr(res, "json", lambda: {})()
|
||||||
|
for k, v in payload.items():
|
||||||
|
if k == "resources":
|
||||||
|
for p, c in v.items():
|
||||||
|
globals().get("override_static", lambda a, b: None)(p, c)
|
||||||
|
elif k == "user_count":
|
||||||
|
setattr(app.state, "USER_COUNT", v)
|
||||||
|
elif k == "webui_name":
|
||||||
|
setattr(app.state, "WEBUI_NAME", v)
|
||||||
|
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
f"License: retrieval issue: {getattr(res, 'text', 'unknown error')}"
|
||||||
|
)
|
||||||
|
except Exception as ex:
|
||||||
|
print(f"License: Uncaught Exception: {ex}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
bearer_security = HTTPBearer(auto_error=False)
|
bearer_security = HTTPBearer(auto_error=False)
|
||||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@
|
|||||||
|
|
||||||
<div class="mb-2.5">
|
<div class="mb-2.5">
|
||||||
<div class="flex w-full justify-between items-center">
|
<div class="flex w-full justify-between items-center">
|
||||||
<div class="text-xs">
|
<div class="text-xs pr-2">
|
||||||
<div class="">
|
<div class="">
|
||||||
{$i18n.t('Help')}
|
{$i18n.t('Help')}
|
||||||
</div>
|
</div>
|
||||||
@ -180,7 +180,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
class=" text-xs font-medium underline"
|
class="flex-shrink-0 text-xs font-medium underline"
|
||||||
href="https://docs.openwebui.com/"
|
href="https://docs.openwebui.com/"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user