Kanboard
Kanboard 是一个使用看板的自托管项目管理工具。其 OAuth2 插件 通过通用 OAuth 2.0 提供商对用户进行身份验证。将 Casdoor 作为提供商后,用户可以使用其 Casdoor 账户登录 Kanboard。
安装 OAuth2 插件
- 通过以下任一方式安装插件:
- 在 Kanboard 中,打开 Settings > Plugins > Plugin Directory 并安装 OAuth2。Web 安装程序需要在
config.php中将PLUGIN_INSTALLER设置为true,需要一个 Web 服务器可写的plugins目录,以及 PHP Zip 扩展。 - 下载插件并将其解压到 Kanboard 目录中的
plugins/OAuth2。目录名称区分大小写。
- 在 Kanboard 中,打开 Settings > Plugins > Plugin Directory 并安装 OAuth2。Web 安装程序需要在
- 确保 Settings > Application settings > Application URL 是 Kanboard 的公共 URL,例如
https://kanboard.example.com/。插件会从此 URL 构建回调 URL。
在 Casdoor 中创建应用
-
在 Kanboard 中,转到 Settings > Integrations > OAuth2 Authentication,并复制 Callback URL。如果启用了 URL 重写,则为:
https://kanboard.example.com/oauth/callback如果没有启用 URL 重写,则为
https://kanboard.example.com/?controller=OAuthController&action=handler&plugin=OAuth2。 -
在 Casdoor 管理控制台中,打开你的用户所属的组织并添加一个应用,或打开现有应用。
-
将回调 URL 添加到 Redirect URLs。
-
保存,并记下 Client ID 和 Client secret。
配置 OAuth2 插件
-
在 Kanboard 中,转到 Settings > Integrations > OAuth2 Authentication,并填写字段:
Field Value Client ID <your-client-id>Client Secret <your-client-secret>Authorize URL https://door.example.com/login/oauth/authorizeToken URL https://door.example.com/api/login/oauth/access_tokenUser API URL https://door.example.com/api/userinfoScopes openid profile emailUsername Key preferred_usernameName Key nameEmail Key emailUser ID Key subAllow Account Creation On <your-client-id>,<your-client-secret>:来自 Casdoor 应用的值。- User API URL:Casdoor 的 UserInfo 端点。对于
profile范围,它返回sub(Casdoor 用户 ID)、preferred_username(用户名)和name(显示名称);对于email范围,它返回email。 - User ID Key:Kanboard 将此值与 Kanboard 用户关联。当用户在 Casdoor 中重命名时,
sub不会改变。 - Allow Account Creation:在首次登录时创建 Kanboard 用户。如果不启用此选项,只有已链接账户的用户才能登录。
-
单击保存。
同步 Casdoor 群组
UserInfo 端点还会在 groups 中返回用户的群组。要根据这些群组创建 Kanboard 群组:
- 在 Casdoor 应用中,在 OIDC/OAuth 选项卡上,将 Token group format 设置为
Name (group),这样群组将以developers而不是my-org/developers的形式传递。 - 在插件设置中,将 Groups Key 设置为
groups。如果只想使用部分群组,请在 Group Filter 中以逗号分隔列出它们。
链接现有的 Kanboard 用户
Kanboard 通过存储的 User ID Key 值查找回归用户,而不是通过用户名或电子邮件。与 Casdoor 用户具有相同用户名的现有 Kanboard 用户在账户链接之前无法使用 Casdoor 登录:
- 用户使用密码登录 Kanboard,打开其个人资料的外部账户,然后单击 Link OAuth2 account。
- 或者,管理员在用户身份验证设置的 OAuth2 ID 字段中输入 Casdoor 用户 ID,即
sub值。
验证结果
- 在浏览器隐私窗口中打开 Kanboard。登录页面显示 OAuth2 login。
- 点击它并登录 Casdoor。Kanboard 将以登录的 Casdoor 用户身份打开。
故障排除
| Symptom | Cause and fix |
|---|---|
Kanboard shows External authentication failed | The user isn't linked yet and Allow Account Creation is off, or a Kanboard user with the same username exists. Turn on account creation, or link the user. |
Casdoor shows Redirect URI: ... doesn't exist in the allowed Redirect URI list | Application URL in Kanboard is wrong, often still http://localhost/. Fix it, and add the Callback URL of the plugin to Redirect URLs. |
| The username, name, or email of new users is empty | Scopes lacks profile or email, or the application's Token fields list leaves the fields out. Casdoor returns only the fields in that list from the UserInfo endpoint. |
You use https://door.example.com/api/get-account as User API URL | That endpoint returns the user inside data. Use the UserInfo endpoint instead, as shown above. |
另请参阅
- plugin-oauth2 on GitHub
- OAuth 2.0