SafeLine WAF
长亭科技开发的 SafeLine (雷池) 是一款自托管 Web 应用防火墙 (WAF)。它可以在以下两个位置通过 OpenID Connect (OIDC) 提供商进行用户登录:
- 身份认证 (identity authentication) 会在 SafeLine 保护的应用程序前显示一个登录页面。从 SafeLine 8.6.0 版本开始,所有版本均支持 OIDC。
- 控制台登录方式 (console sign-in method) 用于管理员登录 SafeLine 控制台。从 SafeLine 9.0.0 版本开始支持 OIDC,且仅适用于商业版 (commercial license)。
这两处配置是独立的,且在 Casdoor 中需要各自配置重定向 URL。由于 SafeLine 控制台界面为中文,本页会显示其中文标签及对应的翻译。
在 Casdoor 中创建应用
-
在 Casdoor 管理控制台中,打开你的用户所属的组织,添加一个新应用,或打开现有应用。
-
将 SafeLine 的回调地址添加到 Redirect URLs 中,包括每个使用登录功能的受保护应用的域名,以及如果你使用了统一认证门户 (统一认证),还需包含其域名:
https://app.example.com/.safeline/auth/api/callback/oidc -
保存,并记下 Client ID 和 Client secret。
登录受保护的应用程序
-
在 SafeLine 控制台中,前往 身份认证 (identity authentication) > 配置 (configuration) > 登录配置 (sign-in configuration),并展开 第三方登录配置 (third-party sign-in) 中的 OIDC 条目。
-
填写设置项:
Setting Value OIDC 服务器 URL (OIDC server URL) https://door.example.comClient ID <your-client-id>Client Secret <your-client-secret>标题名称 (title) Casdoor, or keep the default- OIDC 服务器 URL: Casdoor 的地址。SafeLine 会在其后追加
.well-known/openid-configuration以查找端点。 <your-client-id>,<your-client-secret>: 来自 Casdoor 应用的值。- 自动关联账号 (link accounts automatically): 可选。将 Casdoor 用户与具有相同电子邮件地址或电话号码的现有 SafeLine 用户进行关联。
- OIDC 服务器 URL: Casdoor 的地址。SafeLine 会在其后追加
-
保存,并在每个受保护应用的设置中,在 身份认证 下的 登录方式 (sign-in methods) 中启用 OIDC。
首次登录的用户需等待管理员在 身份认证 > 用户管理 (user management) 中批准,除非应用程序允许用户在登录后立即访问 (认证后直接访问)。
登录 SafeLine 控制台
这需要 SafeLine 9.0.0 或更高版本,并且拥有商业许可证。
-
在 SafeLine 控制台中,前往 通用设置 (general settings) > 控制台管理 (console management) > 控制台用户管理 (console users) > 登录方式 (sign-in method),选择 OIDC。旧版本位于 系统设置 (system settings) > 控制台用户管理 下。
-
复制页面上显示的 应用回调地址 (application callback URL),并将其添加到 Casdoor 应用的 Redirect URLs 中。若要使用 测试登录 (test sign-in),还需添加附加了
/test的相同 URL。 -
填写 OIDC 服务器 URL (
https://door.example.com)、Client ID 和 Client Secret。 -
在 用户角色映射关系 (role mapping) 中添加行,以赋予 Casdoor 用户控制台角色:
Column Value 角色所属 Scope (scope of the role) profile用户角色参数 (claim) groups参数值 (value) The name of a Casdoor group, for example waf-admins控制台角色 (console role) 超级管理, 配置管理, or 系统管理 (super, configuration, or system administrator) Casdoor 在
groups声明中发送用户的群组信息。在 Casdoor 应用中,于 OIDC/OAuth 选项卡下,将 Token group format 设置为Name (group),这样值将是waf-admins而不是my-org/waf-admins。 -
点击 测试登录,并使用属于已映射群组的用户登录 Casdoor。
-
点击 确定 (OK)。
当你提交 OIDC 配置时,SafeLine 会删除现有的控制台账户并将你注销。此后,管理员只能通过 Casdoor 登录控制台。请先测试登录功能。
验证结果
- 在隐私浏览窗口中打开一个受保护的应用程序。SafeLine 会显示带有 OIDC 按钮的登录页面。
- 点击该按钮并登录 Casdoor。SafeLine 会让用户通过,或者在首次登录后,等待管理员批准该用户。
故障排除
| Symptom | Cause and fix |
|---|---|
Casdoor shows Redirect URI: ... doesn't exist in the allowed Redirect URI list | Add the URL from the error to Redirect URLs. Each protected domain, the unified sign-in portal, and the console have their own callback. |
| The Client Secret is empty after saving | A bug of SafeLine before 9.3.11. Upgrade SafeLine. |
当切换到 OIDC 时,统一登录门户(统一认证)显示 未知错误: Cannot read properties of null (reading 'auth_url') | SafeLine 的一个已知 issue:chaitin/SafeLine#1273。Casdoor 的 discovery document 并非导致此问题的原因:在相同配置下它可以正常加载。 |
| An unknown error appears after the user returns from Casdoor, and reloading the page signs the user in | An open SafeLine issue, chaitin/SafeLine#1244. |
| No console role is assigned | The value in 参数值 differs from the group in the token. Check Token group format and the user's groups in Casdoor. |
另请参阅
- 身份认证 - OIDC in the SafeLine documentation
- 控制台登录方式 - OIDC in the SafeLine documentation
- 令牌概述