【问题标题】:admin-initiate-auth with AWS CLI on a Cognito App-client with a secretadmin-initiate-auth 在 Cognito 应用程序客户端上使用 AWS CLI 并带有密钥
【发布时间】:2019-04-24 01:58:36
【问题描述】:

我正在尝试使用 AWS CLI 来确认 Cognito 用户(将他们的状态从 FORCE_CHANGE_PASSWORD 更改为 CONFIRMED)。我在没有和应用程序秘密的应用程序客户端上成功地做到了这一点,但我不知道如何在有应用程序客户端的应用程序客户端中做到这一点。根据 AWS CLI 参考,这里:

https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/admin-initiate-auth.html

我应该可以通过传递 App 机密来做到这一点,如下所示:

(为了格式化,我输入的是整行)

aws cognito-idp admin-initiate-auth 
    --user-pool-id us-east-1_xxxxxxxx 
    --region=us-east-1 
    --client-id xxxxxxxxxxxxxxxxxxxxx
    --auth-flow ADMIN_NO_SRP_AUTH
    --auth-parameters
        USERNAME=TestUser
        PASSWORD='Test_Password'
        SECRET_HASH=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
    --profile AwsProfile

我从 Web 控制台的 App 客户端密码 字段中获取了密码值,并启用了“启用登录 API 以进行基于服务器的身份验证 (ADMIN_NO_SRP_AUTH)”。

但是,我不断收到以下回复: An error occurred (NotAuthorizedException) when calling the AdminInitiateAuth operation: Unable to verify secret hash for client xxxxxxxxxxxxxxxxxxxxxxx

我做错了什么?

【问题讨论】:

  • 您传递的 SECRET_HASH 值是多少?它应该是用户 ID 和客户端 ID 的 MAC,使用 HmacSHA256 登录客户端密钥并以 Base64 编码。
  • 不,我以为我只需要 Cognito 提供的“App Secret”。我怎么知道我是否需要这个 HmacSHA256 哈希?你能指出文档中的某个地方吗?

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


【解决方案1】:

按如下方式计算您的 SECRET_HASH:

Base64(HMAC_SHA256(“客户端密钥”,“用户名”+“客户端 ID”) )

参考:https://docs.amazonaws.cn/en_us/cognito/latest/developerguide/signing-up-users-in-your-app.html#cognito-user-pools-computing-secret-hash

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-20
    • 2020-04-19
    • 1970-01-01
    • 2020-10-23
    • 1970-01-01
    • 2023-03-05
    • 2021-08-13
    • 2018-05-31
    相关资源
    最近更新 更多