AWS Cognito - 确认管理员创建的用户后运行 Lambda

问题描述 投票:0回答:2

我正在实施一个流程,管理员可以邀请用户访问我的平台。我有一个 lambda,它使用

AdminCreateUser
在 Cognito 中创建用户,然后向收件人发送邀请电子邮件,其中包含临时密码和登录链接。然后他们可以登录并设置新密码,确认其帐户。我已经实施了 AWS 文档中概述的流程。

当管理员邀请用户时,会在 DynamoDB 中为该用户创建一个条目,并将

pending
属性设置为
true
。当用户完成
false
挑战以完成此过程时,我想将其设置为
NEW_PASSWORD_REQUIRED

我最初认为

PostConfirmation
Lambda 触发器非常适合此用例,但进一步阅读后,我发现在由
AdminCreateUser
调用创建的用户得到确认后,不会触发此功能。

有没有办法捕获用户完成

NEW_PASSWORD_REQUIRED
挑战的事件,而无需客户自我报告他们已经这样做了?

amazon-web-services aws-lambda amazon-cognito
2个回答
0
投票

我正在尝试实现相同的功能,但当我调用

const command = new AdminCreateUserCommand(params); const response = await cognitoIdentityServiceProvider.send(command);

时,我的 lambda 超时

我已将以下策略分配给 Lambda。你能请我获得正确的许可吗?

 {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "VisualEditor0",
                "Effect": "Allow",
                "Action": [
                    "cognito-idp:AdminCreateUser",
                    "cognito-idp:AdminAddUserToGroup"
                ],
                "Resource": "arn:aws:cognito-idp:*:*:userpool/*"
            }
        ]
    }

0
投票

AWS 文档说:

You create custom workflows by assigning AWS Lambda functions to user pool triggers. When you use the RespondToAuthChallenge API action, Amazon Cognito invokes any functions that are assigned to the following triggers: post authentication, pre token generation, define auth challenge, create auth challenge, and verify auth challenge

我想说你需要处理任何这些触发器并自定义行为。

© www.soinside.com 2019 - 2024. All rights reserved.