步骤 2:为 IdP 配置 SAML 断言 - Amazon Redshift
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

步骤 2:为 IdP 配置 SAML 断言

在创建 IAM 角色后,您可以在 IdP 应用程序中定义一个声明规则,以将组织中的用户或组映射到 IAM 角色。有关更多信息,请参阅 IAM 用户指南中的为身份验证响应配置 SAML 断言

如果选择使用可选的 GetClusterCredentials 参数 DbUserAutoCreateDbGroups,您有两个选择。您可以使用 JDBC 或 ODBC 连接设置这些参数的值,也可以将 SAML 属性元素添加到 IdP 以设置这些值。有关 DbUserAutoCreateDbGroups 参数的更多信息,请参阅步骤 5:配置 JDBC 或 ODBC 连接以使用 IAM 凭证

注意

如果您使用 IAM 策略变量 ${redshift:DbUser}(如GetClusterCredentials 的资源策略中所述),则 DbUser 的值将被替换为由 API 操作的请求上下文检索的值。Amazon Redshift 驱动程序使用由连接 URL 提供的 DbUser 变量的值,而不是作为 SAML 属性提供的值。

为了帮助保护该配置,我们建议您在 IAM 策略中使用一个条件以通过 DbUser 验证 RoleSessionName 值。您可以在 使用 GetClusterCredentials 的示例策略 中找到如何使用 IAM 策略设置条件。

要配置 IdP 以设置 DbUserAutoCreateDbGroups 参数,请包含以下 Attribute 元素:

  • Attribute 属性设置为“https://redshift.amazon.com/SAML/Attributes/DbUser”的 Name 元素

    AttributeValue 元素设置为要连接到 Amazon Redshift 数据库的用户的名称。

    AttributeValue 元素中的值必须为小写形式,以字母开头,仅包含字母数字字符、下划线 (_)、加号 (+)、圆点 (.)、@ 符号或连字符 (-),并且应少于 128 个字符。通常,用户名为用户 ID (例如,bobsmith) 或电子邮件地址 (例如,bobsmith@example.com)。此值不能包含空格 (例如,像 Bob Smith 这样的用户显示名称)。

    <Attribute Name="https://redshift.amazon.com/SAML/Attributes/DbUser"> <AttributeValue>user-name</AttributeValue> </Attribute>
  • Name 属性设置为“https://redshift.amazon.com/SAML/Attributes/AutoCreate”的 Attribute 元素

    可以将 AttributeValue 元素设置为 true 以创建新的数据库用户(如果不存在)。将 AttributeValue 设置为 false 可指定数据库用户必须存在于 Amazon Redshift 数据库中。

    <Attribute Name="https://redshift.amazon.com/SAML/Attributes/AutoCreate"> <AttributeValue>true</AttributeValue> </Attribute>
  • Attribute 属性设置为“https://redshift.amazon.com/SAML/Attributes/DbGroups”的 Name 元素

    该元素包含一个或多个 AttributeValue 元素。将每个 AttributeValue 元素设置为一个数据库组名称,DbUser 将在连接到 Amazon Redshift 数据库的会话期间加入该组。

    <Attribute Name="https://redshift.amazon.com/SAML/Attributes/DbGroups"> <AttributeValue>group1</AttributeValue> <AttributeValue>group2</AttributeValue> <AttributeValue>group3</AttributeValue> </Attribute>