如何取消 AWS Cognito 中的密码重置?

How to cancel a password reset in AWS Cognito?

我使用 AWS Cognito 作为 React 应用程序中的身份验证提供程序。我注意到重置密码流程存在问题:

假设我忘记了密码并请求重设密码。 Cognito 向我发送了一封包含安全代码的电子邮件。然后,我就记住了密码,不想再改了。我不能,因为即使我使用正确的密码登录,它仍会将我发送到“设置新密码”页面。这似乎是一个安全问题,因为只要知道其他用户的电子邮件地址,任何人都可以强制他们重设密码。

这是 Cognito 的设计还是我使用 Cognito 时的错误?

您需要验证被遗忘的 password/authentication 流程是如何在您的应用中实现的。重置密码页面不应发送 NEW_PASSWORD_REQUIRED MFA 质询,也不应将用户状态更改为需要用户池中的新密码。

ForgotPassword API call generates the reset code for the user, whereas the ConfirmForgotPassword API call accepts the code and allows the user to change the password. These API calls do not change the user's status for resetting their password, or create the NEW_PASSWORD_REQUIRED MFA 挑战。

为了完整起见,密码重置代码一旦发送​​就无法取消。 The code is valid for 24 hours,尽管发送另一个代码会使第一个代码无效。