如何排查 WorkSpaces 中的 SAML 2.0 身份验证问题?
当我尝试使用 SAML 2.0 身份验证登录我的 Amazon WorkSpaces 时,我收到一条错误消息。
解决方法
如果您尝试使用 SAML 2.0 身份验证登录 WorkSpaces,则可能会收到以下错误消息之一:
“Your request included an invalid SAML response”
“Something went wrong”
“Not authorized to perform sts:AssumeRoleWithSAML”。
先决条件: 确保服务控制策略 (SCP) 不会阻止 WorkSpaces:Stream API。有关如何排查 SCP 问题的信息,请参阅由于服务控制策略而拒绝访问 - 隐式拒绝。
要排查 SAML 2.0 身份验证问题,请参阅排查特定问题。
如果仍然存在身份验证问题,请执行以下操作。
验证您的 IAM 策略
检查您是否为用于 SAML 2.0 身份验证的 AWS Identity and Access Management (IAM) 角色分配了所需的权限。
完成以下步骤:
-
打开 IAM 控制台。
-
选择 IAM Role(IAM 角色)选项卡。
-
选择您用于 SAML 2.0 身份验证的 IAM 角色。
-
在 Permissions(权限)选项卡上,确认您的策略具有 workspaces:Stream 操作。
示例:{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "workspaces:Stream", "Resource": "arn:aws:workspaces:REGION-CODE:ACCOUNT-ID:directory/DIRECTORY-ID", "Condition": { "StringEquals": { "workspaces:userId": "${saml:sub}" } } } ] }注意: 将 REGION-CODE 替换为您的 AWS 区域,将 ACCOUNT-ID 替换为您的 AWS 账户 ID,将 DIRECTORY-ID 替换为您的目录。
-
选择 Trust relationships(信任关系)选项卡,然后检查您的信任关系策略配置:
确认您为 Principal(主体)指定了正确的账户信息。
确保该策略包含 sts:AssumeRoleWithSAML 和sts:TagSession 操作。
确保在 Condition(条件)下,SAML:sub_type 的值是 persistent(永久)。
示例:{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::ACCOUNT-ID:saml-provider/IDENTITY-PROVIDER" }, "Action": [ "sts:AssumeRoleWithSAML", "sts:TagSession" ], "Condition": { "StringEquals": { "SAML:sub_type": "persistent" } } }] }注意: 将 ACCOUNT-ID 替换为您的账户 ID,将 IDENTITY-PROVIDER 替换为您的身份提供者 (IdP)。
查看您的 SAML 2.0 响应
检查 NameID
NameID 元素的值必须为persistent(永久)。
示例:
<saml2:NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">workspaceUsername</saml2:NameID>
注意: 将workspaceUsername 替换为您的 WorkSpaces 用户名。
另外,请确保 workspaceUsername 与 Active Directory 中的 samaccountname 值相匹配。
检查 Role 属性
Role 属性的格式必须以相关 IAM 角色的 Amazon 资源名称 (ARN) 开头,后跟逗号,以 IdP 的 ARN 结尾。
示例:
<saml2:Attribute Name="https://aws.amazon.com/SAML/Attributes/Role" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" > <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string" >arn:aws:iam::123456789123:role/SAML_Role,arn:aws:iam::123456789123:saml-provider/SAMLIDP</saml2:AttributeValue> </saml2:Attribute>
注意: 将 arn:aws:iam::123456789123:role/SAML_Role 替换为 IAM 角色 ARN,将 arn:aws:iam::123456789123:saml-provider/SAMLIDP 替换为 IdP ARN。
检查 RoleSessionName 属性
RoleSessionName 的值必须是电子邮件地址或用户主体名称 (UPN)。
示例:
<saml2:Attribute Name="https://aws.amazon.com/SAML/Attributes/RoleSessionName" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" > <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string" >workspaceUsername@example.local</saml2:AttributeValue>
注意: 将 workspaceUsername@example.local 替换为用户的电子邮件地址。
如果 RoleSessionName 是电子邮件地址,则该电子邮件地址必须与用户的 Active Directory 电子邮件地址相匹配。
要验证 Active Directory 电子邮件地址,请完成以下步骤:
- 登录到管理您的 Active Directory 的域控制器或成员服务器。
- 选择 Active Directory Users and Computers(Active Directory 用户和计算机)。
- 选择用户。
- 打开 Properties(属性)的上下文菜单。
- 选择 General(常规)选项卡,然后找到 E-mail(电子邮件)的值。
RoleSessionName 值必须仅包含有效字符且不超过预期的字符数上限。确认属性类型、语法、格式和拼写准确无误。
检查 PrincipalTag:Email 属性
PrincipalTag:Email 的值必须与 Active Directory 中用户的电子邮件地址相匹配。
示例:
<saml2:Attribute Name="https://aws.amazon.com/SAML/Attributes/PrincipalTag:Email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" > <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string" >workspaceUsername@example.local</saml2:AttributeValue> </saml2:Attribute>
注意: 将 workspaceUsername@example.local 替换为用户的电子邮件地址。
如果上述任何属性的值不同或不正确,请更新您的 SAML 2.0 IdP 配置。
相关信息
- 语言
- 中文 (简体)
