Skip to content

Post-authentication trigger not firing for webauthn sign-ins

0

Our web app is using the Amplify v6 JS package and Cognito. When a user authenticates with email, password, and MFA we see the pre-authentication, post-authentication, and pre-token generation triggers fire during their authentication flow. However, when a user authenticates with webauthn/passkey flow, we only see the pre-token generation trigger fire. Our passkey sign-in uses the Amplify package's signIn method, called with the following:

    const result = await signIn({
      username: email,
      options: {
        authFlowType: "USER_AUTH",
        preferredChallenge: "WEB_AUTHN",
      },
    });

and in the Network tab of the browser console, I see that first there is an InitiateAuth call with "WEB_AUTHN" preferred challenge, then a RespondToAuthChallenge call with "WEB_AUTHN" ChallengeName to complete the flow. I would expect these to call pre_authentication and post_authentication respectively based on https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-working-with-lambda-triggers.html. The authentication does complete successfully, but I was hoping to utilize the pre-authentication and post-authentication triggers for all login events. Is this not possible for passkey logins or is there some piece of configuration that I could be missing?

  • If my answer was helpful, I would appreciate it if you could mark it as the accepted answer.

1 Answer
1

The API reference lists the triggers for both calls in your flow: InitiateAuth invokes pre authentication, among others, and RespondToAuthChallenge invokes post authentication and pre token generation (InitiateAuth, RespondToAuthChallenge). I couldn't find an exception for passkeys. Lambda triggers are configured per user pool, so there's no per-method setting to turn them on. That makes this one for AWS Support.

Until then, the pre token generation trigger, which does fire, can carry your post-sign-in logic. Its triggerSource tells you why tokens are issued, so you can run the logic for sign-ins and skip TokenGeneration_RefreshTokens (Pre token generation trigger). Check which triggerSource arrives for a passkey sign-in before relying on it.

EXPERT

answered 13 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.