Open WebUI
Open WebUI 是一个用于本地和托管大语言模型的自托管聊天界面。它可以通过任何 OpenID Connect (OIDC) 提供商对用户进行身份验证。以 Casdoor 作为提供商,用户使用其 Casdoor 账户登录,并且 Casdoor 群组决定他们可以看到哪些模型、知识库和工具。
在 Casdoor 中创建应用
-
在 Casdoor 管理控制台中,打开你的用户所在的组织并添加一个应用,或者打开一个现有的应用。
-
将 Open WebUI 的回调地址添加到 Redirect URLs:
https://chat.example.com/oauth/oidc/callback -
在 OIDC/OAuth 选项卡上,将 Token group format 设置为
Name (group),这样群组将以engineering而不是my-org/engineering的形式传递。 -
保存,并记下 Client ID 和 Client secret。
配置 Open WebUI
-
在 Open WebUI 容器上设置以下环境变量:
WEBUI_URL=https://chat.example.com
ENABLE_OAUTH_SIGNUP=true
DEFAULT_USER_ROLE=user
OAUTH_PROVIDER_NAME=Casdoor
OAUTH_CLIENT_ID=<your-client-id>
OAUTH_CLIENT_SECRET=<your-client-secret>
OPENID_PROVIDER_URL=https://door.example.com/.well-known/openid-configuration
OAUTH_SCOPES=openid email profile
ENABLE_OAUTH_GROUP_MANAGEMENT=true
OAUTH_GROUP_CLAIM=groupsWEBUI_URL:Open WebUI 的公开 URL。回调 URL 基于此构建。DEFAULT_USER_ROLE:新用户的角色。默认值pending要求管理员对每一个用户进行批准。OPENID_PROVIDER_URL:Casdoor 的发现文档 (discovery document)。ENABLE_OAUTH_GROUP_MANAGEMENT:在每次登录时,将用户的 Open WebUI 组与groups声明进行同步。
-
重启 Open WebUI。
验证结果
- 在私密浏览器窗口中打开 Open WebUI。登录页面会显示 Continue with Casdoor。
- 点击它并登录 Casdoor。Open WebUI 将以登录的 Casdoor 用户身份打开。
- 作为 Open WebUI 管理员,打开用户列表。新用户已被添加到与其 Casdoor 组匹配的组中。
Open WebUI 仅将用户添加到已存在于 Open WebUI 中的组。请先创建这些组,或设置 ENABLE_OAUTH_GROUP_CREATION=true 以在登录时创建它们。
故障排除
| Symptom | Cause and fix |
|---|---|
| New users wait for approval | DEFAULT_USER_ROLE is pending. Set it to user, or approve the users in the admin panel. |
Casdoor shows Redirect URI: ... doesn't exist in the allowed Redirect URI list | WEBUI_URL differs from the address in Redirect URLs. Make them match. |
| The OAuth settings in the admin panel can't be changed | By default, the environment variables are the source of truth for OAuth. Change the variables and restart. |
| An existing local user gets a second account | Set OAUTH_MERGE_ACCOUNTS_BY_EMAIL=true to sign them in to the account with the same email. |
另请参阅
- SSO in the Open WebUI documentation
- SSO troubleshooting in the Open WebUI documentation