Cognito 用户迁移触发器未触发

Jac*_*dge 4 amazon-web-services amazon-cognito aws-lambda

在 eu-west-1 的认知用户池中。我正在尝试为用户迁移添加触发器。当我尝试以不存在的用户身份登录时,它不会触发。我已经通过编写一个简单的 python lambda 测试了这一点:

def handler(event, context):
    print(event)
    return event
Run Code Online (Sandbox Code Playgroud)

在日志中,如果用户不存在,我永远不会看到此运行。然后我尝试设置所有触发器以使用我看到的这个 lambda(使用现有用户登录时):

  • PreAuthentication_Authentication
  • PostAuthentication_Authentication
  • TokenGeneration_Authentication

当使用不存在的用户登录时,即。迁移候选人 - 我没有看到触发器被触发。

这是地区特定的问题吗?我们是否需要启用触发器才能触发?我们是否需要为非授权用户或登录失败触发的触发器启用特定权限?

JRT*_*JRT 11

要调用用户迁移触发器,您必须使用 USER_PASSWORD_AUTH 进行身份验证

authenticationFlowType: 'USER_PASSWORD_AUTH'
Run Code Online (Sandbox Code Playgroud)

执行此操作的一个示例是下方底部的 Amplify 中的此配置

import Amplify from 'aws-amplify';

Amplify.configure({
    Auth: {

    // REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID
    identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab',

    // REQUIRED - Amazon Cognito Region
    region: 'XX-XXXX-X',

    // OPTIONAL - Amazon Cognito Federated Identity Pool Region 
    // Required only if it's different from Amazon Cognito Region
    identityPoolRegion: 'XX-XXXX-X',
    // OPTIONAL - Configuration for cookie storage
    // Note: if the secure flag is set to true, then the cookie transmission requires a secure protocol
    cookieStorage: {
    // REQUIRED - Cookie domain (only required if cookieStorage is provided)
        domain: '.yourdomain.com',
    // OPTIONAL - Cookie path
        path: '/',
    // OPTIONAL - Cookie expiration in days
        expires: 365,
    // OPTIONAL - Cookie secure flag
    // Either true or false, indicating if the cookie transmission requires a secure protocol (https).
        secure: true
    },

    // OPTIONAL - customized storage object
    storage: new MyStorage(),

    // OPTIONAL - Manually set the authentication flow type. Default is 'USER_SRP_AUTH'
    authenticationFlowType: 'USER_PASSWORD_AUTH'

    // OPTIONAL - Amazon Cognito User Pool ID
    userPoolId: 'XX-XXXX-X_abcd1234',

    // OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)
    userPoolWebClientId: 'a1b2c3d4e5f6g7h8i9j0k1l2m3',

    // OPTIONAL - Enforce user authentication prior to accessing AWS resources or not
    mandatorySignIn: false,

}
});
Run Code Online (Sandbox Code Playgroud)