【问题标题】:How to use AWS amplify securely如何安全地使用 AWS 放大
【发布时间】:2022-01-23 23:11:37
【问题描述】:

我正在试验 AWS 放大。特别是,希望为用户提供一种更改其 cognito 密码的方法。鉴于客户端 ID 已暴露,我不明白如何以安全的方式完成此操作。

我错过了什么?

这是我正在使用的文档......

https://github.com/aws-amplify/amplify-js/tree/main/packages/amazon-cognito-identity-js

【问题讨论】:

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


    【解决方案1】:

    Amplify 在后台使用 amazon-cognito-identity-js。所以使用来自 Amplify(aws-amplify) 的 Auth 模块。

    import { Auth } from 'aws-amplify' 
    

    然后您可以让用户更改他们的密码,因为他们已经登录并且所有必要的信息都已经在其中(浏览器)。

    const currentUser = await Auth.currentAuthenticatedUser();
    
    const currentPassword = "";
    const newPassword = "";
    
    await Auth.changePassword(
      currentUser,
      currentPassword,
      newPassword
    );
    

    【讨论】:

    • 谢谢。我最终做了同样的事情,但没有使用放大。相反,我点击了此处描述的这个端点 (docs.aws.amazon.com/cognito-user-identity-pools/latest/…),它需要访问令牌。所以这可以安全地完成。我没有使用放大(至少到目前为止)我不需要它并且不想要添加的依赖项。
    猜你喜欢
    • 1970-01-01
    • 2020-09-15
    • 2012-08-26
    • 2011-06-29
    • 2016-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多