{{< details >}}
- Tier: 专业版,旗舰版
- Offering: 私有化部署
{{< /details >}}
本文档仅讨论与 Geo 相关的 SSO 考量和配置。有关一般身份验证的更多信息,请参阅 极狐GitLab 身份验证和授权。
配置实例范围的 SAML
先决条件
实例范围的 SAML 必须在您的主 Geo 站点上正常工作。
您只需在主站点上配置 SAML。在次要站点中配置 gitlab_rails['omniauth_providers']
在 gitlab.rb
中没有效果。次要站点会根据在主站点上配置的 SAML 提供程序进行身份验证。根据次要站点的 URL 类型,可能需要在主站点上进行 额外配置。
确定次要站点使用的 URL 类型
根据您的次要站点配置,实例范围的 SAML 配置有所不同。确定您的次要站点是否使用:
-
统一 URL,意味着
external_url
完全匹配主站点的external_url
。 - 启用代理的 独立 URL。代理在 极狐GitLab 15.1 及以后版本中默认启用。
- 禁用代理的 独立 URL。
使用统一 URL 的 SAML
如果您在主站点上正确配置了 SAML,那么它应该可以在次要站点上正常工作,无需额外配置。
启用代理的独立 URL 的 SAML
{{< alert type=”note” >}}
启用代理时,只有当您的 SAML 身份提供商 (IdP) 允许应用程序配置多个回调 URL 时,才能在次要站点使用 SAML 登录。请与您的 IdP 提供商支持团队确认是否可以这样做。
{{< /alert >}}
如果次要站点使用与主站点不同的 external_url
,请配置您的 SAML 身份提供商 (IdP) 以允许次要站点的 SAML 回调 URL。例如,要配置 Okta:
- 登录 Okta。
- 转到 Okta 管理员仪表板 > 应用程序 > 您的应用程序名称 > 常规。
- 在 SAML 设置 中,选择 编辑。
- 在 常规设置 中,选择 下一步 以进入 SAML 设置。
- 在 SAML 设置 > 常规 中,确保 单点登录 URL 是您的主站点的 SAML 回调 URL。例如,
https://gitlab-primary.example.com/users/auth/saml/callback
。如果不是,请在此字段中输入您的主站点的 SAML 回调 URL。 - 选择 显示高级设置。
- 在 其他可请求的 SSO URL 中,输入您的次要站点的 SAML 回调 URL。例如,
https://gitlab-secondary.example.com/users/auth/saml/callback
。您可以将 索引 设置为任何值。 - 选择 下一步 然后 完成。
您不得在主站点的 gitlab.rb
中的 SAML 提供程序配置中指定 assertion_consumer_service_url
。例如:
gitlab_rails['omniauth_providers'] = [
{
name: "saml",
label: "Okta", # optional label for login button, defaults to "Saml"
args: {
idp_cert_fingerprint: "B5:AD:AA:9E:3C:05:68:AD:3B:78:ED:31:99:96:96:43:9E:6D:79:96",
idp_sso_target_url: "https://<dev-account>.okta.com/app/dev-account_gitlabprimary_1/exk7k2gft2VFpVFXa5d1/sso/saml",
issuer: "https://<gitlab-primary>",
name_identifier_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
}
}
]
此配置导致:
- 您的两个站点都使用
/users/auth/saml/callback
作为其断言消费者服务 (ACS) URL。 - URL 的主机被设置为相应站点的主机。
您可以通过访问每个站点的 /users/auth/saml/metadata
路径进行检查。例如,访问 https://gitlab-primary.example.com/users/auth/saml/metadata
可能会响应:
<md:EntityDescriptor ID="_b9e00d84-d34e-4e3d-95de-122e3c361617" entityID="https://gitlab-primary.example.com"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
<md:SPSSODescriptor AuthnRequestsSigned="false" WantAssertionsSigned="false" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<md:NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:persistent</md:NameIDFormat>
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://gitlab-primary.example.com/users/auth/saml/callback" index="0" isDefault="true"/>
<md:AttributeConsumingService index="1" isDefault="true">
<md:ServiceName xml:lang="en">Required attributes</md:ServiceName>
<md:RequestedAttribute FriendlyName="Email address" Name="email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" isRequired="false"/>
<md:RequestedAttribute FriendlyName="Full name" Name="name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" isRequired="false"/>
<md:RequestedAttribute FriendlyName="Given name" Name="first_name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" isRequired="false"/>
<md:RequestedAttribute FriendlyName="Family name" Name="last_name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" isRequired="false"/>
</md:AttributeConsumingService>
</md:SPSSODescriptor>
</md:EntityDescriptor>
访问 https://gitlab-secondary.example.com/users/auth/saml/metadata
可能会响应:
<md:EntityDescriptor ID="_bf71eb57-7490-4024-bfe2-54cec716d4bf" entityID="https://gitlab-primary.example.com"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
<md:SPSSODescriptor AuthnRequestsSigned="false" WantAssertionsSigned="false" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<md:NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:persistent</md:NameIDFormat>
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://gitlab-secondary.example.com/users/auth/saml/callback" index="0" isDefault="true"/>
<md:AttributeConsumingService index="1" isDefault="true">
<md:ServiceName xml:lang="en">Required attributes</md:ServiceName>
<md:RequestedAttribute FriendlyName="Email address" Name="email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" isRequired="false"/>
<md:RequestedAttribute FriendlyName="Full name" Name="name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" isRequired="false"/>
<md:RequestedAttribute FriendlyName="Given name" Name="first_name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" isRequired="false"/>
<md:RequestedAttribute FriendlyName="Family name" Name="last_name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" isRequired="false"/>
</md:AttributeConsumingService>
</md:SPSSODescriptor>
</md:EntityDescriptor>
md:AssertionConsumerService
字段的 Location
属性指向 gitlab-secondary.example.com
。
在配置您的 SAML IdP 以允许次要站点的 SAML 回调 URL 之后,您应该能够在主站点以及次要站点上使用 SAML 登录。
禁用代理的独立 URL 的 SAML
如果您在主站点上正确配置了 SAML,那么它应该可以在次要站点上正常工作,无需额外配置。
OpenID Connect
如果您使用 OpenID Connect (OIDC) OmniAuth 提供商,在大多数情况下,它应该可以正常工作:
- 使用统一 URL 的 OIDC:如果您在主站点上正确配置了 OIDC,那么它应该可以在次要站点上正常工作,无需额外配置。
- 禁用代理的独立 URL 的 OIDC:如果您在主站点上正确配置了 OIDC,那么它应该可以在次要站点上正常工作,无需额外配置。
- 启用代理的独立 URL 的 OIDC:Geo 使用启用代理的独立 URL 不支持 OpenID Connect。
LDAP
如果您在您的 主 站点上使用 LDAP,您还应该在每个 次要 站点上设置次要 LDAP 服务器。否则,用户将无法在 次要 站点上使用 HTTP 基本身份验证通过 HTTP(s) 执行 Git 操作。但是,用户仍然可以使用 SSH 和个人访问令牌进行 Git 操作。
{{< alert type=”note” >}}
所有 次要 站点共享一个 LDAP 服务器是可能的,但额外的延迟可能是一个问题。此外,请考虑在 灾难恢复 情况下,如果 次要 站点被提升为 主 站点时,哪个 LDAP 服务器是可用的。
{{< /alert >}}
检查您的 LDAP 服务文档以获取有关如何在您的 LDAP 服务中设置复制的说明。该过程根据使用的软件或服务而有所不同。