正式なドキュメントは英語版であり、この日本語訳はAI支援翻訳により作成された参考用のものです。日本語訳の一部の内容は人間によるレビューがまだ行われていないため、翻訳のタイミングにより英語版との間に差異が生じることがあります。最新かつ正確な情報については、英語版をご参照ください。

GitLab Self-ManagedのSAML SSO

  • プラン: Free、Premium、Ultimate
  • 提供形態: GitLab Self-Managed

GitLab.comについては、GitLab.comグループのSAML SSOを参照してください。

このページでは、GitLab Self-Managedにおいてインスタンス全体のSAMLシングルサインオン(SSO)を設定する方法について説明します。

SAMLサービスプロバイダー(SP)として機能するようにGitLabを設定できます。これによりGitLabは、OktaなどのSAML Identity Provider(IdP)が発行したアサーションを利用して、ユーザーを認証できます。

詳細については、次を参照してください:

  • OmniAuthプロバイダーの設定については、OmniAuthのドキュメントを参照してください。
  • 一般的に使用される用語については、用語集を参照してください。

GitLabでSAMLのサポートを設定する

  1. GitLabでHTTPSが設定されていることを確認してください。

  2. 共通設定で、samlをシングルサインオンプロバイダーとして追加します。これにより、既存のGitLabアカウントを持たないユーザーに対して、Just-In-Timeアカウントプロビジョニングが有効になります。

  3. ユーザーが最初に手動でアカウントを作成しなくてもSAMLを使用してサインアップできるようにするには、/etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_allow_single_sign_on'] = ['saml']
    gitlab_rails['omniauth_block_auto_created_users'] = false
  4. オプション。初回にSAMLでサインインする際に、SAML応答のメールアドレスが既存のGitLabユーザーと一致する場合、これらを自動的にリンクする必要があります。これを行うには、/etc/gitlab/gitlab.rbに次の設定を追加します:

    gitlab_rails['omniauth_auto_link_saml_user'] = true

    SAML応答のメールアドレスと照合されるのは、GitLabアカウントのプライマリメールアドレスのみです。

    または、ユーザーが既存のユーザーに対してOmniAuthを有効にすることで、SAMLアイデンティティを既存のGitLabアカウントに手動でリンクすることも可能です。

  5. 次の属性を設定し、SAMLユーザーがこれらを変更できないようにします:

    • NameID
    • Emailomniauth_auto_link_saml_userと併用する場合)。

    ユーザーがこれらの属性を変更できる場合、他の認証済みユーザーとしてサインインできてしまいます。これらの属性を変更不可にする方法については、SAML IdPのドキュメントを参照してください。

  6. /etc/gitlab/gitlab.rbを編集し、プロバイダー設定を追加します:

    gitlab_rails['omniauth_providers'] = [
      {
        name: "saml", # This must be lowercase.
        label: "Provider name", # optional label for login button, defaults to "Saml"
        args: {
          assertion_consumer_service_url: "https://gitlab.example.com/users/auth/saml/callback",
          idp_cert_fingerprint: "2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6",
          idp_sso_target_url: "https://login.example.com/idp",
          issuer: "https://gitlab.example.com",
          name_identifier_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
        }
      }
    ]
    引数説明
    assertion_consumer_service_urlGitLab HTTPSエンドポイント(GitLabインストールのHTTPS URLに/users/auth/saml/callbackを付加します)。
    idp_cert_fingerprintIdPの値。証明書からSHA256フィンガープリントを生成するには、フィンガープリントを計算するを参照してください。
    idp_sso_target_urlIdPの値。
    issuerIdPがアプリケーションを識別できるように一意の名前に変更します。
    name_identifier_formatIdPの値。

    これらの値の詳細については、OmniAuth SAMLのドキュメントを参照してください。その他の設定項目の詳細については、IdPでSAMLを設定するを参照してください。

  7. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. GitLabでHTTPSが設定されていることを確認してください。

  2. 共通設定で、samlをシングルサインオンプロバイダーとして追加します。これにより、既存のGitLabアカウントを持たないユーザーに対して、Just-In-Timeアカウントプロビジョニングが有効になります。

  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. ユーザーが最初に手動でアカウントを作成しなくてもSAMLを使用してサインアップできるようにするには、gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          enabled: true
          allowSingleSignOn: ['saml']
          blockAutoCreatedUsers: false
  5. オプション。gitlab_values.yamlに次の設定を追加すると、SAMLユーザーと既存のGitLabユーザーのメールアドレスが一致する場合に、両者を自動的にリンクできます:

    global:
      appConfig:
        omniauth:
          autoLinkSamlUser: true

    または、ユーザーが既存のユーザーに対してOmniAuthを有効にすることで、SAMLアイデンティティを既存のGitLabアカウントに手動でリンクすることも可能です。

  6. 次の属性を設定し、SAMLユーザーがこれらを変更できないようにします:

    • NameID
    • Emailomniauth_auto_link_saml_userと併用する場合)。

    ユーザーがこれらの属性を変更できる場合、他の認証済みユーザーとしてサインインできてしまいます。これらの属性を変更不可にする方法については、SAML IdPのドキュメントを参照してください。

  7. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Provider name' # optional label for login button, defaults to "Saml"
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
    引数説明
    assertion_consumer_service_urlGitLab HTTPSエンドポイント(GitLabインストールのHTTPS URLに/users/auth/saml/callbackを付加します)。
    idp_cert_fingerprintIdPの値。証明書からSHA256フィンガープリントを生成するには、フィンガープリントを計算するを参照してください。
    idp_sso_target_urlIdPの値。
    issuerIdPがアプリケーションを識別できるように一意の名前に変更します。
    name_identifier_formatIdPの値。

    これらの値の詳細については、OmniAuth SAMLのドキュメントを参照してください。その他の設定項目の詳細については、IdPでSAMLを設定するを参照してください。

  8. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  9. gitlab_values.yamlを編集し、プロバイダー設定を追加します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  10. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. GitLabでHTTPSが設定されていることを確認してください。

  2. 共通設定で、samlをシングルサインオンプロバイダーとして追加します。これにより、既存のGitLabアカウントを持たないユーザーに対して、Just-In-Timeアカウントプロビジョニングが有効になります。

  3. ユーザーが最初に手動でアカウントを作成しなくてもSAMLを使用してサインアップできるようにするには、docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_allow_single_sign_on'] = ['saml']
            gitlab_rails['omniauth_block_auto_created_users'] = false
  4. オプション。docker-compose.ymlに次の設定を追加すると、SAMLユーザーと既存のGitLabユーザーのメールアドレスが一致する場合に、両者を自動的にリンクできます:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_auto_link_saml_user'] = true

    または、ユーザーが既存のユーザーに対してOmniAuthを有効にすることで、SAMLアイデンティティを既存のGitLabアカウントに手動でリンクすることも可能です。

  5. 次の属性を設定し、SAMLユーザーがこれらを変更できないようにします:

    • NameID
    • Emailomniauth_auto_link_saml_userと併用する場合)。

    ユーザーがこれらの属性を変更できる場合、他の認証済みユーザーとしてサインインできてしまいます。これらの属性を変更不可にする方法については、SAML IdPのドキュメントを参照してください。

  6. docker-compose.ymlを編集し、プロバイダー設定を追加します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
              {
                name: "saml",
                label: "Provider name", # optional label for login button, defaults to "Saml"
                args: {
                  assertion_consumer_service_url: "https://gitlab.example.com/users/auth/saml/callback",
                  idp_cert_fingerprint: "2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6",
                  idp_sso_target_url: "https://login.example.com/idp",
                  issuer: "https://gitlab.example.com",
                  name_identifier_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
                }
              }
            ]
    引数説明
    assertion_consumer_service_urlGitLab HTTPSエンドポイント(GitLabインストールのHTTPS URLに/users/auth/saml/callbackを付加します)。
    idp_cert_fingerprintIdPの値。証明書からSHA256フィンガープリントを生成するには、フィンガープリントを計算するを参照してください。
    idp_sso_target_urlIdPの値。
    issuerIdPがアプリケーションを識別できるように一意の名前に変更します。
    name_identifier_formatIdPの値。

    これらの値の詳細については、OmniAuth SAMLのドキュメントを参照してください。その他の設定項目の詳細については、IdPでSAMLを設定するを参照してください。

  7. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. GitLabでHTTPSが設定されていることを確認してください。

  2. 共通設定で、samlをシングルサインオンプロバイダーとして追加します。これにより、既存のGitLabアカウントを持たないユーザーに対して、Just-In-Timeアカウントプロビジョニングが有効になります。

  3. ユーザーが最初に手動でアカウントを作成しなくてもSAMLを使用してサインアップできるようにするには、/home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        enabled: true
        allow_single_sign_on: ["saml"]
        block_auto_created_users: false
  4. オプション。/home/git/gitlab/config/gitlab.ymlに次の設定を追加すると、SAMLユーザーと既存のGitLabユーザーのメールアドレスが一致する場合に、両者を自動的にリンクできます:

    production: &base
      omniauth:
        auto_link_saml_user: true

    または、ユーザーが既存のユーザーに対してOmniAuthを有効にすることで、SAMLアイデンティティを既存のGitLabアカウントに手動でリンクすることも可能です。

  5. 次の属性を設定し、SAMLユーザーがこれらを変更できないようにします:

    • NameID
    • Emailomniauth_auto_link_saml_userと併用する場合)。

    ユーザーがこれらの属性を変更できる場合、他の認証済みユーザーとしてサインインできてしまいます。これらの属性を変更不可にする方法については、SAML IdPのドキュメントを参照してください。

  6. /home/git/gitlab/config/gitlab.ymlを編集し、プロバイダー設定を追加します:

    omniauth:
      providers:
        - {
          name: 'saml',
          label: 'Provider name', # optional label for login button, defaults to "Saml"
          args: {
            assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
            idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
            idp_sso_target_url: 'https://login.example.com/idp',
            issuer: 'https://gitlab.example.com',
            name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
          }
        }
    引数説明
    assertion_consumer_service_urlGitLab HTTPSエンドポイント(GitLabインストールのHTTPS URLに/users/auth/saml/callbackを付加します)。
    idp_cert_fingerprintIdPの値。証明書からSHA256フィンガープリントを生成するには、フィンガープリントを計算するを参照してください。
    idp_sso_target_urlIdPの値。
    issuerIdPがアプリケーションを識別できるように一意の名前に変更します。
    name_identifier_formatIdPの値。

    これらの値の詳細については、OmniAuth SAMLのドキュメントを参照してください。その他の設定項目の詳細については、IdPでSAMLを設定するを参照してください。

  7. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

SAML IdPにGitLabを登録する

  1. issuerで指定されたアプリケーション名を使用して、SAML IdPにGitLabのSPを登録します。

  2. IdPに設定情報を提供するには、アプリケーションのメタデータURLを作成します。GitLabのメタデータURLを作成するには、GitLabインストールのHTTPS URLにusers/auth/saml/metadataを付加します。次に例を示します:

    https://gitlab.example.com/users/auth/saml/metadata

    IdPは最低限、emailまたはmailを使用して、ユーザーのメールアドレスを含むクレームを提供するmust(必要があります)。その他の利用可能なクレームの詳細については、アサーションを設定するを参照してください。

  3. サインインページでは、標準のサインインフォームの下にSAMLのアイコンが表示されているはずです。そのアイコンを選択すると、認証プロセスが開始されます。認証に成功すると、GitLabに戻り、サインインした状態になります。

IdPでSAMLを設定する

IdPでSAMLアプリケーションを設定するには、少なくとも次の情報が必要です:

設定例については、Identity Providerを設定するを参照してください。

IdPによっては追加の設定が必要になる場合があります。詳細については、IdPにおけるSAMLアプリ用の追加の設定を参照してください。

複数のSAML IdPを使用するようにGitLabを設定する

次の条件を満たす場合、複数のSAML IdPを使用するようにGitLabを設定できます:

  • 各プロバイダーに、argsに指定された名前と一致する、一意の名前が設定されている。
  • プロバイダー名を次のように使用している:
    • OmniAuthの設定で、プロバイダー名に基づいてプロパティを設定している。例: allowBypassTwoFactorallowSingleSignOnsyncProfileFromProvider
    • プロバイダー名を使用して、既存の各ユーザーに追加のIDとして関連付けている。
  • assertion_consumer_service_urlがプロバイダー名と一致している。
  • strategy_classが明示的に設定されている(プロバイダー名からは推測できないため)。

複数のSAML IdPを設定する場合、SAMLグループのリンクを適切に機能させるには、SAML応答にグループ属性が含まれるように、すべてのSAML IdPを設定する必要があります。詳細については、SAMLグループのリンクを参照してください。

複数のSAML IdPを設定するには、次の手順に従います:

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      {
        name: 'saml', # This must match the following name configuration parameter
        label: 'Provider 1' # Differentiate the two buttons and providers in the UI
        args: {
                name: 'saml', # This is mandatory and must match the provider name
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback', # URL must match the name of the provider
                strategy_class: 'OmniAuth::Strategies::SAML',
                # Include all required arguments similar to a single provider
              },
      },
      {
        name: 'saml_2', # This must match the following name configuration parameter
        label: 'Provider 2' # Differentiate the two buttons and providers in the UI
        args: {
                name: 'saml_2', # This is mandatory and must match the provider name
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml_2/callback', # URL must match the name of the provider
                strategy_class: 'OmniAuth::Strategies::SAML',
                # Include all required arguments similar to a single provider
              },
      }
    ]

    ユーザーがいずれかのプロバイダーから手動でアカウントを作成することなく、SAMLを使用してサインアップできるようにするには、次の値を設定に追加します:

    gitlab_rails['omniauth_allow_single_sign_on'] = ['saml', 'saml_2']
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、最初のSAMLプロバイダーのKubernetes Secretとして使用します:

    name: 'saml' # At least one provider must be named 'saml'
    label: 'Provider 1' # Differentiate the two buttons and providers in the UI
    args:
      name: 'saml' # This is mandatory and must match the provider name
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback' # URL must match the name of the provider
      strategy_class: 'OmniAuth::Strategies::SAML' # Mandatory
      # Include all required arguments similar to a single provider
  2. 次の内容をsaml_2.yamlファイルに記述し、2番目のSAMLプロバイダーのKubernetes Secretとして使用します:

    name: 'saml_2'
    label: 'Provider 2' # Differentiate the two buttons and providers in the UI
    args:
      name: 'saml_2' # This is mandatory and must match the provider name
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml_2/callback' # URL must match the name of the provider
      strategy_class: 'OmniAuth::Strategies::SAML' # Mandatory
      # Include all required arguments similar to a single provider
  3. オプション。同じ手順に従って、追加のSAMLプロバイダーを設定します。

  4. Kubernetes Secretsを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml \
       --from-file=saml=saml.yaml \
       --from-file=saml_2=saml_2.yaml
  5. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  6. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
              key: saml
            - secret: gitlab-saml
              key: saml_2

    ユーザーがいずれかのプロバイダーから手動でアカウントを作成することなく、SAMLを使用してサインアップできるようにするには、次の値を設定に追加します:

    global:
      appConfig:
        omniauth:
          allowSingleSignOn: ['saml', 'saml_2']
  7. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_allow_single_sign_on'] = ['saml', 'saml1']
            gitlab_rails['omniauth_providers'] = [
              {
                name: 'saml', # This must match the following name configuration parameter
                label: 'Provider 1' # Differentiate the two buttons and providers in the UI
                args: {
                        name: 'saml', # This is mandatory and must match the provider name
                        assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback', # URL must match the name of the provider
                        strategy_class: 'OmniAuth::Strategies::SAML',
                        # Include all required arguments similar to a single provider
                      },
              },
              {
                name: 'saml_2', # This must match the following name configuration parameter
                label: 'Provider 2' # Differentiate the two buttons and providers in the UI
                args: {
                        name: 'saml_2', # This is mandatory and must match the provider name
                        assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml_2/callback', # URL must match the name of the provider
                        strategy_class: 'OmniAuth::Strategies::SAML',
                        # Include all required arguments similar to a single provider
                      },
              }
            ]

    ユーザーがいずれかのプロバイダーから手動でアカウントを作成することなく、SAMLを使用してサインアップできるようにするには、次の値を設定に追加します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_allow_single_sign_on'] = ['saml', 'saml_2']
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - {
            name: 'saml', # This must match the following name configuration parameter
            label: 'Provider 1' # Differentiate the two buttons and providers in the UI
            args: {
              name: 'saml', # This is mandatory and must match the provider name
              assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback', # URL must match the name of the provider
              strategy_class: 'OmniAuth::Strategies::SAML',
              # Include all required arguments similar to a single provider
            },
          }
          - {
            name: 'saml_2', # This must match the following name configuration parameter
            label: 'Provider 2' # Differentiate the two buttons and providers in the UI
            args: {
              name: 'saml_2', # This is mandatory and must match the provider name
              strategy_class: 'OmniAuth::Strategies::SAML',
              assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml_2/callback', # URL must match the name of the provider
              # Include all required arguments similar to a single provider
            },
          }

    ユーザーがいずれかのプロバイダーから手動でアカウントを作成することなく、SAMLを使用してサインアップできるようにするには、次の値を設定に追加します:

    production: &base
      omniauth:
        allow_single_sign_on: ["saml", "saml_2"]
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

Identity Providerを設定する

GitLabはSAMLをサポートしているため、広範なIdPを通じてGitLabにサインインすることが可能です。

GitLabは、OktaやGoogle WorkspaceのIdPの設定に関する次の情報をガイダンスとして提供しています。いずれかのIdPの設定についてご不明な点がある場合は、各プロバイダーのサポートにお問い合わせください。

Oktaを設定する

  1. Oktaの管理者セクションで、アプリケーションを選択します。
  2. アプリ画面で、Create App Integration(アプリ統合を作成)を選択し、次の画面でSAML 2.0を選択します。
  3. オプション。GitLab Pressからロゴを選択して追加します。ロゴをトリミングしてサイズを変更する必要があります。
  4. SAMLの一般設定を入力します。次の項目を設定します:
    • "Single sign-on URL": アサーションコンシューマサービスURLを使用します。
    • "Audience URI": 発行者を使用します。
    • NameID
    • アサーション
  5. フィードバックセクションで、自分が顧客であり、内部使用のためにアプリを作成していることを入力します。
  6. 新しいアプリのプロファイルの上部で、SAML 2.0 configuration instructions(SAML 2.0設定手順)を選択します。
  7. Identity Provider Single Sign-On URL(アイデンティティプロバイダのシングルサインオンURL)をメモします。このURLは、GitLab設定ファイルのidp_sso_target_urlに使用します。
  8. Oktaからサインアウトする前に、ユーザーとグループ(存在する場合)を必ず追加してください。

Google Workspaceを設定する

前提要件:

Google Workspaceを設定するには、次の手順に従います:

  1. 次の情報を使用し、Google WorkspaceでカスタムSAMLアプリを設定する手順に従います。

    一般的な値説明
    SAMLアプリの名前GitLab他の名前でもかまいません。
    ACS URLhttps://<GITLAB_DOMAIN>/users/auth/saml/callbackアサーションコンシューマサービスURL。
    GITLAB_DOMAINgitlab.example.comGitLabインスタンスのドメイン。
    エンティティIDhttps://gitlab.example.comSAMLアプリケーションに固有の値。この値は、GitLabの設定でissuerに指定します。
    名前IDの形式EMAIL必須の値です。name_identifier_formatとしても知られています。
    名前IDプライマリーメールアドレスお使いのメールアドレス。そのアドレス宛てに送信された内容を受信できることを確認してください。
    お名前(名)first_nameお名前(名)。GitLabと通信するために必須の値です。
    お名前(姓)last_nameお名前(姓)。GitLabと通信するために必須の値です。
  2. 次のSAML属性マッピングを設定します:

    Googleディレクトリの属性アプリケーションの属性
    Basic information(基本情報) > Email(メールアドレス)email
    Basic information(基本情報) > お名前(名)first_name
    基本情報 > お名前(姓)last_name

    この情報の一部は、GitLabでSAMLのサポートを設定する際に使用する場合があります。

Google Workspace SAMLアプリケーションを設定する際に、次の情報を記録しておいてください:

説明
SSO URL環境により異なるGoogle Identity Providerの詳細。GitLabのidp_sso_target_url設定に指定します。
証明書ダウンロード可能Google SAML証明書。
SHA256フィンガープリント環境により異なる証明書をダウンロードすると利用できます。証明書からSHA256フィンガープリントを生成するには、フィンガープリントを計算するを参照してください。

Google Workspace管理者は、IdPメタデータ、エンティティID、SHA-256フィンガープリントも提供します。ただし、GitLabがGoogle Workspace SAMLアプリケーションに接続するために、これらの情報は必要ありません。

Microsoft Entra IDを設定する

  1. Microsoft Entra管理センターにサインインします。

  2. ギャラリー以外のアプリケーションを作成します。

  3. そのアプリケーションのSSOを設定します。

    gitlab.rbファイル内の次の設定は、Microsoft Entra IDのフィールドに対応しています:

    gitlab.rbの設定Microsoft Entra IDフィールド
    issuerIdentifier (Entity ID)(識別子(エンティティID))
    assertion_consumer_service_urlReply URL (Assertion Consumer Service URL)(応答URL(アサーションコンシューマサービスURL))
    idp_sso_target_urlLogin URL(Login URL(ログインURL))
    idp_cert_fingerprintThumbprint(Thumbprint(サムプリント))
  4. 次の属性を設定します:

詳細については、設定例のページを参照してください。

他のIdPを設定する

一部のIdPには、SAML設定でIdPとして使用する方法に関するドキュメントが用意されています。次に例を示します:

SAML設定におけるIdPの設定方法についてご不明な点がある場合は、各プロバイダーのサポートにお問い合わせください。

アサーションを設定する

  • 提供形態: GitLab.com、GitLab Self-Managed

これらの属性は大文字と小文字が区別されます。

フィールドサポートされているデフォルトキー
メール(必須)emailmailhttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddresshttp://schemas.microsoft.com/ws/2008/06/identity/claims/emailaddresshttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailhttp://schemas.microsoft.com/ws/2008/06/identity/claims/emailurn:oid:0.9.2342.19200300.100.1.3
フルネームnamehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/namehttp://schemas.microsoft.com/ws/2008/06/identity/claims/nameurn:oid:2.16.840.1.113730.3.1.241urn:oid:2.5.4.3
お名前(名)first_namefirstnamefirstNamehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/givennamehttp://schemas.microsoft.com/ws/2008/06/identity/claims/givennameurn:oid:2.5.4.42
お名前(姓)last_namelastnamelastNamehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/surnamehttp://schemas.microsoft.com/ws/2008/06/identity/claims/surnameurn:oid:2.5.4.4

GitLabがSAML SSOプロバイダーからSAML応答を受信すると、GitLabは属性のnameフィールドで次の値を検索します:

  • "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"
  • "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname"
  • "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
  • firstname
  • lastname
  • email

GitLabがSAML応答を解析できるように、これらの値を属性のNameフィールドに正しく含める必要があります。たとえば、GitLabは次のようなSAML応答のスニペットを解析できます:

  • これは、Name属性が前の表にある必須値のいずれかに設定されているため、受け入れられます。

             <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname">
                 <AttributeValue>Alvin</AttributeValue>
             </Attribute>
             <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname">
                 <AttributeValue>Test</AttributeValue>
             </Attribute>
             <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress">
                 <AttributeValue>alvintest@example.com</AttributeValue>
             </Attribute>
  • これは、Name属性が前の表にある値の1つと一致するため、受け入れられます。

             <Attribute Name="firstname">
                 <AttributeValue>Alvin</AttributeValue>
             </Attribute>
             <Attribute Name="lastname">
                 <AttributeValue>Test</AttributeValue>
             </Attribute>
             <Attribute Name="email">
                 <AttributeValue>alvintest@example.com</AttributeValue>
             </Attribute>

ただし、GitLabは次のSAML応答スニペットを解析できません:

  • これは、Name属性の値が前の表にあるサポート対象の値のいずれでもないため、受け入れられません。

             <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/firstname">
                 <AttributeValue>Alvin</AttributeValue>
             </Attribute>
             <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/lastname">
                 <AttributeValue>Test</AttributeValue>
             </Attribute>
             <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/mail">
                 <AttributeValue>alvintest@example.com</AttributeValue>
             </Attribute>
  • これは、FriendlyNameにサポート対象の値が設定されていても、Name属性にサポート対象外の値が設定されているため、失敗します。

             <Attribute FriendlyName="firstname" Name="urn:oid:2.5.4.42">
                 <AttributeValue>Alvin</AttributeValue>
             </Attribute>
             <Attribute FriendlyName="lastname" Name="urn:oid:2.5.4.4">
                 <AttributeValue>Test</AttributeValue>
             </Attribute>
             <Attribute FriendlyName="email" Name="urn:oid:0.9.2342.19200300.100.1.3">
                 <AttributeValue>alvintest@example.com</AttributeValue>
             </Attribute>

以下については、attribute_statementsを参照してください。:

  • カスタムアサーション設定の例。
  • カスタムユーザー名属性を設定する方法。

サポート対象のアサーションの完全なリストについては、gem OmniAuth SAMLを参照してください

SAMLグループメンバーシップに基づいてユーザーを設定する

次のことが可能です:

  • ユーザーが特定のグループのメンバーであることを必須にする。
  • グループメンバーシップに基づいて、ユーザーに外部 、管理者、監査担当者のいずれかのロールを割り当てる。

GitLabは、SAMLサインインのたびにこれらのグループをチェックし、必要に応じてユーザー属性を更新します。ただし、この機能では、GitLabグループにユーザーを自動的に追加することはdoes not(できません)。

これらのグループのサポートは、以下に依存します:

グループプランGitLab Enterprise Edition(EE)のみか?
必須Free、Premium、Ultimateはい
外部Free、Premium、Ultimateいいえ
管理者Free、Premium、Ultimateはい
監査担当者Premium、Ultimateはい

前提要件:

  • グループ情報がどこにあるかを、GitLabに指示する必要があります。そのためには、IdPサーバーが標準のSAML応答とともに特定のAttributeStatementを送信するように設定してください。次に例を示します:

    <saml:AttributeStatement>
      <saml:Attribute Name="Groups">
        <saml:AttributeValue xsi:type="xs:string">Developers</saml:AttributeValue>
        <saml:AttributeValue xsi:type="xs:string">Freelancers</saml:AttributeValue>
        <saml:AttributeValue xsi:type="xs:string">Admins</saml:AttributeValue>
        <saml:AttributeValue xsi:type="xs:string">Auditors</saml:AttributeValue>
      </saml:Attribute>
    </saml:AttributeStatement>

    属性の名前には、ユーザーが所属しているグループを含める必要があります。これらのグループがある場所をGitLabに指示するには、SAML設定にgroups_attribute:要素を追加します。この属性は大文字と小文字が区別されます。

必須グループ

IdPは、SAML応答でグループ情報をGitLabに渡します。この応答を使用するには、以下を識別できるようにGitLabを設定します:

  • SAML応答内でグループがある場所(groups_attribute設定を使用)。
  • グループまたはユーザーに関する情報(グループ設定を使用)。

required_groups設定を使用して、サインインに必要なグループメンバーシップをGitLabが識別できるようにします。

required_groupsを設定しない場合、または設定を空のままにしている場合は、適切に認証されたユーザーであれば誰でもこのサービスを使用できます。

groups_attributeで指定された属性が誤っているか存在しない場合、すべてのユーザーがブロックされます。

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      { name: 'saml',
        label: 'Our SAML Provider',
        groups_attribute: 'Groups',
        required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
        }
      }
    ]
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    groups_attribute: 'Groups'
    required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors']
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
  2. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  5. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
               { name: 'saml',
                 label: 'Our SAML Provider',
                 groups_attribute: 'Groups',
                 required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
                 args: {
                         assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                         idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                         idp_sso_target_url: 'https://login.example.com/idp',
                         issuer: 'https://gitlab.example.com',
                         name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
                 }
               }
            ]
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - { name: 'saml',
              label: 'Our SAML Provider',
              groups_attribute: 'Groups',
              required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
              args: {
                      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                      idp_sso_target_url: 'https://login.example.com/idp',
                      issuer: 'https://gitlab.example.com',
                      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
              }
            }
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

外部グループ

IdPは、SAML応答でグループ情報をGitLabに渡します。この応答を使用するには、以下を識別できるようにGitLabを設定します:

  • SAML応答内でグループがある場所(groups_attribute設定を使用)。
  • グループまたはユーザーに関する情報(グループ設定を使用)。

SAMLは、external_groups設定に基づいて、ユーザーを外部ユーザーとして自動的に識別できます。

groups_attributeで指定された属性が誤っているか存在しない場合、ユーザーは標準ユーザーとしてアクセスします。

設定例:

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
    
      { name: 'saml',
        label: 'Our SAML Provider',
        groups_attribute: 'Groups',
        external_groups: ['Freelancers'],
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                # or
                # idp_cert: '-----BEGIN CERTIFICATE-----\n ... \n-----END CERTIFICATE-----',
    
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
        }
      }
    ]
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    groups_attribute: 'Groups'
    external_groups: ['Freelancers']
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      # or
      # idp_cert: '-----BEGIN CERTIFICATE-----\n ... \n-----END CERTIFICATE-----',
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
  2. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  5. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
              { name: 'saml',
                label: 'Our SAML Provider',
                groups_attribute: 'Groups',
                external_groups: ['Freelancers'],
                args: {
                        assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                        idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                        idp_sso_target_url: 'https://login.example.com/idp',
                        issuer: 'https://gitlab.example.com',
                        name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
                }
              }
            ]
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
           - { name: 'saml',
               label: 'Our SAML Provider',
               groups_attribute: 'Groups',
               external_groups: ['Freelancers'],
               args: {
                       assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                       idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                       idp_sso_target_url: 'https://login.example.com/idp',
                       issuer: 'https://gitlab.example.com',
                       name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
               }
             }
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

管理者グループ

IdPは、SAML応答でグループ情報をGitLabに渡します。この応答を使用するには、以下を識別できるようにGitLabを設定します:

  • SAML応答内でグループがある場所(groups_attribute設定を使用)。
  • グループまたはユーザーに関する情報(グループ設定を使用)。

admin_groups設定を使用して、ユーザーに管理者アクセス権を付与するグループをGitLabが識別できるようにします。

groups_attributeで指定された属性が誤っているか存在しない場合、ユーザーは管理者アクセス権を失います。

設定例:

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      { name: 'saml',
        label: 'Our SAML Provider',
        groups_attribute: 'Groups',
        admin_groups: ['Admins'],
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                # or
                # idp_cert: '-----BEGIN CERTIFICATE-----\n ... \n-----END CERTIFICATE-----',
    
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
        }
      }
    ]
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    groups_attribute: 'Groups'
    admin_groups: ['Admins']
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
  2. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  5. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
               { name: 'saml',
                 label: 'Our SAML Provider',
                 groups_attribute: 'Groups',
                 admin_groups: ['Admins'],
                 args: {
                         assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                         idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                         idp_sso_target_url: 'https://login.example.com/idp',
                         issuer: 'https://gitlab.example.com',
                         name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
                 }
               }
            ]
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - { name: 'saml',
              label: 'Our SAML Provider',
              groups_attribute: 'Groups',
              admin_groups: ['Admins'],
              args: {
                      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                      idp_sso_target_url: 'https://login.example.com/idp',
                      issuer: 'https://gitlab.example.com',
                      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
              }
            }
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

監査担当者グループ

  • プラン: Premium、Ultimate
  • 提供形態: GitLab Self-Managed、GitLab Dedicated

IdPは、SAML応答でグループ情報をGitLabに渡します。この応答を使用するには、以下を識別できるようにGitLabを設定します:

  • SAML応答内でグループがある場所(groups_attribute設定を使用)。
  • グループまたはユーザーに関する情報(グループ設定を使用)。

auditor_groups設定を使用して、監査担当者アクセス権を持つユーザーを含むグループをGitLabが識別できるようにします。

groups_attributeで指定された属性が誤っているか存在しない場合、ユーザーは監査担当者アクセス権を失います。

設定例:

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      { name: 'saml',
        label: 'Our SAML Provider',
        groups_attribute: 'Groups',
        auditor_groups: ['Auditors'],
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
        }
      }
    ]
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    groups_attribute: 'Groups'
    auditor_groups: ['Auditors']
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
  2. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  5. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
               { name: 'saml',
                 label: 'Our SAML Provider',
                 groups_attribute: 'Groups',
                 auditor_groups: ['Auditors'],
                 args: {
                         assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                         idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                         idp_sso_target_url: 'https://login.example.com/idp',
                         issuer: 'https://gitlab.example.com',
                         name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
                 }
               }
            ]
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - { name: 'saml',
              label: 'Our SAML Provider',
              groups_attribute: 'Groups',
              auditor_groups: ['Auditors'],
              args: {
                      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                      idp_sso_target_url: 'https://login.example.com/idp',
                      issuer: 'https://gitlab.example.com',
                      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
              }
            }
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

SAMLグループ同期を自動的に管理する

GitLabグループメンバーシップの自動管理については、SAMLグループ同期を参照してください。

SAMLセッションのタイムアウトをカスタマイズする

デフォルトでは、GitLabのSAMLセッションは24時間後に終了します。SAML2 AuthnStatementのSessionNotOnOrAfter属性を使用して、この期間をカスタマイズできます。この属性には、ユーザーセッションを終了するタイミングを示すISO 8601タイムスタンプ値が含まれています。指定された場合、この値はSAMLセッションのデフォルトのタイムアウト(24時間)をオーバーライドします。

インスタンスにカスタムsession duration(セッション時間)が設定されており、それがSessionNotOnOrAfterタイムスタンプよりも以前である場合、ユーザーはGitLabユーザーセッションの終了時に再度認証する必要があります。

2要素認証を回避する

セッション単位で2要素認証(2FA)としてカウントするようにSAML認証方法を設定するには、upstream_two_factor_authn_contextsリストにその方式を登録します。

  1. IdPがAuthnContextを返すようになっていることを確認してください。次に例を示します:

    <saml:AuthnStatement>
        <saml:AuthnContext>
            <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:MediumStrongCertificateProtectedTransport</saml:AuthnContextClassRef>
        </saml:AuthnContext>
    </saml:AuthnStatement>
  2. インストール設定を編集し、upstream_two_factor_authn_contextsリストにSAML認証方法を登録します。SAML応答に含まれているAuthnContextを入力する必要があります。

    1. /etc/gitlab/gitlab.rbを編集します:

      gitlab_rails['omniauth_providers'] = [
        { name: 'saml',
          label: 'Our SAML Provider',
          args: {
                  assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                  idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                  idp_sso_target_url: 'https://login.example.com/idp',
                  issuer: 'https://gitlab.example.com',
                  name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                  upstream_two_factor_authn_contexts:
                    %w(
                      urn:oasis:names:tc:SAML:2.0:ac:classes:CertificateProtectedTransport
                      urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorOTPSMS
                      urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorIGTOKEN
                    ),
          }
        }
      ]
    2. ファイルを保存して、GitLabを再設定します:

      sudo gitlab-ctl reconfigure
    1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

      name: 'saml'
      label: 'Our SAML Provider'
      args:
        assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
        idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
        idp_sso_target_url: 'https://login.example.com/idp'
        issuer: 'https://gitlab.example.com'
        name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
        upstream_two_factor_authn_contexts:
          - 'urn:oasis:names:tc:SAML:2.0:ac:classes:CertificateProtectedTransport'
          - 'urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorOTPSMS'
          - 'urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorIGTOKEN'
    2. Kubernetes Secretを作成します:

      kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
    3. Helm値をエクスポートします:

      helm get values gitlab > gitlab_values.yaml
    4. gitlab_values.yamlを編集します:

      global:
        appConfig:
          omniauth:
            providers:
              - secret: gitlab-saml
    5. ファイルを保存し、新しい値を適用します:

      helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
    1. docker-compose.ymlを編集します:

      version: "3.6"
      services:
        gitlab:
          environment:
            GITLAB_OMNIBUS_CONFIG: |
              gitlab_rails['omniauth_providers'] = [
                 { name: 'saml',
                   label: 'Our SAML Provider',
                   args: {
                           assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                           idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                           idp_sso_target_url: 'https://login.example.com/idp',
                           issuer: 'https://gitlab.example.com',
                           name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
                           upstream_two_factor_authn_contexts:
                             %w(
                               urn:oasis:names:tc:SAML:2.0:ac:classes:CertificateProtectedTransport
                               urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorOTPSMS
                               urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorIGTOKEN
                             )
                   }
                 }
              ]
    2. ファイルを保存して、GitLabを再起動します:

      docker compose up -d
    1. /home/git/gitlab/config/gitlab.ymlを編集します:

      production: &base
        omniauth:
          providers:
            - { name: 'saml',
                label: 'Our SAML Provider',
                args: {
                        assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                        idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                        idp_sso_target_url: 'https://login.example.com/idp',
                        issuer: 'https://gitlab.example.com',
                        name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
                        upstream_two_factor_authn_contexts:
                          [
                            'urn:oasis:names:tc:SAML:2.0:ac:classes:CertificateProtectedTransport',
                            'urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorOTPSMS',
                            'urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorIGTOKEN'
                          ]
                }
              }
    2. ファイルを保存して、GitLabを再起動します:

      # For systems running systemd
      sudo systemctl restart gitlab.target
      
      # For systems running SysV init
      sudo service gitlab restart

応答署名を検証する

IdPは、アサーションが改ざんされていないことを保証するために、SAMLレスポンスに署名する必要があります。

これにより、特定のグループメンバーシップが必要な場合に、ユーザーの代理および権限昇格を防止できます。

idp_cert_fingerprintを使用する

idp_cert_fingerprintを使用して、レスポンス署名の検証を設定できます。設定例を以下に示します:

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      { name: 'saml',
        label: 'Our SAML Provider',
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
        }
      }
    ]
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
  2. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  5. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
               { name: 'saml',
                 label: 'Our SAML Provider',
                 args: {
                         assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                         idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                         idp_sso_target_url: 'https://login.example.com/idp',
                         issuer: 'https://gitlab.example.com',
                         name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
                 }
               }
            ]
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - { name: 'saml',
              label: 'Our SAML Provider',
              args: {
                      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                      idp_sso_target_url: 'https://login.example.com/idp',
                      issuer: 'https://gitlab.example.com',
                      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
              }
            }
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

idp_certを使用する

idp_certを使用して、GitLabを直接設定することもできます。設定例を以下に示します:

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      { name: 'saml',
        label: 'Our SAML Provider',
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert: '-----BEGIN CERTIFICATE-----
                  <redacted>
                  -----END CERTIFICATE-----',
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
        }
      }
    ]
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert: |
        -----BEGIN CERTIFICATE-----
        <redacted>
        -----END CERTIFICATE-----
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
  2. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  5. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
               { name: 'saml',
                 label: 'Our SAML Provider',
                 args: {
                         assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                         idp_cert: '-----BEGIN CERTIFICATE-----
                           <redacted>
                           -----END CERTIFICATE-----',
                         idp_sso_target_url: 'https://login.example.com/idp',
                         issuer: 'https://gitlab.example.com',
                         name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
                 }
               }
            ]
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - { name: 'saml',
              label: 'Our SAML Provider',
              args: {
                      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                      idp_cert: '-----BEGIN CERTIFICATE-----
                        <redacted>
                        -----END CERTIFICATE-----',
                      idp_sso_target_url: 'https://login.example.com/idp',
                      issuer: 'https://gitlab.example.com',
                      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
              }
            }
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

応答署名検証が正しく設定されていない場合は、次のようなエラーメッセージが表示されることがあります:

  • キー検証エラー。
  • ダイジェストの不一致。
  • フィンガープリントの不一致。

これらのエラーの解決方法については、SAMLのトラブルシューティングガイドを参照してください。

SAML設定をカスタマイズする

認証のためにユーザーをSAMLサーバーにリダイレクトする

GitLabの設定にauto_sign_in_with_providerを付加すると、認証のためにSAMLサーバーに自動的にリダイレクトできます。これにより、実際にサインインする前に要素を選択する必要がなくなります。

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_auto_sign_in_with_provider'] = 'saml'
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  2. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          autoSignInWithProvider: 'saml'
  3. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_auto_sign_in_with_provider'] = 'saml'
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        auto_sign_in_with_provider: 'saml'
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

すべてのサインイン試行がSAMLサーバーにリダイレクトされるため、ローカル認証情報を使用してサインインすることはできません。SAMLユーザーのうち少なくとも1人が管理者アクセス権を持っていることを確認してください。

自動サインイン設定を回避するには、サインインURLに?auto_sign_in=falseを付加します。例: https://gitlab.example.com/users/sign_in?auto_sign_in=false

SAMLレスポンス属性名をマップする

  • プラン: Free、Premium、Ultimate
  • 提供形態: GitLab Self-Managed、GitLab Dedicated

attribute_statementsを使用すると、SAML応答の属性名をOmniAuthのinfoハッシュエントリにマップできます。

この設定は、OmniAuthのinfoハッシュスキーマに含まれる属性をマップする場合にのみ使用してください。

たとえば、SAMLResponseEmailAddressという属性が含まれている場合は、{ email: ['EmailAddress'] }を指定することで、属性をinfoハッシュの対応するキーにマップできます。URI形式の属性もサポートしています。例: { email: ['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'] }

この設定を使用して、アカウントの作成に必要な特定の属性をどこから取得すべきかをGitLabに指示します。たとえば、IdPがユーザーのメールアドレスをemailではなくEmailAddressとして送信する場合は、それを設定することでGitLabに知らせます:

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      { name: 'saml',
        label: 'Our SAML Provider',
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                attribute_statements: { email: ['EmailAddress'] }
        }
      }
    ]
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
      attribute_statements:
        email: ['EmailAddress']
  2. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  5. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
               { name: 'saml',
                 label: 'Our SAML Provider',
                 args: {
                         assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                         idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                         idp_sso_target_url: 'https://login.example.com/idp',
                         issuer: 'https://gitlab.example.com',
                         name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                         attribute_statements: { email: ['EmailAddress'] }
                 }
               }
            ]
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - { name: 'saml',
              label: 'Our SAML Provider',
              args: {
                      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                      idp_sso_target_url: 'https://login.example.com/idp',
                      issuer: 'https://gitlab.example.com',
                      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                      attribute_statements: { email: ['EmailAddress'] }
              }
            }
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

ユーザー名を設定する

デフォルトでは、SAML応答内のメールアドレスのローカル部分が、GitLabユーザー名の生成に使用されます。

ユーザーが希望するユーザー名を含む1つ以上の属性を指定するには、attribute_statementsusernameまたはnicknameを設定します:

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      { name: 'saml',
        label: 'Our SAML Provider',
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                attribute_statements: { nickname: ['username'] }
        }
      }
    ]
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
      attribute_statements:
        nickname: ['username']
  2. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  5. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
               { name: 'saml',
                 label: 'Our SAML Provider',
                 groups_attribute: 'Groups',
                 required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
                 args: {
                         assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                         idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                         idp_sso_target_url: 'https://login.example.com/idp',
                         issuer: 'https://gitlab.example.com',
                         name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                         attribute_statements: { nickname: ['username'] }
                 }
               }
            ]
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - { name: 'saml',
              label: 'Our SAML Provider',
              groups_attribute: 'Groups',
              required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
              args: {
                      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                      idp_sso_target_url: 'https://login.example.com/idp',
                      issuer: 'https://gitlab.example.com',
                      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                      attribute_statements: { nickname: ['username'] }
              }
            }
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

これにより、SAML応答内のusername属性の値がGitLabのユーザー名として設定されます。

プロファイル属性をマップする

SAMLプロバイダーからプロファイル情報を同期するには、これらの属性をマップするようにattribute_statementsを設定する必要があります。

サポートされているプロファイル属性は次のとおりです:

  • job_title
  • organization

これらの属性にはデフォルトのマッピングがなく、明示的に設定しない限り同期されません。

  1. 目的の属性を同期するようにOmniAuthを設定します。

  2. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      { name: 'saml',
        label: 'Our SAML Provider',
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                attribute_statements: {
                  organization: ['organization'],
                  job_title: ['job_title']
                }
        }
      }
    ]
  3. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 目的の属性を同期するようにOmniAuthを設定します。

  2. 次のYAMLの内容をsaml.yamlファイルに記述して保存し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
      attribute_statements:
        organization: ['organization']
        job_title: ['job_title']
  3. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  4. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  5. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  6. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. 目的の属性を同期するようにOmniAuthを設定します。

  2. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
               { name: 'saml',
                 label: 'Our SAML Provider',
                 args: {
                         assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                         idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                         idp_sso_target_url: 'https://login.example.com/idp',
                         issuer: 'https://gitlab.example.com',
                         name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                         attribute_statements: {
                           organization: ['organization'],
                           job_title: ['job_title']
                         }
                 }
               }
            ]
  3. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. 目的の属性を同期するようにOmniAuthを設定します。

  2. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - { name: 'saml',
              label: 'Our SAML Provider',
              args: {
                      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                      idp_sso_target_url: 'https://login.example.com/idp',
                      issuer: 'https://gitlab.example.com',
                      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                      attribute_statements: {
                        organization: ['organization'],
                        job_title: ['job_title']
                      }
              }
            }
  3. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

クロックドリフト(時刻のずれ)を許容する

IdPの時刻が、システム時刻よりもわずかに進んでいる場合があります。わずかなクロックドリフトを許容するには、設定でallowed_clock_driftを使用します。このパラメータには秒単位で値を入力する必要があります。小数を指定することもできます。指定した値は、応答の検証時の現在時刻に上乗せされます。

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      { name: 'saml',
        label: 'Our SAML Provider',
        groups_attribute: 'Groups',
        required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                allowed_clock_drift: 1  # for one second clock drift
        }
      }
    ]
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    groups_attribute: 'Groups'
    required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors']
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
      allowed_clock_drift: 1  # for one second clock drift
  2. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  5. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
               { name: 'saml',
                 label: 'Our SAML Provider',
                 groups_attribute: 'Groups',
                 required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
                 args: {
                         assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                         idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                         idp_sso_target_url: 'https://login.example.com/idp',
                         issuer: 'https://gitlab.example.com',
                         name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                         allowed_clock_drift: 1  # for one second clock drift
                 }
               }
            ]
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - { name: 'saml',
              label: 'Our SAML Provider',
              groups_attribute: 'Groups',
              required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
              args: {
                      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                      idp_sso_target_url: 'https://login.example.com/idp',
                      issuer: 'https://gitlab.example.com',
                      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                      allowed_clock_drift: 1  # for one second clock drift
              }
            }
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

uidに一意の属性を指定する(オプション)

デフォルトでは、ユーザーのuidは、SAML応答のNameID属性として設定されます。uidに別の属性を指定するには、uid_attributeを設定します。

uidに一意の属性を設定する前に、SAMLユーザーが次の属性を変更できないよう、各属性が変更不可に設定されていることを確認してください:

  • NameID
  • Emailomniauth_auto_link_saml_userと併用する場合)。

ユーザーがこれらの属性を変更できる場合、他の認証済みユーザーとしてサインインできてしまいます。これらの属性を変更不可にする方法については、SAML IdPのドキュメントを参照してください。次の例では、SAML応答内のuid属性の値がuid_attributeとして設定されています。

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      { name: 'saml',
        label: 'Our SAML Provider',
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                uid_attribute: 'uid'
        }
      }
    ]
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    groups_attribute: 'Groups'
    required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors']
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
      uid_attribute: 'uid'
  2. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  5. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
               { name: 'saml',
                 label: 'Our SAML Provider',
                 groups_attribute: 'Groups',
                 required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
                 args: {
                         assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                         idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                         idp_sso_target_url: 'https://login.example.com/idp',
                         issuer: 'https://gitlab.example.com',
                         name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                         uid_attribute: 'uid'
                 }
               }
            ]
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - { name: 'saml',
              label: 'Our SAML Provider',
              groups_attribute: 'Groups',
              required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
              args: {
                      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                      idp_sso_target_url: 'https://login.example.com/idp',
                      issuer: 'https://gitlab.example.com',
                      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                      uid_attribute: 'uid'
              }
            }
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

アサーションを暗号化する(オプション)

SAMLアサーションの暗号化は推奨されるオプションです。これにより、暗号化されていないデータがログに記録されたり、悪意のあるアクターによって傍受されたりするのを防ぐための保護レイヤーが追加されます。

このインテグレーションでは、アサーションの暗号化とリクエストの署名の両方にcertificateおよびprivate_keyの設定を使用します。

SAMLアサーションを暗号化するには、GitLab SAML設定で秘密キーと公開証明書を定義します。IdPは公開証明書でアサーションを暗号化し、GitLabは秘密キーでアサーションを復号化します。

キーと証明書を定義する際は、キーファイル内のすべての改行を\nに置き換えます。これにより、キーファイルは改行のない1行の長い文字列になります。

  1. /etc/gitlab/gitlab.rbを編集します:

    gitlab_rails['omniauth_providers'] = [
      { name: 'saml',
        label: 'Our SAML Provider',
        groups_attribute: 'Groups',
        required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
        args: {
                assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                idp_sso_target_url: 'https://login.example.com/idp',
                issuer: 'https://gitlab.example.com',
                name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                certificate:|
                -----BEGIN CERTIFICATE-----
                <redacted>
                -----END CERTIFICATE-----,
                private_key:|
                -----BEGIN PRIVATE KEY-----
                <redacted>
                -----END PRIVATE KEY-----
        }
      }
    ]
  2. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'saml'
    label: 'Our SAML Provider'
    groups_attribute: 'Groups'
    required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors']
    args:
      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
      idp_sso_target_url: 'https://login.example.com/idp'
      issuer: 'https://gitlab.example.com'
      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
      certificate:|
      -----BEGIN CERTIFICATE-----
      <redacted>
      ----END CERTIFICATE-----,
      private_key:|
      -----BEGIN PRIVATE KEY-----
      <redacted>
      -----END PRIVATE KEY-----
  2. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
  3. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  4. gitlab_values.yamlを編集します:

    global:
      appConfig:
        omniauth:
          providers:
            - secret: gitlab-saml
  5. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. docker-compose.ymlを編集します:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_providers'] = [
               { name: 'saml',
                 label: 'Our SAML Provider',
                 groups_attribute: 'Groups',
                 required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
                 args: {
                         assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                         idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                         idp_sso_target_url: 'https://login.example.com/idp',
                         issuer: 'https://gitlab.example.com',
                         name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                         certificate:|
                         -----BEGIN CERTIFICATE-----
                         <redacted>
                         -----END CERTIFICATE-----,
                         private_key:|
                         -----BEGIN PRIVATE KEY-----
                         <redacted>
                         -----END PRIVATE KEY-----
                 }
               }
            ]
  2. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. /home/git/gitlab/config/gitlab.ymlを編集します:

    production: &base
      omniauth:
        providers:
          - { name: 'saml',
              label: 'Our SAML Provider',
              groups_attribute: 'Groups',
              required_groups: ['Developers', 'Freelancers', 'Admins', 'Auditors'],
              args: {
                      assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                      idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                      idp_sso_target_url: 'https://login.example.com/idp',
                      issuer: 'https://gitlab.example.com',
                      name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                      certificate: '-----BEGIN CERTIFICATE-----\n<redacted>\n-----END CERTIFICATE-----',
                      private_key: '-----BEGIN PRIVATE KEY-----\n<redacted>\n-----END PRIVATE KEY-----'
              }
            }
  2. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

SAML認証リクエストに署名する(オプション)

SAML認証リクエストに署名するようにGitLabを設定できます。GitLab SAMLリクエストはSAMLリダイレクトバインディングを使用しているため、この設定はオプションです。

署名を実装するには、次の手順に従います:

  1. SAMLに使用するGitLabインスタンスの秘密キーと公開証明書ペアを作成します。

  2. 設定のsecurityセクションで署名に関する設定を行います。次に例を示します:

    1. /etc/gitlab/gitlab.rbを編集します:

      gitlab_rails['omniauth_providers'] = [
        { name: 'saml',
          label: 'Our SAML Provider',
          args: {
                  assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                  idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                  idp_sso_target_url: 'https://login.example.com/idp',
                  issuer: 'https://gitlab.example.com',
                  name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                  certificate: '-----BEGIN CERTIFICATE-----\n<redacted>\n-----END CERTIFICATE-----',
                  private_key: '-----BEGIN PRIVATE KEY-----\n<redacted>\n-----END PRIVATE KEY-----',
                  security: {
                    authn_requests_signed: true,  # enable signature on AuthNRequest
                    want_assertions_signed: true,  # enable the requirement of signed assertion
                    want_assertions_encrypted: false,  # enable the requirement of encrypted assertion
                    metadata_signed: false,  # enable signature on Metadata
                    signature_method: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
                    digest_method: 'http://www.w3.org/2001/04/xmlenc#sha256',
                  }
          }
        }
      ]
    2. ファイルを保存して、GitLabを再設定します:

      sudo gitlab-ctl reconfigure
    1. 次の内容をsaml.yamlファイルに記述し、Kubernetes Secretとして使用します:

      name: 'saml'
      label: 'Our SAML Provider'
      args:
        assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback'
        idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6'
        idp_sso_target_url: 'https://login.example.com/idp'
        issuer: 'https://gitlab.example.com'
        name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
        certificate: '-----BEGIN CERTIFICATE-----\n<redacted>\n-----END CERTIFICATE-----'
        private_key: '-----BEGIN PRIVATE KEY-----\n<redacted>\n-----END PRIVATE KEY-----'
        security:
          authn_requests_signed: true  # enable signature on AuthNRequest
          want_assertions_signed: true  # enable the requirement of signed assertion
          want_assertions_encrypted: false  # enable the requirement of encrypted assertion
          metadata_signed: false  # enable signature on Metadata
          signature_method: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'
          digest_method: 'http://www.w3.org/2001/04/xmlenc#sha256'
    2. Kubernetes Secretを作成します:

      kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yaml
    3. Helm値をエクスポートします:

      helm get values gitlab > gitlab_values.yaml
    4. gitlab_values.yamlを編集します:

      global:
        appConfig:
          omniauth:
            providers:
              - secret: gitlab-saml
    5. ファイルを保存し、新しい値を適用します:

      helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
    1. docker-compose.ymlを編集します:

      version: "3.6"
      services:
        gitlab:
          environment:
            GITLAB_OMNIBUS_CONFIG: |
              gitlab_rails['omniauth_providers'] = [
                 { name: 'saml',
                   label: 'Our SAML Provider',
                   args: {
                           assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                           idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                           idp_sso_target_url: 'https://login.example.com/idp',
                           issuer: 'https://gitlab.example.com',
                           name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                           certificate: '-----BEGIN CERTIFICATE-----\n<redacted>\n-----END CERTIFICATE-----',
                           private_key: '-----BEGIN PRIVATE KEY-----\n<redacted>\n-----END PRIVATE KEY-----',
                           security: {
                             authn_requests_signed: true,  # enable signature on AuthNRequest
                             want_assertions_signed: true,  # enable the requirement of signed assertion
                             want_assertions_encrypted: false,  # enable the requirement of encrypted assertion
                             metadata_signed: false,  # enable signature on Metadata
                             signature_method: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
                             digest_method: 'http://www.w3.org/2001/04/xmlenc#sha256',
                           }
                   }
                 }
              ]
    2. ファイルを保存して、GitLabを再起動します:

      docker compose up -d
    1. /home/git/gitlab/config/gitlab.ymlを編集します:

      production: &base
        omniauth:
          providers:
            - { name: 'saml',
                label: 'Our SAML Provider',
                args: {
                        assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
                        idp_cert_fingerprint: '2f:cb:19:57:68:c3:9e:9a:94:ce:c2:c2:e3:2c:59:c0:aa:d7:a3:36:5c:10:89:2e:81:16:b5:d8:3d:40:96:b6',
                        idp_sso_target_url: 'https://login.example.com/idp',
                        issuer: 'https://gitlab.example.com',
                        name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
                        certificate: '-----BEGIN CERTIFICATE-----\n<redacted>\n-----END CERTIFICATE-----',
                        private_key: '-----BEGIN PRIVATE KEY-----\n<redacted>\n-----END PRIVATE KEY-----',
                        security: {
                          authn_requests_signed: true,  # enable signature on AuthNRequest
                          want_assertions_signed: true,  # enable the requirement of signed assertion
                          want_assertions_encrypted: false,  # enable the requirement of encrypted assertion
                          metadata_signed: false,  # enable signature on Metadata
                          signature_method: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
                          digest_method: 'http://www.w3.org/2001/04/xmlenc#sha256',
                        }
                }
              }
    2. ファイルを保存して、GitLabを再起動します:

      # For systems running systemd
      sudo systemctl restart gitlab.target
      
      # For systems running SysV init
      sudo service gitlab restart

その後、GitLabは次の処理を行います:

  • 指定された秘密キーでリクエストに署名します。
  • 受信したリクエストの署名をIdPが検証できるよう、設定された公開x500証明書をIdPのメタデータに含めます。

このオプションの詳細については、Ruby SAML gemのドキュメントを参照してください。

Ruby SAML gemは、OmniAuth SAML gemがSAML認証のクライアント側を実装するために使用します。

SAMLのリダイレクトバインディングは、SAMLのPOSTバインディングとは異なります。POSTバインディングでは、仲介者によってリクエストが改ざんされるのを防ぐために署名が必須となります。

SAMLを通じて作成されたユーザーのパスワードを生成する

GitLabは、SAMLを通じて作成されたユーザーに対して、パスワードを生成して設定します。

SSOまたはSAMLで認証されたユーザーは、HTTPS経由でのGitオペレーションにパスワードを使用してはなりません。代わりに、次のいずれかが可能です:

管理者は、SAMLユーザーを既存のGitLabユーザーに自動的にリンクするようにGitLabを設定できます。詳細については、GitLabでのSAMLサポートの設定を参照してください。

ユーザーは、SAMLアイデンティティを既存のGitLabアカウントに手動でリンクできます。詳細については、既存のユーザーに対してOmniAuthを有効にするを参照してください。

GitLab Self-ManagedでグループSAML SSOを設定する

  • プラン: Premium、Ultimate
  • 提供形態: GitLab Self-Managed、GitLab Dedicated

GitLab Self-Managedインスタンスで複数のSAML IdPを通じてアクセスを許可する必要がある場合は、グループSAML SSOを使用します。

グループSAML SSOを設定するには、次の手順に従います:

  1. GitLabでHTTPSが設定されていることを確認してください。

  2. /etc/gitlab/gitlab.rbを編集して、OmniAuthとgroup_samlプロバイダーを有効にします:

    gitlab_rails['omniauth_enabled'] = true
    gitlab_rails['omniauth_providers'] = [{ name: 'group_saml' }]
  3. ファイルを保存して、GitLabを再設定します:

    sudo gitlab-ctl reconfigure
  1. GitLabでHTTPSが設定されていることを確認してください。

  2. 次の内容をgroup_saml.yamlファイルに記述し、Kubernetes Secretとして使用します:

    name: 'group_saml'
  3. Kubernetes Secretを作成します:

    kubectl create secret generic -n <namespace> gitlab-group-saml --from-file=provider=group_saml.yaml
  4. Helm値をエクスポートします:

    helm get values gitlab > gitlab_values.yaml
  5. gitlab_values.yamlを編集して、OmniAuthとgroup_samlプロバイダーを有効にします:

    global:
      appConfig:
        omniauth:
          enabled: true
          providers:
            - secret: gitlab-group-saml
  6. ファイルを保存し、新しい値を適用します:

    helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
  1. GitLabでHTTPSが設定されていることを確認してください。

  2. docker-compose.ymlを編集して、OmniAuthとgroup_samlプロバイダーを有効にします:

    version: "3.6"
    services:
      gitlab:
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            gitlab_rails['omniauth_enabled'] = true
            gitlab_rails['omniauth_providers'] = [{ name: 'group_saml' }]
  3. ファイルを保存して、GitLabを再起動します:

    docker compose up -d
  1. GitLabでHTTPSが設定されていることを確認してください。

  2. /home/git/gitlab/config/gitlab.ymlを編集して、OmniAuthとgroup_samlプロバイダーを有効にします:

    production: &base
      omniauth:
        enabled: true
        providers:
          - { name: 'group_saml' }
  3. ファイルを保存して、GitLabを再起動します:

    # For systems running systemd
    sudo systemctl restart gitlab.target
    
    # For systems running SysV init
    sudo service gitlab restart

マルチテナントソリューションであるため、GitLab Self-ManagedにおけるグループSAMLは、推奨されるインスタンス全体のSAMLと比べて機能が制限されています。以下の機能を活用するには、インスタンス全体のSAMLを使用してください:

IdPにおけるSAMLアプリ用の追加の設定

IdPでSAMLアプリを設定する場合、次のような追加の設定が必要になる場合があります:

フィールド備考
SAMLプロファイルWebブラウザSSOプロファイルGitLabはSAMLを使用して、ユーザーをブラウザ経由でサインインさせます。IdPに直接リクエストが送信されることはありません。
SAMLリクエストバインディングHTTPリダイレクトGitLab(SP)はbase64でエンコードされたSAMLRequest HTTPパラメータを使用して、ユーザーをIdPにリダイレクトします。
SAML応答バインディングHTTP POSTIdPによるSAMLトークンの送信方法を指定します。これには、ユーザーのブラウザがGitLabに送り返すSAMLResponseを含みます。
SAML応答の署名必須改ざんを防止します。
応答内のX.509証明書必須応答に署名し、指定されたフィンガープリントと照合して応答をチェックします。
フィンガープリントアルゴリズムSHA-1GitLabは証明書のSHA-1ハッシュを使用して、SAML応答に署名します。
署名アルゴリズムSHA-1/SHA-256/SHA-384/SHA-512応答への署名方法を指定します。ダイジェスト方式とも呼ばれ、SAML応答内で指定できます。
SAMLアサーションの暗号化オプションIdentity Provider、ユーザーのブラウザ、およびGitLab間でTLSを使用します。
SAMLアサーションへの署名オプションSAMLアサーションの整合性を検証します。有効にすると、応答全体に署名します。
SAMLリクエスト署名の確認オプションSAML応答の署名を確認します。
デフォルトのRelayStateオプションユーザーがIdPを通じてSAML認証で正常にサインインした後に、最終的にアクセスするベースURLのサブパスを指定します。
NameID形式永続的NameID形式の詳細を参照してください。
追加のURLオプション一部のプロバイダーでは、発行者、識別子、またはアサーションコンシューマサービスURLを他のフィールドに含める場合があります。

設定例については、特定のプロバイダーに関する注記を参照してください。

Geo環境でSAMLを設定する

Geo環境でSAMLを設定するには、インスタンス全体のSAMLを設定するを参照してください。

詳細については、Geoにおけるシングルサインオン(SSO)を参照してください。

用語集

用語説明
Identity Provider(IdP)OktaやOneLoginなど、ユーザー認証情報を管理するサービス。
サービスプロバイダー(SP)OktaなどのSAML Identity Provider(IdP)が発行したアサーションを利用して、ユーザーを認証します。GitLabはSAML 2.0 SPとして設定できます。
アサーションユーザーの名前やロールなど、ユーザーの認証に関する情報。クレームまたは属性とも呼ばれます。
シングルサインオン(SSO)認証スキームの名前。
アサーションコンシューマサービスURLIdPでの認証に成功した後、ユーザーがリダイレクトされるGitLab側のコールバック先。
発行者GitLabがIdPに対して自身を識別する方法。「relying party trust identifier(証明書利用者信頼の識別子)」とも呼ばれます。
証明書フィンガープリントサーバーが正しい証明書で通信に署名していることを確認することにより、SAMLを介した通信の安全性を保証します。証明書フィンガープリントとも呼ばれます。

トラブルシューティング

SAMLのトラブルシューティングガイドを参照してください。