https://auth.example.com 请换成你的 Casdoor 地址(Casdoor 云上类似 https://acme.casdoor.com),其他 example.com 地址也换成你自己的。用 Casdoor 配置 Gitea
- 1
在 Casdoor 中注册 Gitea
在 Casdoor 控制台打开 应用,为 Gitea 添加一个应用,在它的 OIDC/OAuth 标签页复制 客户端ID 和 客户端密钥。把下面的地址加到 重定向URLs:
https://git.example.com/user/oauth2/Casdoor/callback
Casdoorin the path is the authentication source name in the next step; the two must match, including case. 要用群组的话,先在应用所属的组织里创建群组(例如gitea-admins)并加入用户,再在同一个标签页把 Token 中的群组格式 设成 Name,这样令牌里是gitea-admins,而不是<组织>/gitea-admins。 - 2
Add the authentication source
Run this on the Gitea server (with Docker, prefix it with
docker exec -u git <container>), or fill in the same values under Site Administration → Authentication Sources with OAuth2 and the OpenID Connect provider.gitea admin auth add-oauth \ --name Casdoor \ --provider openidConnect \ --key "<client ID>" \ --secret "<client secret>" \ --auto-discover-url https://auth.example.com/.well-known/openid-configuration \ --scopes "profile email" \ --group-claim-name groups \ --admin-group gitea-admins - 3
Sign in
The Gitea sign-in page now has a Sign in with Casdoor button. On first sign-in, users register a new Gitea account or link an existing one. Members of
gitea-adminsbecome Gitea administrators.
注意事项
- To skip the registration form and create accounts straight away, set
ENABLE_AUTO_REGISTRATION = truein the[oauth2_client]section ofapp.ini.
Gitea 的设置取自它的官方文档(核对于 2026年10月:Gitea command line);另见Casdoor 文档。Gitea 是其所有者的商标。
常见问题
Does this work with Forgejo?
Forgejo keeps Gitea's OAuth2 authentication sources, so the same settings apply; check the Forgejo documentation for the exact command name.
Can I require Casdoor for everyone?
Yes. Once your users have linked Casdoor, turn off password sign-in in Gitea's [service] settings so the Casdoor button is the way in.
更多应用集成
查看全部Argo CD
应用集成Connect Argo CD to Casdoor over OpenID Connect: oidc.config in argocd-cm, the client secret, PKCE, CLI login and RBAC from Casdoor groups.
GitLab
应用集成Configure self-managed GitLab to sign users in with Casdoor over OpenID Connect: gitlab.rb provider settings, account creation and group-based admins.
Grafana
应用集成Set up Grafana single sign-on with Casdoor over OpenID Connect: Generic OAuth settings, PKCE, and Grafana roles mapped from Casdoor groups.
