跳到主内容

Kanboard

Kanboard 是一个使用看板的自托管项目管理工具。其 OAuth2 插件 通过通用 OAuth 2.0 提供商对用户进行身份验证。将 Casdoor 作为提供商后,用户可以使用其 Casdoor 账户登录 Kanboard。

安装 OAuth2 插件​

  1. 通过以下任一方式安装插件:
    • 在 Kanboard 中,打开 Settings > Plugins > Plugin Directory 并安装 OAuth2。Web 安装程序需要在 config.php 中将 PLUGIN_INSTALLER 设置为 true,需要一个 Web 服务器可写的 plugins 目录,以及 PHP Zip 扩展。
    • 下载插件并将其解压到 Kanboard 目录中的 plugins/OAuth2。目录名称区分大小写。
  2. 确保 Settings > Application settings > Application URL 是 Kanboard 的公共 URL,例如 https://kanboard.example.com/。插件会从此 URL 构建回调 URL。

在 Casdoor 中创建应用​

  1. 在 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。

  2. 在 Casdoor 管理控制台中,打开你的用户所属的组织并添加一个应用,或打开现有应用。

  3. 将回调 URL 添加到 Redirect URLs。

  4. 保存,并记下 Client ID 和 Client secret。

配置 OAuth2 插件​

  1. 在 Kanboard 中,转到 Settings > Integrations > OAuth2 Authentication,并填写字段:

    FieldValue
    Client ID<your-client-id>
    Client Secret<your-client-secret>
    Authorize URLhttps://door.example.com/login/oauth/authorize
    Token URLhttps://door.example.com/api/login/oauth/access_token
    User API URLhttps://door.example.com/api/userinfo
    Scopesopenid profile email
    Username Keypreferred_username
    Name Keyname
    Email Keyemail
    User ID Keysub
    Allow Account CreationOn
    • <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 用户。如果不启用此选项,只有已链接账户的用户才能登录。
  2. 单击保存。

同步 Casdoor 群组​

UserInfo 端点还会在 groups 中返回用户的群组。要根据这些群组创建 Kanboard 群组:

  1. 在 Casdoor 应用中,在 OIDC/OAuth 选项卡上,将 Token group format 设置为 Name (group),这样群组将以 developers 而不是 my-org/developers 的形式传递。
  2. 在插件设置中,将 Groups Key 设置为 groups。如果只想使用部分群组,请在 Group Filter 中以逗号分隔列出它们。

Kanboard 通过存储的 User ID Key 值查找回归用户,而不是通过用户名或电子邮件。与 Casdoor 用户具有相同用户名的现有 Kanboard 用户在账户链接之前无法使用 Casdoor 登录:

  • 用户使用密码登录 Kanboard,打开其个人资料的外部账户,然后单击 Link OAuth2 account。
  • 或者,管理员在用户身份验证设置的 OAuth2 ID 字段中输入 Casdoor 用户 ID,即 sub 值。

验证结果​

  1. 在浏览器隐私窗口中打开 Kanboard。登录页面显示 OAuth2 login。
  2. 点击它并登录 Casdoor。Kanboard 将以登录的 Casdoor 用户身份打开。

故障排除​

SymptomCause and fix
Kanboard shows External authentication failedThe 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 listApplication 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 emptyScopes 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 URLThat endpoint returns the user inside data. Use the UserInfo endpoint instead, as shown above.

另请参阅​