这里推荐的路径是使用SSO / identity federation,但我提出了一种手动的单策略解决方案,如果您还没有 SSO,则可以更轻松地进行管理。我的解决方案仍然存在风险,但仅限于初始帐户设置过程。它涉及使用 NewUser 标记手动标记新 IAM 用户,然后在他们重置密码并配置 MFA 后手动取消标记。
以下指南假设您使用的是the recommended policy from AWS to allow MFA-authenticated IAM users to manage their own credentials on the My Security Credentials page。
编辑您的 "Sid": "DenyAllExceptListedIfNoMFA" 块所在的 MFA 策略,并将其替换为以下内容:
{
"Sid": "DenyAllExceptListedIfNoMFAAndNewUser",
"Effect": "Deny",
"NotAction": [
"iam:CreateVirtualMFADevice",
"iam:EnableMFADevice",
"iam:GetUser",
"iam:ListMFADevices",
"iam:ListVirtualMFADevices",
"iam:ResyncMFADevice",
"sts:GetSessionToken",
"iam:ChangePassword"
],
"Resource": "*",
"Condition": {
"BoolIfExists": {
"aws:MultiFactorAuthPresent": "false"
}
}
},
{
"Sid": "DenyAllExceptListedIfNoMFA",
"Effect": "Deny",
"NotAction": [
"iam:CreateVirtualMFADevice",
"iam:EnableMFADevice",
"iam:GetUser",
"iam:ListMFADevices",
"iam:ListVirtualMFADevices",
"iam:ResyncMFADevice",
"sts:GetSessionToken"
],
"Resource": "*",
"Condition": {
"BoolIfExists": {
"aws:MultiFactorAuthPresent": "false"
},
"StringNotEqualsIfExists": {
"iam:ResourceTag/NewUser": "true"
}
}
}
创建一个新用户并添加一个NewUser 标记,并将值设置为true。
将凭据发送给新用户。首次登录后,从他们的 IAM 用户资源中删除 NewUser 标签。
你可以看到an example of my full policy here。