我想為 Amazon Cognito 使用者集區設定電子郵件多重要素驗證 (MFA),但我不確定所需的組態。
解決方法
**注意:**如果您在執行 AWS Command Line Interface (AWS CLI) 命令時收到錯誤訊息,請參閱對 AWS CLI 錯誤進行疑難排解。此外,請確定您使用的是最新的 AWS CLI 版本。
解決功能方案錯誤
您只能在 Essentials 或 Plus 功能方案中啟用電子郵件 MFA。
如果您的使用者集區是 Lite 方案,並嘗試啟用電子郵件 MFA,那麼您可能會收到錯誤。
在 Amazon Cognito 主控台中,您可能會看到以下錯誤訊息:
「Can't enable email MFA when user pool is not under the Essentials or Plus plan」
如果您使用的是 AWS CLI,您可能會收到以下錯誤訊息:
「An error occurred (FeatureUnavailableInTierException) when calling the SetUserPoolMfaConfig operation: The following feature is not available for the LITE pricing tier configured: Email MFA」
若要解決功能方案錯誤,請升級至 Essentials 或 Plus 功能方案。若要更改方案,請參閱選取功能方案。
解決電子郵件組態錯誤
Amazon Cognito 使用 Amazon Simple Email Service (Amazon SES) 將 MFA 代碼傳送至使用者的電子郵件地址。啟用電子郵件 MFA 時,您必須將使用者集區設定為使用 Amazon SES,而不是 預設電子郵件組態。
如果使用預設電子郵件組態,您可能會收到錯誤。
在 Amazon Cognito 主控台中,您可能會看到以下錯誤訊息:
「Can't enable email MFA with email sending in Send email with Cognito configuration」
如果您使用的是 AWS CLI,您可能會收到以下錯誤訊息:
「An error occurred (InvalidParameterException) when calling the SetUserPoolMfaConfig operation: Cannot set EmailMfaConfiguration when user pool EmailConfiguration contains an EmailSendingAccount of COGNITO_DEFAULT.Update the value of EmailSendingAccount」
若要將電子郵件 MFA 代碼傳送給使用者,請設定 Amazon SES 帳戶,然後使用您的使用者集區設定 Amazon SES。
解決帳戶復原錯誤
為了維護安全性,Amazon Cognito 要求 MFA 與帳戶復原使用不同的方法。使用者必須有不同的管道來接收 MFA 代碼與密碼重設代碼。
使用者無法在相同的電子郵件地址或電話號碼同時接收 MFA 代碼與密碼重設代碼。例如,如果您為 MFA 設定電子郵件,則使用者必須使用 SMS 來進行帳號復原。如果您在未設定額外復原方法的情況下啟用電子郵件 MFA,那麼您可能會收到錯誤。
在 Amazon Cognito 主控台中,您可能會看到以下錯誤訊息:
「Can't enable email MFA when user pool account recovery method is email-only or legacy.」
如果您使用的是 AWS CLI,您可能會收到以下錯誤訊息:
「An error occurred (InvalidParameterException) when calling the SetUserPoolMfaConfig operation: Cannot set EmailMfaConfiguration when user pool AccountRecoverySetting is not set or contains only verified_email in RecoveryMechanisms.At least one recovery mechanism other than verified_email should be present」
若要解決錯誤,請設定一個額外的帳戶復原方法。然後,再設定電子郵件 MFA。如需操作說明,請參閱在 Amazon Cognito 主控台中設定電子郵件 MFA 的 電子郵件 MFA。
**注意:**為了幫助使用者重設密碼,最佳實務是在使用者集區中,將 email 與 phone_number 設為必填屬性。
相關資訊
將 MFA 新增至使用者集區
Amazon SES 電子郵件組態