【问题标题】:AWS Amplify Auth / Cognito talking too much?AWS Amplify Auth / Cognito 说得太多了?
【发布时间】:2019-06-29 16:22:54
【问题描述】:

目前使用Cognito Javascript SDK,当我发送的用户名存在与否时收到警告,我有点惊讶:

这是我正在使用的代码:

login(username, password) {
    const authenticationData = {
      Username : username,
      Password : password,
    };

    const authenticationDetails = new AuthenticationDetails(authenticationData);

    const userPool = new CognitoUserPool(this.poolData);
    const userData = {
      Username : username,
      Pool : userPool,
    };

    this.cognitoUser = new CognitoUser(userData);
    this.cognitoUser.authenticateUser(authenticationDetails, {
      onSuccess: function (result) {
        console.log(result);
      },
      newPasswordRequired: function(...) {

      },
      onFailure: function(err) {
        console.log(err);
      },
    });
  }

如果我使用错误的密码将username 设置为mytest(现有用户),我会收到以下错误:

“未授权异常” 用户名或密码错误。

没关系。但是如果我将username 设置为test12345(非现有用户),我会收到此错误:

“用户未发现异常” 用户不存在。

我认为告诉最终用户用户名是否存在并不安全。

我错了吗?是不是我做错了什么?

我希望只有第一个例外来通知最终用户登录失败。

【问题讨论】:

  • 这是一个安全问题,具有an answer
  • 谢谢,但我说的不是注册而是身份验证,而且我的用户群会很小。我认为亚马逊应该让我们能够决定是否要显示此消息。好像还不行……

标签: javascript amazon-web-services amazon-cognito aws-amplify


【解决方案1】:

我花了一些时间才找到它,但在用户池客户端设置中有一个选项防止用户存在错误(常规设置 -> 应用程序客户端)。见https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-managing-errors.html

【讨论】:

    猜你喜欢
    • 2019-03-04
    • 2021-07-31
    • 2019-12-14
    • 2021-09-28
    • 2020-11-18
    • 2019-12-25
    • 1970-01-01
    • 2021-11-16
    • 2023-02-03
    相关资源
    最近更新 更多