为身份验证响应配置SAML断言
在验证组织用户身份后,外部身份提供商会向华为云登录端点发送身份验证响应,该响应通过HTTP POST方式传输并遵循SAML 2.0的HTTP POST绑定规范,其中包含一个SAML断言(Assertion)。该断言由外部身份提供商生成,包含用户相关的属性(Attributes)及身份标识信息(如Subject和NameID),这些内容需要在外部身份提供商中进行配置,具体方式取决于所使用的外部身份提供商。当华为云接收到该断言后,会将其中部分属性映射为条件键,您可以在IAM身份策略的Condition中使用这些条件键,以实现基于属性的精细化访问控制。
Subject和NameID
- https://auth.huawei.com/saml
- https://auth.huawei.com/saml/acs/{provider_id}
如果启用了SAML加密,则登录URL必须包含华为云为该SAML身份提供商分配的ID,该标识符可在身份提供商的详情页面中获取。
- 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
Format属性的典型示例是 persistent(持久)、transient(临时)或由身份提供商自定义的完整URL,IAM会将其映射为saml:sub_type条件键的值。
- 如果该Format属性包含前缀urn:oasis:names:tc:SAML:2.0:nameid-format,那么IAM会将该前缀移除后作为saml:sub_type条件键的值。例如,对于urn:oasis:names:tc:SAML:2.0:nameid-format:transient,saml:sub_type条件键的值为transient。
- 如果该Format属性包含任何其他前缀,那么IAM会直接使用完整的Format属性值作为saml:sub_type条件键的值。
其中,persistent表示在所有会话中保持不变的稳定标识;transient表示仅在当前会话中有效的临时标识,每次认证都会生成新的值。
<Subject>
<NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">_dead322d4643f41430fe25e3</NameID>
<SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<SubjectConfirmationData NotOnOrAfter="2013-11-05T02:06:42.876Z" Recipient=https: //auth.huaweicloud.com/saml"/>
</SubjectConfirmation>
</Subject>
saml:aud条件键来自SAML recipient属性,它等价于OIDC令牌中的受众字段。
PrincipalTag SAML属性
(可选)您可使用将Name属性设置为https://www.huaweicloud.com/SAML/Attributes/PrincipalTag:{TagKey}的Attribute元素。此元素允许您将属性作为SAML断言中的会话标签传递。有关会话标签的更多信息,请参见传递会话标签。
<Attribute Name="https://www.huaweicloud.com/SAML/Attributes/PrincipalTag:Position"> <AttributeValue>ProductManager</AttributeValue> </Attribute> <Attribute Name="https://www.huaweicloud.com/SAML/Attributes/PrincipalTag:EmployeeID"> <AttributeValue>0711</AttributeValue> </Attribute>
<Attribute Name="https://www.huaweicloud.com/SAML/Attributes/TransitiveTagKeys"> <AttributeValue>Position</AttributeValue> <AttributeValue>EmployeeID</AttributeValue> </Attribute>
Agency SAML属性
Name标签中Attribute属性的值区分大小写。必须将其一字不差地设置为https://www.huaweicloud.com/SAML/Attributes/Agency。
<Attribute Name="https://www.huaweicloud.com/SAML/Attributes/Agency">
<AttributeValue>iam: :account-id:agency:agency-name1,iam: :account-id:samlProvider:provider-name</AttributeValue>
<AttributeValue>iam: :account-id:agency:agency-name2,iam: :account-id:samlProvider:provider-name</AttributeValue>
<AttributeValue>iam: :account-id:agency:agency-name3,iam: :account-id:samlProvider:provider-name</AttributeValue>
</Attribute> AgencySessionName SAML属性
<Attribute Name="https://www.huaweicloud.com/SAML/Attributes/AgencySessionName"> <AttributeValue>user-id-name</AttributeValue> </Attribute>
SessionDuration SAML属性
您可以在SAML断言中使用一个Attribute元素,其Name属性设置为https://www.huaweicloud.com/SAML/Attributes/SessionDuration。该元素包含一个AttributeValue,用于指定用户在必须重新获取临时安全凭证之前可访问华为云管理控制台的会话时长,该值为以秒为单位的整数,范围为900秒(15分钟)到43200秒(12小时)。如果未提供该属性,则默认会话时长为3小时,对应AssumeAgencyWithSAML API的默认duration_seconds参数值。
要使用该属性,必须配置SAML提供商以支持通过控制台登录Web终端节点(https://auth.huaweicloud.com/saml或 https://auth.huawei.com/saml/acs/{provider_id} )实现单点登录。
延长控制台会话时间可能增加凭证泄露风险,请谨慎操作。
<Attribute Name="https://www.huaweicloud.com/SAML/Attributes/SessionDuration"> <AttributeValue>1800</AttributeValue> </Attribute>
SourceIdentity SAML属性
您可以在SAML断言中使用一个Attribute元素,其Name属性设置为https://www.huaweicloud.com/SAML/Attributes/SourceIdentity。该元素包含一个AttributeValue,用于标识使用IAM信任委托的实体。当用户通过SAML会话在华为云中切换其他委托时,该SourceIdentity值会在委托链过程中持续传递,并在整个会话期间保持不变,无法在会话中途修改。该值会随每一次基于该委托会话发起的API请求一同记录,便于后续审计。管理员可以通过华为云CTS日志追踪SourceIdentity,从而识别使用同一信任委托执行操作的具体实体。
<Attribute Name="https://www.huaweicloud.com/SAML/Attributes/SourceIdentity"> <AttributeValue>Maria@example.com</AttributeValue> </Attribute>