Help us learn about your current experience with the documentation. Take the survey.

使用 Atlassian 作为 OAuth 2.0 认证提供商

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab Self-Managed

要启用 Atlassian OmniAuth 提供商以实现无密码认证,您必须在 Atlassian 注册一个应用程序。

Atlassian 应用注册

  1. 前往 Atlassian developer console,并使用用于管理该应用的 Atlassian 账户登录。
  2. 选择 创建新应用
  3. 选择一个应用名称,例如 ‘GitLab’,然后选择 创建
  4. 记下 Client IDSecret,以备 GitLab 配置 步骤使用。
  5. 在左侧边栏的 API 和功能 下,选择 OAuth 2.0 (3LO)
  6. 输入 GitLab 回调 URL,格式为 https://gitlab.example.com/users/auth/atlassian_oauth2/callback,然后选择 保存更改
  7. 在左侧边栏的 API 和功能 下,选择 + 添加
  8. Jira platform REST API 选择 添加,然后选择 配置
  9. 在以下范围 (scope) 旁边选择 添加
    • 查看 Jira 问题数据
    • 查看用户资料
    • 创建和管理问题

GitLab 配置

  1. 在您的 GitLab 服务器上,打开配置文件:

    对于 Linux 包安装:

    sudo editor /etc/gitlab/gitlab.rb

    对于自编译安装:

    sudo -u git -H editor /home/git/gitlab/config/gitlab.yml
  2. 配置 通用设置,以将 atlassian_oauth2 添加为单点登录 (SSO) 提供商。这将为没有现有 GitLab 账户的用户启用即时 (Just-In-Time) 账户配置功能。

  3. 为 Atlassian 添加提供商配置:

    对于 Linux 包安装:

    gitlab_rails['omniauth_providers'] = [
      {
        name: "atlassian_oauth2",
        # label: "Provider name", # optional label for login button, defaults to "Atlassian"
        app_id: "<your_client_id>",
        app_secret: "<your_client_secret>",
        args: { scope: "offline_access read:jira-user read:jira-work", prompt: "consent" }
      }
    ]

    对于自编译安装:

    - { name: "atlassian_oauth2",
        # label: "Provider name", # optional label for login button, defaults to "Atlassian"
        app_id: "<your_client_id>",
        app_secret: "<your_client_secret>",
        args: { scope: "offline_access read:jira-user read:jira-work", prompt: "consent" }
     }
  4. <your_client_id><your_client_secret> 更改为您在 应用注册 期间收到的客户端凭据。

  5. 保存配置文件。

  6. 要使更改生效:

现在,登录页面的常规登录表单下方应该会出现一个 Atlassian 图标。选择该图标即可开始认证流程。

如果一切顺利,用户将使用其 Atlassian 凭据登录到 GitLab。