https://auth.example.com 请换成你的 Casdoor 地址(Casdoor 云上类似 https://acme.casdoor.com),其他 example.com 地址也换成你自己的。用 Casdoor 配置 authentik
- 1
创建应用
在 authentik 管理界面打开 Applications → Applications,点 New Application。填上名称,slug 设为
casdoor,提供商类型选 OAuth2/OpenID Connect。 - 2
配置提供商
在提供商这一步,客户端类型保持 confidential(机密),添加一个 strict(严格匹配)的重定向 URI,并选一个签名密钥:
Client type Confidential Redirect URIs Strict: https://auth.example.com/callback Signing Key authentik Self-signed Certificate (or your own) - 3
复制凭据
完成向导后打开这个提供商,复制它的 Client ID 和 Client Secret。
- 4
在 Casdoor 中添加 authentik 提供商
在 Casdoor 控制台打开 提供商,点击 添加,填写:
类别 OAuth 类型 OIDC 显示名称 authentik 客户端ID <client ID> 客户端密钥 <client secret> Issuer链接 https://authentik.example.com/application/o/casdoor/ 认证URL https://authentik.example.com/application/o/authorize/ Token链接 https://authentik.example.com/application/o/token/ 范围 openid profile email UserInfo链接 https://authentik.example.com/application/o/userinfo/ 登出URL https://authentik.example.com/application/o/casdoor/end-session/ 启用PKCE 开启 点击 Issuer链接 旁边的 请求,会从 authentik 的 discovery 文档自动填好其余地址。同一个组织里所有 OIDC 类型的提供商都通过同一个字段关联用户,所以如果这个组织已经有一个 OIDC 提供商,请把 类型 改成 Custom Flexible,它按提供商分别关联账号。
- 5
把提供商加到应用上
打开 应用,编辑用户登录的那个应用,在它的 提供商 标签页添加这个提供商。之后登录页上就会出现 authentik 按钮。
注意事项
- authentik 提供商的 issuer 包含应用 slug,并以斜杠结尾,例如
https://authentik.example.com/application/o/casdoor/。Casdoor 会拿它和 token 里的 issuer 比较,所以 slug 必须一致。 - 一定要选签名密钥。不选的话,authentik 会用客户端密钥签名 token,也不会公开任何公钥。
- 从 authentik 2025.10 起,除非你改了 email scope 的映射,否则
email_verified为 false,Casdoor 收到的邮箱会是未验证状态。
authentik 的设置取自它的官方文档(核对于 2026年10月:authentik OAuth2 provider)。authentik 是其所有者的商标。
常见问题
Casdoor 提示 issuer 不匹配,为什么?
检查 slug 和末尾的斜杠。如果把提供商的 issuer 模式设成了 global,issuer 就是 https://authentik.example.com/,把它填到 Casdoor 里这个提供商的“Issuer链接”中。
需要打开 Include claims in id_token 吗?
不需要。Casdoor 还会调用 authentik 的 userinfo 端点,它会返回 profile 和 email 声明。
更多提供商
查看全部Authelia
让用户通过 Authelia 用 OpenID Connect 登录 Casdoor:包括提供商配置,以及要加到 Authelia 配置里的客户端。

超星学习通
让师生用超星学习通账号登录 Casdoor:按超星微服务开放平台的 OAuth 接口填好了授权、换取 access_token 和获取用户信息的地址。
GitLab Self-Managed
让用户用你自建 GitLab 上的账号通过 OpenID Connect 登录 Casdoor:包括提供商配置,以及要在 GitLab 里创建的 OAuth 应用。
