The Atlas Kubernetes Operator (AKO) provides support for configuring federated authentication in MongoDB Atlas using the AtlasFederatedAuth Custom Resource.
联合身份验证使您能够使用身份提供程序 (IdP) 跨系统链接用户凭证。它提供两个核心目的:
管理用户对Atlas用户界面的访问权限(限制查看、创建和配置资源的权限)。
对Atlas集群进行身份验证和授权访问权限(针对人类用户和应用程序)。
可以通过AtlasFederatedAuth 自定义资源同时配置这两个功能。
注意
Atlas Kubernetes Operator支持在Atlas组织中配置现有IdP,而不是在Atlas中创建 IdP。您必须先完成此过程,然后才能将此资源与 AKO 一起使用。
Learn how to create a SAML IdP for UI Access in Manage Identity Providers.
Learn how to create an IdP for cluster access for a workforce (OIDC) in Configure an External Identity Provider Application.
在准备外部身份提供者中了解如何为应用程序/工作负载的集群访问权限创建 IdP (OAuth 2.0)。
Atlas UI Access (SAML)
Atlas访问权限(或用户界面访问权限)允许组织所有者根据在 身份提供程序(例如Microsoft Entra ID或 Google Workspace)中的角色,在组织中的用户进行身份验证后自动将Atlas中的角色授予给他们。
注意
启用联合身份提供程序后, Atlas会禁用所有其他身份验证方法。
创建用户界面访问身份提供程序并将其与组织关联后,您可以使用Atlas Kubernetes Operator对其进行配置。
此示例执行以下操作:
为链接到指定密钥的组织启用联合身份验证。
将
my-org-domain.com添加为已批准的域。为组织启用域限制。
禁用SSO调试。
Grants the
Organization Memberrole to users after authenticating.Maps the
Organization Ownerrole for the organization and applies the role mapping to an IdP group namedorg-admin.Maps the
Organization Project CreatorandProject Ownerroles for a project in the organization nameddev-projectand applies the role mapping to an IdP group nameddev-team.
注意
The spec.roleMappings.roleAssignments parameter must include at least one organization role within the current organization or the projects in the organization.
示例:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasFederatedAuth metadata: name: atlas-default-federated-auth namespace: mongodb-atlas-system spec: enabled: true connectionSecretRef: name: my-org-secret namespace: mongodb-atlas-system domainAllowList: - my-org-domain.com domainRestrictionEnabled: true ssoDebugEnabled: false postAuthRoleGrants: - ORG_MEMBER roleMappings: - externalGroupName: org-admin roleAssignments: - role: ORG_OWNER - externalGroupName: dev-team roleAssignments: - role: ORG_GROUP_CREATOR - projectName: dev-project role: GROUP_OWNER EOF
有关配置 AtlasFederatedAuth资源的更多信息,请参阅 AtlasFederatedAuth 自定义资源。
Atlas集群访问 (OIDC/OAuth 2.0)
集群访问权限允许组织所有者使用身份提供者(使用 OIDC 或 OAuth 2.0)根据 角色 在 身份提供程序 中提供对Atlas中数据库集群的数据访问。还可以根据访问权限权限是授予人类用户还是应用程序来进一步区分此功能:
工作负载 用于应用程序;允许外部应用程序通过程序化身份进行身份验证,例如 Azure 中的服务主体或 Google Cloud Platform 中的服务账户,使用 OAuth2.0 。
Workforce 是为用户服务的;允许使用 OIDC 通过外部 身份提供程序(例如Microsoft Entra ID或 Okta)对数据库进行身份验证和授权。
要通过 AKO 启用 Atlas 集群访问,请将 身份提供程序 ID 添加到 AtlasFederatedAuth 资源中的 dataAccessIdentityProviderIds 字段。
apiVersion: atlas.mongodb.com/v1 kind: AtlasFederatedAuth metadata: name: atlas-default-federated-auth namespace: mongodb-atlas-system spec: enabled: true dataAccessIdentityProviders: - 32b6e34b3d91647abb20e7b8 - 42d8v92k5a34184rnv93f0c1 connectionSecretRef: name: my-org-secret namespace: mongodb-atlas-system
有关配置 AtlasFederatedAuth资源的更多信息,请参阅 AtlasFederatedAuth 自定义资源。
身份验证会启用 身份提供程序 在组织内部使用,并且现在可以在 AtlasDatabaseUser 中使用此 身份提供程序 授予集群访问权限,方法是配置oidcAuthType 并在username 字段中设置相应的 ID 和名称。
对于劳动力访问权限,将
oidcAuthType字段设立为USER,将databaseName字段设置为admin,并将username字段设置为<Atlas IdP ID>/IdP Username。对于工作负载访问权限,将
oidcAuthType字段设立为IDP_GROUP,将databaseName字段设置为$external,并将username字段设置为<Atlas IdP ID>/IdP Group Name。
apiVersion: atlas.mongodb.com/v1 kind: AtlasDatabaseUser metadata: name: my-workload-user namespace: mongodb-atlas-system spec: databaseName: $external roles: - roleName: "readWrite" databaseName: "my-database" projectRef: name: my-project username: idp-id-in-atlas/my-idp-group-name oidcAuthType: IDP_GROUP
apiVersion: atlas.mongodb.com/v1 kind: AtlasDatabaseUser metadata: name: my-workforce-user namespace: mongodb-atlas-system spec: databaseName: admin roles: - roleName: "readWrite" databaseName: "my-database" projectRef: name: my-project username: idp-id-in-atlas/my-idp-user-name oidcAuthType: USER
有关配置 AtlasDatabaseUser资源的更多信息,请参阅 AtlasDatabaseUser 自定义资源。