retire the Open WebUI integration
ci/woodpecker/push/woodpecker Pipeline was canceled

The app is stopped (`com.openwebui.cloudronapp`, installed|stopped), so every call
to it failed with "Temporary failure in name resolution" — a stopped container has
no DNS entry. Four of the last four provisions logged exactly that; no new member
ever reached the group.

Its "members group" was never a Cloudron group: the id pointed at a group inside
Open WebUI's own database, which is why it appears nowhere in Cloudron's UI.

Removed: owui_add_to_members_group, both call sites (provision_member and guest
convert), the OWUI_* constants, and the signed-JWT identity path in inject_key.
That last one is the part that matters beyond tidiness: it accepted a
shared-secret-signed token as proof of identity for an integration nobody runs.
inject_key keeps its one live path (LibreChat: X-User-Email + X-Portal-Secret,
still verified).

First attempt at this cut too much — a greedy splice off the guest-convert call
took listmonk_sync and the held-credit grant with it, and test_guest_lifecycle.py
caught it before anything shipped. Redone with exact anchors.
This commit is contained in:
inference-admin committed 2026-11-13 22:33:10 +00:00
1 parent 5c494cb261
commit 0a6939fe07
1 file changed
+9 -89
+9 -89
View File
@@ -210,16 +210,12 @@ PORTAL_SECRET = os.environ.get("PORTAL_SECRET", "")
# genuinely came from OpenWebUI (behind Cloudron SSO) rather than a spoofed
# header. This is stronger than the plain X-Portal-Secret header because the
# email itself is tamper-proof.
OWUI_JWT_SECRET = os.environ.get("OWUI_JWT_SECRET", "")
# Open WebUI admin API key — used at provisioning time to add the new member to
# Open WebUI's `members` group, which gates read access to the shared
# "Inference Cooperative Docs" RAG collection. Without this, a new member's
# first chat session has no docs grounding (the nightly refresh would only fix
# it hours later). Machine-to-machine only; never logged.
OWUI_API_KEY = os.environ.get("OWUI_API_KEY", "")
OWUI_BASE = os.environ.get("OWUI_BASE", "http://chat:8080") # internal Cloudron network
OWUI_MEMBERS_GROUP_ID = os.environ.get("OWUI_MEMBERS_GROUP_ID", "eb348e1a-059a-4a8f-8920-0f73942f6272")
# Open WebUI knowledge collection id for the co-op docs RAG. Attached to every
# model in /v1/models so answers are grounded by automatic RAG injection (and
@@ -2613,63 +2609,11 @@ async def cloudron_set_active(user_id: str, active: bool) -> None:
r.raise_for_status()
async def owui_add_to_members_group(cloudron_user_id: str) -> bool:
"""Add a (new) member to Open WebUI's `members` group by their Cloudron uid.
Open WebUI authenticates via Cloudron SSO and stores users keyed by the SSO
`sub` — which is the Cloudron user id (uid-…). The shared docs-RAG knowledge
collection is granted read to the `members` group, so group membership is
what makes the docs visible. Called at provisioning time so a new member's
FIRST chat session already has the docs (the nightly refresh sync is too
slow for that).
Best-effort: any failure logs a warning and returns False — provisioning
must not fail over this; the nightly refresh self-heals within a day.
"""
if not OWUI_API_KEY:
logger.warning("OWUI_API_KEY not set; skipping Open WebUI group add for %s", cloudron_user_id)
return False
try:
async with httpx.AsyncClient(timeout=15.0) as client:
# find the OWUI user (SSO `sub` = Cloudron uid); if they've never
# logged in, the user row may not exist yet — the nightly sync
# covers it, and group-add by uid also works after first login.
r = await client.get(
f"{OWUI_BASE}/api/v1/users/",
headers={"Authorization": f"Bearer {OWUI_API_KEY}"},
params={"query": cloudron_user_id},
)
if r.status_code != 200:
logger.warning("OWUI user lookup failed: %s %s", r.status_code, r.text[:150])
return False
payload = r.json() or {}
users = payload.get("users", []) if isinstance(payload, dict) else (payload or [])
owui_uid = None
for u in users:
if u.get("id") == cloudron_user_id:
owui_uid = u["id"]
break
if not owui_uid:
# user hasn't logged in yet — they'll be added to the group by
# the nightly sync after first login. Not an error.
logger.info("OWUI: no user row yet for %s (not logged in); nightly sync will add", cloudron_user_id)
return False
r = await client.post(
f"{OWUI_BASE}/api/v1/groups/id/{OWUI_MEMBERS_GROUP_ID}/users/add",
headers={"Authorization": f"Bearer {OWUI_API_KEY}"},
json={"user_ids": [owui_uid]},
)
if r.status_code == 200:
logger.info("OWUI: added %s to members group", cloudron_user_id)
return True
# 400 "already in group" is fine
logger.warning("OWUI group add for %s: %s %s", cloudron_user_id, r.status_code, r.text[:150])
return False
except Exception as e:
logger.warning("OWUI group add failed for %s: %s", cloudron_user_id, e)
return False
# Open WebUI was RETIRED 2026-11-13: the app is stopped (com.openwebui.cloudronapp,
# installed|stopped) and its "members group" lived inside Open WebUI's own
# database, never in Cloudron. A stopped container has no DNS entry, so every
# call failed with 'Temporary failure in name resolution' and no new member
# ever reached the group. Nothing here may call out to it.
async def cloudron_update_profile(user_id: str, email: str, display_name: str, fallback_email: str = "") -> None:
"""Update a user's profile (display name, email) after creation.
@@ -2746,15 +2690,6 @@ async def provision_member(email: str, name: str, slug: str = "") -> str:
balance = get_member_balance(email)
team_id = await litellm_get_or_create_team(email, balance)
# Pre-provision the member into Open WebUI's docs-RAG access group so their
# FIRST chat session has the co-op docs. Best-effort (most new members
# haven't logged in yet, so the OWUI user row doesn't exist — the nightly
# refresh catches them after first login).
try:
await owui_add_to_members_group(user_id)
except Exception as e:
logger.warning("OWUI members-group add skipped for %s: %s", email, e)
# Reuse an existing key if we already have one (the sk- value is stored in
# our DB at creation time and is the authoritative token for this member's
# chat key). Only mint a fresh key when there is none.
@@ -3160,10 +3095,6 @@ async def convert_guest_to_member(email: str, name: str, slug: str = "") -> str:
logger.warning("Guest convert: reset pin failed for %s: %s", email, e)
# 4. Full member onboarding — the pieces the guest path skipped.
try:
await owui_add_to_members_group(user_id)
except Exception as e:
logger.warning("Guest convert: OWUI group add skipped for %s: %s", email, e)
await listmonk_sync(email, subscribe=True)
try:
conn = get_db()
@@ -4563,21 +4494,10 @@ async def inject_key(request: Request, path: str):
# Verify the request came through the chat frontend, so a direct caller
# can't spoof the user-email header and use another member's key.
#
# Two supported auth paths:
# 1. OpenWebUI signs the user identity as a JWT (X-OpenWebUI-User-Jwt)
# with a shared secret — the email is tamper-proof, so no separate
# secret header is needed.
# 2. LibreChat sends a plain X-User-Email header plus an X-Portal-Secret
# shared-secret header.
email = ""
jwt_header = request.headers.get("x-openwebui-user-jwt", "")
if jwt_header and OWUI_JWT_SECRET:
try:
claims = jwt.decode(jwt_header, OWUI_JWT_SECRET, algorithms=["HS256"])
email = claims.get("email", "")
except jwt.PyJWTError:
raise HTTPException(401, "Invalid user identity token")
else:
# ONE auth path: LibreChat sends a plain X-User-Email header plus an
# X-Portal-Secret shared-secret header. OpenWebUI's signed-JWT path was
# retired with the app (2026-11-13) — honouring a shared-secret-signed token
# for an integration nobody runs is auth surface with no user.
_verify_portal_secret(request)
email = (
request.headers.get("x-user-email", "")