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のサポートを設定する
GitLabでHTTPSが設定されていることを確認してください。
共通設定で、
samlをシングルサインオンプロバイダーとして追加します。これにより、既存のGitLabアカウントを持たないユーザーに対して、Just-In-Timeアカウントプロビジョニングが有効になります。ユーザーが最初に手動でアカウントを作成しなくてもSAMLを使用してサインアップできるようにするには、
/etc/gitlab/gitlab.rbを編集します:gitlab_rails['omniauth_allow_single_sign_on'] = ['saml'] gitlab_rails['omniauth_block_auto_created_users'] = falseオプション。初回にSAMLでサインインする際に、SAML応答のメールアドレスが既存のGitLabユーザーと一致する場合、これらを自動的にリンクする必要があります。これを行うには、
/etc/gitlab/gitlab.rbに次の設定を追加します:gitlab_rails['omniauth_auto_link_saml_user'] = trueSAML応答のメールアドレスと照合されるのは、GitLabアカウントのプライマリメールアドレスのみです。
または、ユーザーが既存のユーザーに対してOmniAuthを有効にすることで、SAMLアイデンティティを既存のGitLabアカウントに手動でリンクすることも可能です。
次の属性を設定し、SAMLユーザーがこれらを変更できないようにします:
NameIDEmail(omniauth_auto_link_saml_userと併用する場合)。
ユーザーがこれらの属性を変更できる場合、他の認証済みユーザーとしてサインインできてしまいます。これらの属性を変更不可にする方法については、SAML IdPのドキュメントを参照してください。
/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を設定するを参照してください。
ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
GitLabでHTTPSが設定されていることを確認してください。
共通設定で、
samlをシングルサインオンプロバイダーとして追加します。これにより、既存のGitLabアカウントを持たないユーザーに対して、Just-In-Timeアカウントプロビジョニングが有効になります。Helm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlユーザーが最初に手動でアカウントを作成しなくてもSAMLを使用してサインアップできるようにするには、
gitlab_values.yamlを編集します:global: appConfig: omniauth: enabled: true allowSingleSignOn: ['saml'] blockAutoCreatedUsers: falseオプション。
gitlab_values.yamlに次の設定を追加すると、SAMLユーザーと既存のGitLabユーザーのメールアドレスが一致する場合に、両者を自動的にリンクできます:global: appConfig: omniauth: autoLinkSamlUser: trueまたは、ユーザーが既存のユーザーに対してOmniAuthを有効にすることで、SAMLアイデンティティを既存のGitLabアカウントに手動でリンクすることも可能です。
次の属性を設定し、SAMLユーザーがこれらを変更できないようにします:
NameIDEmail(omniauth_auto_link_saml_userと併用する場合)。
ユーザーがこれらの属性を変更できる場合、他の認証済みユーザーとしてサインインできてしまいます。これらの属性を変更不可にする方法については、SAML IdPのドキュメントを参照してください。
次の内容を
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を設定するを参照してください。
Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlgitlab_values.yamlを編集し、プロバイダー設定を追加します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
GitLabでHTTPSが設定されていることを確認してください。
共通設定で、
samlをシングルサインオンプロバイダーとして追加します。これにより、既存のGitLabアカウントを持たないユーザーに対して、Just-In-Timeアカウントプロビジョニングが有効になります。ユーザーが最初に手動でアカウントを作成しなくても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オプション。
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アカウントに手動でリンクすることも可能です。
次の属性を設定し、SAMLユーザーがこれらを変更できないようにします:
NameIDEmail(omniauth_auto_link_saml_userと併用する場合)。
ユーザーがこれらの属性を変更できる場合、他の認証済みユーザーとしてサインインできてしまいます。これらの属性を変更不可にする方法については、SAML IdPのドキュメントを参照してください。
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を設定するを参照してください。
ファイルを保存して、GitLabを再起動します:
docker compose up -d
GitLabでHTTPSが設定されていることを確認してください。
共通設定で、
samlをシングルサインオンプロバイダーとして追加します。これにより、既存のGitLabアカウントを持たないユーザーに対して、Just-In-Timeアカウントプロビジョニングが有効になります。ユーザーが最初に手動でアカウントを作成しなくてもSAMLを使用してサインアップできるようにするには、
/home/git/gitlab/config/gitlab.ymlを編集します:production: &base omniauth: enabled: true allow_single_sign_on: ["saml"] block_auto_created_users: falseオプション。
/home/git/gitlab/config/gitlab.ymlに次の設定を追加すると、SAMLユーザーと既存のGitLabユーザーのメールアドレスが一致する場合に、両者を自動的にリンクできます:production: &base omniauth: auto_link_saml_user: trueまたは、ユーザーが既存のユーザーに対してOmniAuthを有効にすることで、SAMLアイデンティティを既存のGitLabアカウントに手動でリンクすることも可能です。
次の属性を設定し、SAMLユーザーがこれらを変更できないようにします:
NameIDEmail(omniauth_auto_link_saml_userと併用する場合)。
ユーザーがこれらの属性を変更できる場合、他の認証済みユーザーとしてサインインできてしまいます。これらの属性を変更不可にする方法については、SAML IdPのドキュメントを参照してください。
/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を設定するを参照してください。
ファイルを保存して、GitLabを再起動します:
# For systems running systemd sudo systemctl restart gitlab.target # For systems running SysV init sudo service gitlab restart
SAML IdPにGitLabを登録する
issuerで指定されたアプリケーション名を使用して、SAML IdPにGitLabのSPを登録します。IdPに設定情報を提供するには、アプリケーションのメタデータURLを作成します。GitLabのメタデータURLを作成するには、GitLabインストールのHTTPS URLに
users/auth/saml/metadataを付加します。次に例を示します:https://gitlab.example.com/users/auth/saml/metadataIdPは最低限、
emailまたはmailを使用して、ユーザーのメールアドレスを含むクレームを提供するmust(必要があります)。その他の利用可能なクレームの詳細については、アサーションを設定するを参照してください。サインインページでは、標準のサインインフォームの下にSAMLのアイコンが表示されているはずです。そのアイコンを選択すると、認証プロセスが開始されます。認証に成功すると、GitLabに戻り、サインインした状態になります。
IdPでSAMLを設定する
IdPでSAMLアプリケーションを設定するには、少なくとも次の情報が必要です:
- アサーションコンシューマサービスURL。
- 発行者。
NameID- メールアドレスのクレーム。
設定例については、Identity Providerを設定するを参照してください。
IdPによっては追加の設定が必要になる場合があります。詳細については、IdPにおけるSAMLアプリ用の追加の設定を参照してください。
複数のSAML IdPを使用するようにGitLabを設定する
次の条件を満たす場合、複数のSAML IdPを使用するようにGitLabを設定できます:
- 各プロバイダーに、
argsに指定された名前と一致する、一意の名前が設定されている。 - プロバイダー名を次のように使用している:
- OmniAuthの設定で、プロバイダー名に基づいてプロパティを設定している。例:
allowBypassTwoFactor、allowSingleSignOn、syncProfileFromProvider。 - プロバイダー名を使用して、既存の各ユーザーに追加のIDとして関連付けている。
- OmniAuthの設定で、プロバイダー名に基づいてプロパティを設定している。例:
assertion_consumer_service_urlがプロバイダー名と一致している。strategy_classが明示的に設定されている(プロバイダー名からは推測できないため)。
複数のSAML IdPを設定する場合、SAMLグループのリンクを適切に機能させるには、SAML応答にグループ属性が含まれるように、すべてのSAML IdPを設定する必要があります。詳細については、SAMLグループのリンクを参照してください。
複数のSAML IdPを設定するには、次の手順に従います:
/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']ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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次の内容を
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オプション。同じ手順に従って、追加のSAMLプロバイダーを設定します。
Kubernetes Secretsを作成します:
kubectl create secret generic -n <namespace> gitlab-saml \ --from-file=saml=saml.yaml \ --from-file=saml_2=saml_2.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_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']ファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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']ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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"]ファイルを保存して、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を設定する
- Oktaの管理者セクションで、アプリケーションを選択します。
- アプリ画面で、Create App Integration(アプリ統合を作成)を選択し、次の画面でSAML 2.0を選択します。
- オプション。GitLab Pressからロゴを選択して追加します。ロゴをトリミングしてサイズを変更する必要があります。
- SAMLの一般設定を入力します。次の項目を設定します:
- フィードバックセクションで、自分が顧客であり、内部使用のためにアプリを作成していることを入力します。
- 新しいアプリのプロファイルの上部で、SAML 2.0 configuration instructions(SAML 2.0設定手順)を選択します。
- Identity Provider Single Sign-On URL(アイデンティティプロバイダのシングルサインオンURL)をメモします。このURLは、GitLab設定ファイルの
idp_sso_target_urlに使用します。 - Oktaからサインアウトする前に、ユーザーとグループ(存在する場合)を必ず追加してください。
Google Workspaceを設定する
前提要件:
- Google Workspaceの特権管理者アカウントへのアクセス権があることを確認してください。
Google Workspaceを設定するには、次の手順に従います:
次の情報を使用し、Google WorkspaceでカスタムSAMLアプリを設定する手順に従います。
一般的な値 説明 SAMLアプリの名前 GitLab 他の名前でもかまいません。 ACS URL https://<GITLAB_DOMAIN>/users/auth/saml/callbackアサーションコンシューマサービスURL。 GITLAB_DOMAINgitlab.example.comGitLabインスタンスのドメイン。 エンティティID https://gitlab.example.comSAMLアプリケーションに固有の値。この値は、GitLabの設定で issuerに指定します。名前IDの形式 EMAIL必須の値です。 name_identifier_formatとしても知られています。名前ID プライマリーメールアドレス お使いのメールアドレス。そのアドレス宛てに送信された内容を受信できることを確認してください。 お名前(名) first_nameお名前(名)。GitLabと通信するために必須の値です。 お名前(姓) last_nameお名前(姓)。GitLabと通信するために必須の値です。 次のSAML属性マッピングを設定します:
Googleディレクトリの属性 アプリケーションの属性 Basic information(基本情報) > Email(メールアドレス) emailBasic 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を設定する
Microsoft Entra管理センターにサインインします。
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(サムプリント)) 次の属性を設定します:
- Unique User Identifier (Name ID)(一意のユーザー識別子(名前ID))には
user.objectIDを指定します。- Name identifier format(名前識別子形式)を
persistentにします。詳細については、ユーザーSAMLアイデンティティの管理を参照してください。
- Name identifier format(名前識別子形式)を
- Additional claims(追加のクレーム)にはサポートされている属性を指定します。
- Unique User Identifier (Name ID)(一意のユーザー識別子(名前ID))には
詳細については、設定例のページを参照してください。
他のIdPを設定する
一部のIdPには、SAML設定でIdPとして使用する方法に関するドキュメントが用意されています。次に例を示します:
SAML設定におけるIdPの設定方法についてご不明な点がある場合は、各プロバイダーのサポートにお問い合わせください。
アサーションを設定する
- 提供形態: GitLab.com、GitLab Self-Managed
これらの属性は大文字と小文字が区別されます。
| フィールド | サポートされているデフォルトキー |
|---|---|
| メール(必須) | email、mail、http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress、http://schemas.microsoft.com/ws/2008/06/identity/claims/emailaddress、http://schemas.xmlsoap.org/ws/2005/05/identity/claims/email、http://schemas.microsoft.com/ws/2008/06/identity/claims/email、urn:oid:0.9.2342.19200300.100.1.3 |
| フルネーム | name、http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name、http://schemas.microsoft.com/ws/2008/06/identity/claims/name、urn:oid:2.16.840.1.113730.3.1.241、urn:oid:2.5.4.3 |
| お名前(名) | first_name、firstname、firstName、http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname、http://schemas.microsoft.com/ws/2008/06/identity/claims/givenname、urn:oid:2.5.4.42 |
| お名前(姓) | last_name、lastname、lastName、http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname、http://schemas.microsoft.com/ws/2008/06/identity/claims/surname、urn: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"firstnamelastnameemail
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)をインストールしているかどうか。
| グループ | プラン | 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で指定された属性が誤っているか存在しない場合、すべてのユーザーがブロックされます。
/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' } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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'Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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' } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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' } }ファイルを保存して、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で指定された属性が誤っているか存在しない場合、ユーザーは標準ユーザーとしてアクセスします。
設定例:
/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' } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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'Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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' } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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' } }ファイルを保存して、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で指定された属性が誤っているか存在しない場合、ユーザーは管理者アクセス権を失います。
設定例:
/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' } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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'Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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' } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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' } }ファイルを保存して、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で指定された属性が誤っているか存在しない場合、ユーザーは監査担当者アクセス権を失います。
設定例:
/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' } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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'Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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' } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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' } }ファイルを保存して、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リストにその方式を登録します。
IdPが
AuthnContextを返すようになっていることを確認してください。次に例を示します:<saml:AuthnStatement> <saml:AuthnContext> <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:MediumStrongCertificateProtectedTransport</saml:AuthnContextClassRef> </saml:AuthnContext> </saml:AuthnStatement>インストール設定を編集し、
upstream_two_factor_authn_contextsリストにSAML認証方法を登録します。SAML応答に含まれているAuthnContextを入力する必要があります。/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 ), } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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'Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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 ) } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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' ] } }ファイルを保存して、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を使用して、レスポンス署名の検証を設定できます。設定例を以下に示します:
/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' } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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'Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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' } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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' } }ファイルを保存して、GitLabを再起動します:
# For systems running systemd sudo systemctl restart gitlab.target # For systems running SysV init sudo service gitlab restart
idp_certを使用する
idp_certを使用して、GitLabを直接設定することもできます。設定例を以下に示します:
/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' } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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'Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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' } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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' } }ファイルを保存して、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サーバーに自動的にリダイレクトできます。これにより、実際にサインインする前に要素を選択する必要がなくなります。
/etc/gitlab/gitlab.rbを編集します:gitlab_rails['omniauth_auto_sign_in_with_provider'] = 'saml'ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
Helm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: autoSignInWithProvider: 'saml'ファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
docker-compose.ymlを編集します:version: "3.6" services: gitlab: environment: GITLAB_OMNIBUS_CONFIG: | gitlab_rails['omniauth_auto_sign_in_with_provider'] = 'saml'ファイルを保存して、GitLabを再起動します:
docker compose up -d
/home/git/gitlab/config/gitlab.ymlを編集します:production: &base omniauth: auto_sign_in_with_provider: 'saml'ファイルを保存して、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ハッシュスキーマに含まれる属性をマップする場合にのみ使用してください。
たとえば、SAMLResponseにEmailAddressという属性が含まれている場合は、{ email: ['EmailAddress'] }を指定することで、属性をinfoハッシュの対応するキーにマップできます。URI形式の属性もサポートしています。例: { email: ['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'] }
この設定を使用して、アカウントの作成に必要な特定の属性をどこから取得すべきかをGitLabに指示します。たとえば、IdPがユーザーのメールアドレスをemailではなくEmailAddressとして送信する場合は、それを設定することでGitLabに知らせます:
/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'] } } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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']Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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'] } } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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'] } } }ファイルを保存して、GitLabを再起動します:
# For systems running systemd sudo systemctl restart gitlab.target # For systems running SysV init sudo service gitlab restart
ユーザー名を設定する
デフォルトでは、SAML応答内のメールアドレスのローカル部分が、GitLabユーザー名の生成に使用されます。
ユーザーが希望するユーザー名を含む1つ以上の属性を指定するには、attribute_statementsでusernameまたはnicknameを設定します:
/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'] } } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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']Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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'] } } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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'] } } }ファイルを保存して、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_titleorganization
これらの属性にはデフォルトのマッピングがなく、明示的に設定しない限り同期されません。
/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'] } } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の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']Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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'] } } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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'] } } }ファイルを保存して、GitLabを再起動します:
# For systems running systemd sudo systemctl restart gitlab.target # For systems running SysV init sudo service gitlab restart
クロックドリフト(時刻のずれ)を許容する
IdPの時刻が、システム時刻よりもわずかに進んでいる場合があります。わずかなクロックドリフトを許容するには、設定でallowed_clock_driftを使用します。このパラメータには秒単位で値を入力する必要があります。小数を指定することもできます。指定した値は、応答の検証時の現在時刻に上乗せされます。
/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 } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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 driftKubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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 } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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 } }ファイルを保存して、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ユーザーが次の属性を変更できないよう、各属性が変更不可に設定されていることを確認してください:
NameIDEmail(omniauth_auto_link_saml_userと併用する場合)。
ユーザーがこれらの属性を変更できる場合、他の認証済みユーザーとしてサインインできてしまいます。これらの属性を変更不可にする方法については、SAML IdPのドキュメントを参照してください。次の例では、SAML応答内のuid属性の値がuid_attributeとして設定されています。
/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' } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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'Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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' } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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' } }ファイルを保存して、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行の長い文字列になります。
/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----- } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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-----Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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----- } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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-----' } }ファイルを保存して、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リダイレクトバインディングを使用しているため、この設定はオプションです。
署名を実装するには、次の手順に従います:
SAMLに使用するGitLabインスタンスの秘密キーと公開証明書ペアを作成します。
設定の
securityセクションで署名に関する設定を行います。次に例を示します:/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', } } } ]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
次の内容を
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'Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-saml --from-file=provider=saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集します:global: appConfig: omniauth: providers: - secret: gitlab-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
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', } } } ]ファイルを保存して、GitLabを再起動します:
docker compose up -d
/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', } } }ファイルを保存して、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オペレーションにパスワードを使用してはなりません。代わりに、次のいずれかが可能です:
- パーソナル 、プロジェクト 、またはグループアクセストークンを設定する。
- OAuth認証情報ヘルパーを使用します。
既存のユーザーにSAMLアイデンティティをリンクする
管理者は、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を設定するには、次の手順に従います:
GitLabでHTTPSが設定されていることを確認してください。
/etc/gitlab/gitlab.rbを編集して、OmniAuthとgroup_samlプロバイダーを有効にします:gitlab_rails['omniauth_enabled'] = true gitlab_rails['omniauth_providers'] = [{ name: 'group_saml' }]ファイルを保存して、GitLabを再設定します:
sudo gitlab-ctl reconfigure
GitLabでHTTPSが設定されていることを確認してください。
次の内容を
group_saml.yamlファイルに記述し、Kubernetes Secretとして使用します:name: 'group_saml'Kubernetes Secretを作成します:
kubectl create secret generic -n <namespace> gitlab-group-saml --from-file=provider=group_saml.yamlHelm値をエクスポートします:
helm get values gitlab > gitlab_values.yamlgitlab_values.yamlを編集して、OmniAuthとgroup_samlプロバイダーを有効にします:global: appConfig: omniauth: enabled: true providers: - secret: gitlab-group-samlファイルを保存し、新しい値を適用します:
helm upgrade -f gitlab_values.yaml gitlab gitlab/gitlab
GitLabでHTTPSが設定されていることを確認してください。
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' }]ファイルを保存して、GitLabを再起動します:
docker compose up -d
GitLabでHTTPSが設定されていることを確認してください。
/home/git/gitlab/config/gitlab.ymlを編集して、OmniAuthとgroup_samlプロバイダーを有効にします:production: &base omniauth: enabled: true providers: - { name: 'group_saml' }ファイルを保存して、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 POST | IdPによるSAMLトークンの送信方法を指定します。これには、ユーザーのブラウザがGitLabに送り返すSAMLResponseを含みます。 |
| SAML応答の署名 | 必須 | 改ざんを防止します。 |
| 応答内のX.509証明書 | 必須 | 応答に署名し、指定されたフィンガープリントと照合して応答をチェックします。 |
| フィンガープリントアルゴリズム | SHA-1 | GitLabは証明書の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) | 認証スキームの名前。 |
| アサーションコンシューマサービスURL | IdPでの認証に成功した後、ユーザーがリダイレクトされるGitLab側のコールバック先。 |
| 発行者 | GitLabがIdPに対して自身を識別する方法。「relying party trust identifier(証明書利用者信頼の識別子)」とも呼ばれます。 |
| 証明書フィンガープリント | サーバーが正しい証明書で通信に署名していることを確認することにより、SAMLを介した通信の安全性を保証します。証明書フィンガープリントとも呼ばれます。 |
トラブルシューティング
SAMLのトラブルシューティングガイドを参照してください。