7

我正在使用 AWS CLI 启用仅具有 TOTP MFA(无 SMS)的 MFA 用户池。

aws cognito-idp set-user-pool-mfa-config --user-pool-id xxxx_xxxx --mfa-configuration 可选 --software-token-mfa-configuration Enabled=true

{
    "SoftwareTokenMfaConfiguration": {
        "Enabled": true
    },
    "MfaConfiguration": "OPTIONAL"
}

看起来还可以,对吧?但是当我尝试设置用户首选项时,我不断收到此错误:

调用 AdminSetUserMFAPreference 操作时发生错误 (InvalidParameterException):用户尚未设置软件令牌 mfa

命令: aws cognito-idp admin-set-user-mfa-preference --user-pool-id xxxx_xxxx --username username@email.com --software-token-mfa-settings Enabled=true

尝试使用 admin-set-user-preference 也不起作用: aws cognito-idp admin-set-user-settings --user-pool-id us-xxxx-xxxx--username username@email.com --mfa -option DeliveryMedium=EMAIL

调用 AdminSetUserSettings 操作时发生错误 (InvalidParameterException):当前仅支持 phone_number 属性作为 MFA 选项。

我错过了什么?它是否需要文档中未提及的额外配置?


解决方案:

首先,您需要获取用户的 ACCESS_TOKEN 并继续启动 TOTP 流程:

aws cognito-idp associate-software-token --access-token ACCESS_TOKEN

(这将生成一个您可以在 Google Authenticator 中使用的唯一代码)

使用从 Authenticator 应用程序中检索到的 TOTP 代码运行:

aws cognito-idp verify-software-token --access-token ACCESS_TOKEN --user-code USER_CODE

使用来自上一个命令的成功消息,您可以更改用户首选项:

aws cognito-idp admin-set-user-mfa-preference --user-pool-id xxxxx --username xxxxxxx --software-token-mfa-settings Enabled=True,PreferredMfa=True

4

0 回答 0