mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
Merge pull request #18411 from ricdikulous/feat/websocket-cors-security
feat: add CORS validation to WebSocket connections for defense-in-depth
This commit is contained in:
commit
3984184a82
1 changed files with 6 additions and 2 deletions
|
|
@ -18,6 +18,10 @@ from open_webui.utils.redis import (
|
|||
get_sentinel_url_from_env,
|
||||
)
|
||||
|
||||
from open_webui.config import (
|
||||
CORS_ALLOW_ORIGIN,
|
||||
)
|
||||
|
||||
from open_webui.env import (
|
||||
ENABLE_WEBSOCKET_SUPPORT,
|
||||
WEBSOCKET_MANAGER,
|
||||
|
|
@ -58,7 +62,7 @@ if WEBSOCKET_MANAGER == "redis":
|
|||
else:
|
||||
mgr = socketio.AsyncRedisManager(WEBSOCKET_REDIS_URL)
|
||||
sio = socketio.AsyncServer(
|
||||
cors_allowed_origins=[],
|
||||
cors_allowed_origins=CORS_ALLOW_ORIGIN,
|
||||
async_mode="asgi",
|
||||
transports=(["websocket"] if ENABLE_WEBSOCKET_SUPPORT else ["polling"]),
|
||||
allow_upgrades=ENABLE_WEBSOCKET_SUPPORT,
|
||||
|
|
@ -67,7 +71,7 @@ if WEBSOCKET_MANAGER == "redis":
|
|||
)
|
||||
else:
|
||||
sio = socketio.AsyncServer(
|
||||
cors_allowed_origins=[],
|
||||
cors_allowed_origins=CORS_ALLOW_ORIGIN,
|
||||
async_mode="asgi",
|
||||
transports=(["websocket"] if ENABLE_WEBSOCKET_SUPPORT else ["polling"]),
|
||||
allow_upgrades=ENABLE_WEBSOCKET_SUPPORT,
|
||||
|
|
|
|||
Loading…
Reference in a new issue