Casdoor集成市场

GitLab | 应用集成

GitLab 单点登录

Self-managed GitLab signs users in through OmniAuth providers, including any OpenID Connect provider. With Casdoor as the provider, developers use one account for GitLab and the rest of your tools.

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

用 Casdoor 配置 GitLab

  1. 1

    在 Casdoor 中注册 GitLab

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

    • https://gitlab.example.com/users/auth/openid_connect/callback
  2. 2

    Add Casdoor to gitlab.rb

    GitLab only talks to OpenID providers over HTTPS, so serve Casdoor over HTTPS. Add this to /etc/gitlab/gitlab.rb and run sudo gitlab-ctl reconfigure.

    gitlab_rails['omniauth_allow_single_sign_on'] = ['openid_connect']
    gitlab_rails['omniauth_block_auto_created_users'] = false
    gitlab_rails['omniauth_providers'] = [
      {
        name: "openid_connect",
        label: "Casdoor",
        args: {
          name: "openid_connect",
          scope: ["openid", "profile", "email"],
          response_type: "code",
          issuer: "https://auth.example.com",
          discovery: true,
          client_auth_method: "query",
          uid_field: "sub",
          pkce: true,
          client_options: {
            identifier: "<client ID>",
            secret: "<client secret>",
            redirect_uri: "https://gitlab.example.com/users/auth/openid_connect/callback"
          }
        }
      }
    ]
  3. 3

    Map Casdoor groups (GitLab Premium and Ultimate)

    To make members of a Casdoor group GitLab administrators, or to mark contractors as external users, add a gitlab block inside client_options. Set the Casdoor application's Token group format to Name so the values match.

    gitlab: {
      groups_attribute: "groups",
      admin_groups: ["gitlab-admins"],
      external_groups: ["contractors"]
    }
  4. 4

    Sign in

    The sign-in page now has a Casdoor button. People who already have a GitLab account can connect Casdoor under User settings → Account → Service sign-in.

注意事项

  • omniauth_allow_single_sign_on lets GitLab create an account on first sign-in, and omniauth_block_auto_created_users = false lets new users in without waiting for an administrator to approve them.
  • uid_field: "sub" ties each GitLab identity to the Casdoor user ID, which doesn't change when a user is renamed.

GitLab 的设置取自它的官方文档(核对于 2026年10月:GitLab OpenID Connect);另见Casdoor 文档。GitLab 是其所有者的商标。

常见问题

Do I need GitLab Premium?

Not for single sign-on: any self-managed GitLab can use Casdoor as its OpenID Connect provider. Rules based on OIDC group membership (required, external and admin groups) need GitLab Premium or Ultimate.

I compiled GitLab from source. Where do the settings go?

Put the same provider settings under omniauth in config/gitlab.yml; GitLab's OpenID Connect documentation shows that format next to the gitlab.rb one.