Casdoor集成市场

Gitea | 应用集成

Gitea 单点登录

Gitea signs users in through OAuth2 authentication sources, including OpenID Connect providers. Add Casdoor as one, and developers sign in to your Git server with their Casdoor account.

Casdoor 官方核验OIDC按群组设管理员
你需要一个正在运行的 Casdoor,自己部署或用 Casdoor 云都可以。示例中的 https://auth.example.com 请换成你的 Casdoor 地址(Casdoor 云上类似 https://acme.casdoor.com),其他 example.com 地址也换成你自己的。

用 Casdoor 配置 Gitea

  1. 1

    在 Casdoor 中注册 Gitea

    在 Casdoor 控制台打开 应用,为 Gitea 添加一个应用,在它的 OIDC/OAuth 标签页复制 客户端ID 和 客户端密钥。把下面的地址加到 重定向URLs:

    • https://git.example.com/user/oauth2/Casdoor/callback

    Casdoor in 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. 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. 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-admins become Gitea administrators.

注意事项

  • To skip the registration form and create accounts straight away, set ENABLE_AUTO_REGISTRATION = true in the [oauth2_client] section of app.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.