From 6cd9d49b627dabbf915b875efc0f1002eba6736f Mon Sep 17 00:00:00 2001 From: spektr Date: Wed, 11 Nov 2026 06:46:01 +0100 Subject: [PATCH] M6: open_webui-Rolle OIDC-vorbereitet (Keycloak gnai-openwebui, WEBUI_URL chat.*, Client-Secret als Podman-Secret) Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- .../roles/open_webui/defaults/main.yml | 13 ++++++++ .../ansible/roles/open_webui/tasks/main.yml | 30 +++++++++++++++++++ .../templates/open-webui.container.j2 | 10 +++++++ 3 files changed, 53 insertions(+) diff --git a/llm-server/llm/ansible/roles/open_webui/defaults/main.yml b/llm-server/llm/ansible/roles/open_webui/defaults/main.yml index 6a617ee..97ebe39 100644 --- a/llm-server/llm/ansible/roles/open_webui/defaults/main.yml +++ b/llm-server/llm/ansible/roles/open_webui/defaults/main.yml @@ -34,6 +34,19 @@ open_webui_container_port: 8080 # Persistent app data (SQLite DB, uploads, cache). open_webui_data_dir: /var/lib/ghostnet-ai/production/openwebui-data +# OIDC phase (M6 public route via NPM + Keycloak). Disabled for the +# internal phase; enable together with the Keycloak client +# `gnai-openwebui` and the NPM proxy host chat.ghostnet.selfhost.eu. +# The client secret is created as a Podman secret by the operator (the +# Keycloak-generated value never enters git): +# runuser -u gnai-production -- podman secret create \ +# openwebui-oidc-client-secret - +open_webui_oidc_enabled: false +open_webui_oidc_client_id: gnai-openwebui +open_webui_oidc_client_secret_secret: openwebui-oidc-client-secret +open_webui_oidc_provider_url: https://auth.ghostnet.selfhost.eu/realms/Ghost.net/.well-known/openid-configuration +open_webui_public_url: https://chat.ghostnet.selfhost.eu + # Internal phase: local auth with first-user-is-admin. The public OIDC # phase (M6 route) switches ENABLE_OAUTH_* on and disables local signup. open_webui_env: diff --git a/llm-server/llm/ansible/roles/open_webui/tasks/main.yml b/llm-server/llm/ansible/roles/open_webui/tasks/main.yml index 9aa44c8..ba498c4 100644 --- a/llm-server/llm/ansible/roles/open_webui/tasks/main.yml +++ b/llm-server/llm/ansible/roles/open_webui/tasks/main.yml @@ -122,6 +122,36 @@ when: open_webui_engine_secret_exists.rc == 1 no_log: true +- name: Check whether the OIDC client secret exists (required when OIDC is enabled) + ansible.builtin.command: + argv: + - /usr/sbin/runuser + - --user + - "{{ open_webui_user }}" + - -- + - /usr/bin/env + - "HOME={{ open_webui_home }}" + - "XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }}" + - /usr/bin/podman + - secret + - exists + - "{{ open_webui_oidc_client_secret_secret }}" + chdir: "{{ open_webui_home }}" + changed_when: false + failed_when: false + check_mode: false + register: open_webui_oidc_secret_exists + +- name: Require the OIDC client secret when OIDC is enabled + ansible.builtin.fail: + msg: >- + open_webui_oidc_enabled=true requires the Podman secret + {{ open_webui_oidc_client_secret_secret }} (operator creates it from + the Keycloak client secret, never in git). + when: + - open_webui_oidc_enabled | bool + - open_webui_oidc_secret_exists.rc != 0 + - name: Render the OpenWebUI quadlet ansible.builtin.template: src: open-webui.container.j2 diff --git a/llm-server/llm/ansible/roles/open_webui/templates/open-webui.container.j2 b/llm-server/llm/ansible/roles/open_webui/templates/open-webui.container.j2 index fd66ce3..5e0c81b 100644 --- a/llm-server/llm/ansible/roles/open_webui/templates/open-webui.container.j2 +++ b/llm-server/llm/ansible/roles/open_webui/templates/open-webui.container.j2 @@ -16,6 +16,16 @@ Secret={{ open_webui_engine_api_key_secret }},type=env,target=OPENAI_API_KEY {% for key, value in open_webui_env.items() %} Environment={{ key }}={{ value }} {% endfor %} +{% if open_webui_oidc_enabled %} +Environment=WEBUI_URL={{ open_webui_public_url }} +Environment=ENABLE_OAUTH_SIGNUP=True +Environment=ENABLE_SIGNUP=False +Environment=OPENID_PROVIDER_URL={{ open_webui_oidc_provider_url }} +Environment=OAUTH_CLIENT_ID={{ open_webui_oidc_client_id }} +Environment=OAUTH_SCOPES=openid email profile +Environment=OAUTH_PROVIDER_NAME=Keycloak +Secret={{ open_webui_oidc_client_secret_secret }},type=env,target=OAUTH_CLIENT_SECRET +{% endif %} [Service] Restart=on-failure -- 2.54.0