为身份验证响应配置 SAML 断言 - Amazon Identity and Access Management
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

为身份验证响应配置 SAML 断言

在您验证组织中的用户身份后,外部身份提供者(IdP)将向 Amazon SAML 端点(https://region-code.signin.aws.amazon.com/saml)发送身份验证响应。有关潜在 region-code 替换的列表,请参阅 Amazon 登录端点中的 Region(区域)列。此响应是一个包含 SAML 令牌的 POST 请求,该令牌遵循适用于 SAML 2.0 的 HTTP POST 绑定标准,其中包含以下元素或断言。您可在与 SAML 兼容的 IdP 中配置这些断言。请参考 IdP 文档,以了解有关如何输入这些声明的说明。

当 IdP 将包含断言的响应发送到 Amazon 时,许多传入断言将映射到 Amazon 上下文密钥。可以在 IAM policy 中使用 Condition 元素检查这些上下文密钥。可用映射的列表如将 SAML 属性映射到 Amazon 信任策略上下文密钥部分中所示。

SubjectNameID

以下摘录显示了一个示例。用您自己的值替代标记值。同时包含 SubjectConfirmationSubjectConfirmationData 属性的 NotOnOrAfter 元素必须恰好具有一个 Recipient 元素。这些属性包含的值必须与 Amazon 端点(https://region-code.signin.aws.amazon.com/saml)匹配。有关可能的 region-code 值的列表,请参阅 Amazon 登录端点中的 Region(区域)列。对于 Amazon 值,您也可以使用 https://signin.aws.amazon.com/static/saml,如以下示例所示。

NameID 元素的值可以是持久性的、瞬态的或由 IdP 解决方案提供的完整格式 URI 构成。持久性值表示在不同会话之间用户的 NameID 值是相同的。如果值是瞬态的,则用户在每个会话中拥有不同的 NameID 值。单点登录交互支持以下类型的标识符:

  • urn:oasis:names:tc:SAML:2.0:nameid-format:persistent

  • urn:oasis:names:tc:SAML:2.0:nameid-format:transient

  • urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress

  • urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified

  • urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName

  • urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName

  • urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos

  • urn:oasis:names:tc:SAML:2.0:nameid-format:entity

<Subject> <NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">_cbb88bf52c2510eabe00c1642d4643f41430fe25e3</NameID> <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"> <SubjectConfirmationData NotOnOrAfter="2013-11-05T02:06:42.876Z" Recipient="https://signin.aws.amazon.com/saml"/> </SubjectConfirmation> </Subject>
重要

saml:aud 上下文键来自 SAML recipient 属性,因为它等同于 OIDC 受众字段(例如 accounts.google.com:aud)的 SAML。

PrincipalTag SAML 属性

(可选)您可使用将 Name 属性设置为 https://aws.amazon.com/SAML/Attributes/PrincipalTag:{TagKey}Attribute 元素。此元素允许您将属性作为 SAML 断言中的会话标签传递。有关会话标签的更多信息,请参阅 在 Amazon STS 中传递会话标签

要将属性作为会话标签传递,请包含指定标签值的 AttributeValue 元素。例如,要传递标签键/值对 Project = MarketingCostCenter = 12345,请使用以下属性。为每个标签包含一个单独的 Attribute 元素。

<Attribute Name="https://aws.amazon.com/SAML/Attributes/PrincipalTag:Project"> <AttributeValue>Marketing</AttributeValue> </Attribute> <Attribute Name="https://aws.amazon.com/SAML/Attributes/PrincipalTag:CostCenter"> <AttributeValue>12345</AttributeValue> </Attribute>

要将上述标签设置为可传递,请包含另一个 Attribute 元素并将 Name 属性设置为 https://aws.amazon.com/SAML/Attributes/TransitiveTagKeys。这是一个可选的多值属性,可将您的会话标签设置为可传递。当您使用 SAML 会话代入 Amazon 中的另一个角色时,可传递标签将保留。这称为角色链。例如,要将 PrincipalCostCenter 标签均设置为可传递,请使用以下属性指定键。

<Attribute Name="https://aws.amazon.com/SAML/Attributes/TransitiveTagKeys"> <AttributeValue>Project</AttributeValue> <AttributeValue>CostCenter</AttributeValue> </Attribute>

Role SAML 属性

您可使用将 Name 属性设置为 https://aws.amazon.com/SAML/Attributes/RoleAttribute 元素。此元素包含一个或多个 AttributeValue 元素,这些元素可列出用户通过 IdP 映射到的 IAM 身份提供程序和角色。IAM 角色和 IAM 身份提供程序指定为逗号分隔的 ARN 对,格式与传递到 AssumeRoleWithSAMLRoleArnPrincipalArn 参数相同。此元素必须至少包含一个角色/提供商对(AttributeValue 元素),也可以包含多个对。如果该元素包含多个对,则用户需要选择其使用 WebSSO 登录 Amazon Web Services Management Console 时要代入的角色。

重要

Name 标签中 Attribute 属性的值区分大小写。必须将其一字不差地设置为 https://aws.amazon.com/SAML/Attributes/Role

<Attribute Name="https://aws.amazon.com/SAML/Attributes/Role"> <AttributeValue>arn:aws:iam::account-number:role/role-name1,arn:aws:iam::account-number:saml-provider/provider-name</AttributeValue> <AttributeValue>arn:aws:iam::account-number:role/role-name2,arn:aws:iam::account-number:saml-provider/provider-name</AttributeValue> <AttributeValue>arn:aws:iam::account-number:role/role-name3,arn:aws:iam::account-number:saml-provider/provider-name</AttributeValue> </Attribute>

RoleSessionName SAML 属性

您可使用将 Name 属性设置为 https://aws.amazon.com/SAML/Attributes/RoleSessionNameAttribute 元素。该元素包含一个为临时凭证提供标识符的 AttributeValue 元素,这些凭证是针对 SSO 颁发的。您可以使用此选项将临时凭证与正在使用您应用程序的用户相关联。该元素用于在 Amazon Web Services Management Console中显示用户信息。AttributeValue 元素中的值长度必须介于 2 到 64 个字符之间,只能包含字母数字字符、下划线和以下字符:. , + = @ -(连字符)。它不能含有空格。该值通常是用户 ID (johndoe) 或电子邮件地址 (johndoe@example.com)。该值不应包含空格,如用户的显示名称 (John Doe)。

重要

Name 标签中 Attribute 属性的值区分大小写。必须将其一字不差地设置为 https://aws.amazon.com/SAML/Attributes/RoleSessionName

<Attribute Name="https://aws.amazon.com/SAML/Attributes/RoleSessionName"> <AttributeValue>user-id-name</AttributeValue> </Attribute>

SessionDuration SAML 属性

(可选)您可使用将 Name 属性设置为 https://aws.amazon.com/SAML/Attributes/SessionDuration"Attribute 元素。该元素包含一个 AttributeValue 元素,它指定用户在必须请求新的临时凭证之前可访问 Amazon Web Services Management Console的时间长度。该值是一个表示会话秒数的整数。该值的范围是 900 秒 (15 分钟) 到 43200 秒 (12 小时)。如果该属性不存在,则凭证持续时间为 1 小时 (DurationSeconds API 的 AssumeRoleWithSAML 参数的默认值)。

要使用该属性,您必须配置 SAML 提供商,以通过控制台登录 Web 终端节点 (https://region-code.signin.aws.amazon.com/saml) 提供对 Amazon Web Services Management Console的单一登录访问。有关可能的 region-code 值的列表,请参阅 Amazon 登录端点中的 Region(区域)列。您可以选择使用以下 URL:https://signin.aws.amazon.com/static/saml。请注意,该属性仅将会话扩展到 Amazon Web Services Management Console。它不能延长其他凭证的有效期。但是,如果它存在于 AssumeRoleWithSAML API 调用中,则可以用来缩短 会话的持续时间。调用返回的凭证的默认生命周期为 60 分钟。

另请注意,如果还定义了 SessionNotOnOrAfter 属性,则两个属性的 lesser(较小值)(SessionDurationSessionNotOnOrAfter)将建立控制台会话的最大持续时间。

在启用具有更长持续时间的控制台会话时,可能产生凭证外泄的风险。为了帮助缓解这种风险,您可以通过在 IAM 控制台页面的 Role Summary (角色摘要) 上选择 Revoke Sessions(撤销会话)立即禁用所有角色的有效控制台会话。有关更多信息,请参阅撤消 IAM 角色临时安全凭证

重要

Name 标签中 Attribute 属性的值区分大小写。必须将其一字不差地设置为 https://aws.amazon.com/SAML/Attributes/SessionDuration

<Attribute Name="https://aws.amazon.com/SAML/Attributes/SessionDuration"> <AttributeValue>1800</AttributeValue> </Attribute>

SourceIdentity SAML 属性

(可选)您可使用将 Name 属性设置为 https://aws.amazon.com/SAML/Attributes/SourceIdentityAttribute 元素。该元素包含一个 AttributeValue 元素,为使用 IAM 角色的人员或应用程序提供标识符。当您使用 SAML 会话代入 Amazon 中的另一个角色时,源身份的值将保留,称为角色链。源身份的值存在于对角色会话期间执行的每个操作的请求中。在角色会话期间无法更改已设置的值。然后,管理员可以使用 Amazon CloudTrail 日志来监控和审计源身份信息,以确定谁在使用共享角色执行操作。

AttributeValue 元素中的值长度必须介于 2 到 64 个字符之间,只能包含字母数字字符、下划线和以下字符:. , + = @ -(连字符)。它不能含有空格。该值通常是与用户关联的属性,例如用户 ID (johndoe) 或电子邮件地址 (johndoe@example.com)。该值不应包含空格,如用户的显示名称 (John Doe)。有关使用基于身份的策略的更多信息,请参阅 监控和控制使用所担任角色执行的操作

重要

如果您的 SAML 断言配置为使用 SourceIdentity 属性,则您的角色信任策略还必须包含 sts:SetSourceIdentity 操作,否则代入角色操作会失败。有关使用基于身份的策略的更多信息,请参阅 监控和控制使用所担任角色执行的操作

要传递源身份属性,请包含 AttributeValue 元素,指定源身份的值。例如,要传递源身份 DiegoRamirez 使用以下属性。

<Attribute Name="https://aws.amazon.com/SAML/Attributes/SourceIdentity"> <AttributeValue>DiegoRamirez</AttributeValue>

将 SAML 属性映射到 Amazon 信任策略上下文密钥

本部分中的表列出了常用的 SAML 属性以及它们在 Amazon 中映射到信任策略条件上下文密钥的方式。您可以使用这些键来控制对角色的访问。为此,请将键与 SAML 访问请求中所附带断言包含的值进行比较。

重要

这些键仅在 IAM 信任策略(可决定谁能担任角色的策略)中可用,并且不适用于权限策略。

在 eduPerson 和 eduOrg 属性表中,值是以字符串或字符串列表的形式键入的。对于字符串值,您可以使用 StringEqualsStringLike 条件测试 IAM 信任策略中的这些值。对于包含字符串列表的值,您可以使用 ForAnyValueForAllValues 策略集运算符测试信任策略中的这些值。

注意

每个 Amazon 上下文密钥只能包含一个断言。如果包含多个声明,将仅映射其中一个。

eduPerson 和 eduOrg 属性
eduPerson 或 eduOrg 属性(Name 密钥) 映射至此 Amazon 上下文密钥(FriendlyName 密钥) 类型

urn:oid:1.3.6.1.4.1.5923.1.1.1.1

eduPersonAffiliation

字符串列表

urn:oid:1.3.6.1.4.1.5923.1.1.1.2

eduPersonNickname

字符串列表

urn:oid:1.3.6.1.4.1.5923.1.1.1.3

eduPersonOrgDN

字符串

urn:oid:1.3.6.1.4.1.5923.1.1.1.4

eduPersonOrgUnitDN

字符串列表

urn:oid:1.3.6.1.4.1.5923.1.1.1.5

eduPersonPrimaryAffiliation

字符串

urn:oid:1.3.6.1.4.1.5923.1.1.1.6

eduPersonPrincipalName

字符串

urn:oid:1.3.6.1.4.1.5923.1.1.1.7

eduPersonEntitlement

字符串列表

urn:oid:1.3.6.1.4.1.5923.1.1.1.8

eduPersonPrimaryOrgUnitDN

字符串

urn:oid:1.3.6.1.4.1.5923.1.1.1.9

eduPersonScopedAffiliation

字符串列表

urn:oid:1.3.6.1.4.1.5923.1.1.1.10

eduPersonTargetedID

字符串列表

urn:oid:1.3.6.1.4.1.5923.1.1.1.11

eduPersonAssurance

字符串列表

urn:oid:1.3.6.1.4.1.5923.1.2.1.2

eduOrgHomePageURI

字符串列表

urn:oid:1.3.6.1.4.1.5923.1.2.1.3

eduOrgIdentityAuthNPolicyURI

字符串列表

urn:oid:1.3.6.1.4.1.5923.1.2.1.4

eduOrgLegalName

字符串列表

urn:oid:1.3.6.1.4.1.5923.1.2.1.5

eduOrgSuperiorURI

字符串列表

urn:oid:1.3.6.1.4.1.5923.1.2.1.6

eduOrgWhitePagesURI

字符串列表

urn:oid:2.5.4.3

cn

字符串列表

Active Directory 属性
AD 属性 映射到此 Amazon 上下文密钥 类型

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name

name

字符串

http://schemas.xmlsoap.org/claims/CommonName

commonName

字符串

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname

givenName

字符串

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname

surname

字符串

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress

mail

字符串

http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid

uid

字符串

X.500 属性
X.500 属性 映射到此 Amazon 上下文密钥 类型

2.5.4.3

commonName

字符串

2.5.4.4

surname

字符串

2.4.5.42

givenName

字符串

2.5.4.45

x500UniqueIdentifier

字符串

0.9.2342.19200300100.1.1

uid

字符串

0.9.2342.19200300100.1.3

mail

字符串

0.9.2342.19200300.100.1.45

organizationStatus

字符串