A new user is created by an admin. They need to reset their initial password on first login. We have the Cognito app client configured to only allow custom authentication flow (CUSTOM_AUTH_FLOW_ONLY). But when the user resets their password, the auth flow ends and they get the id-, access- and refresh-token immediately, none of the custom challenges are issued.
- How can I steer the flow to continue with my custom challenge flow, instead of issuing the tokens?
- It would also work if the tokens would not be sent in the response, after they reset their initial password, so that the user has to log in again.
A new user currently runs through this flow:
- At the moment, for a new user, we send
InitiateAuthRequest
with username and SRP_A, AuthFlow set toCUSTOM_AUTH
, as a normal login would do. - Our DefineAuthChallengeLambda is hit, issuing the
PASSWORD_VERIFIER
challenge. - The client responds to the auth challenge with the srp claims, username and timestamp.
- Cognito verifies the response and sees, that the user must change their password. Our lambda triggers are skipped and the
NEW_PASSWORD_REQUIRED
challenge is returned by Cognito. - The client responds to the auth challenge with a new password, Cognito accepts the password and issues the tokens, which is not what we want.
We either want for the flow to end here and not issue any tokens, or to not end here and continue with a define auth challenge trigger call.