-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Authentication Flow for Email-Based MFA Failing to Trigger CreateAuthChallenge #14067
Comments
Hey, @Mustafa-Algoace01 👋. Sorry to hear you're running into this, but we'll transfer this over the the |
@Mustafa-Algoace01, can you also share the code for the Just so you're aware, we also recently released support for email MFA out of the box. You can read more about that in the MFA Auth section here, but not sure if you had implemented this yourself before we released this feature! |
@cwomack I am trying to implement MFA using a third-party email service instead of AWS SES by integrating a custom authentication flow with Cognito. However, I am encountering the following issues: If I remove the following line from the DefineAuthChallenge Lambda function, I get the error: // Pass the USER_ID_FOR_SRP to the next challenge If I add the above line, it throws an error: The VerifyAuthChallengeResponse Lambda function is not being triggered during the flow. Below is my VerifyAuthChallengeResponse function for reference:
|
@Mustafa-Algoace01, can you confirm if the It looks like there are some discrepancies on how the lambdas are set up relative to our docs, but are you just trying to use a custom email sender? If so, this Lambda example may be more relevant. |
@cwomack i tell you what i want, i want MFA email without using SES so I make custom authentication flow for mfa email first I create define auth lambda function here its code export const handler = async (event) => {
} catch (error) { here its response{ second is "create auth function"here its code export const handler = async (event) => {
}; and here its response{ both function work fine but during signing I use this code for custom auth const {isSignedIn, nextStep} = await signIn({ but signing throw this error I cant find any solution of this error |
@Mustafa-Algoace01 I'll go through the code you mentioned, but like @cwomack said using a single custom email sender lambda should be easier to manage if you want to use email MFA without SES |
@pranavosu Thank you for the suggestion! If I understand correctly, using a custom email sender Lambda for email MFA would indeed simplify management. However, in my use case, Cognito MFA with email is enabled, which requires SES to send verification emails. My challenge is: how can I implement email MFA without configuring SES? As far as I know, Cognito mandates SES for email delivery when email-based MFA is enabled. Can you clarify how the custom Lambda would bypass this requirement, or if there’s an alternative approach I might be missing? |
thanks @Mustafa-Algoace01. let me take a closer look at this |
Hey @Mustafa-Algoace01, you are correct, SES must be enabled as the email provider to toggle on Email MFA in the console. However, once the custom sender is added, Cognito will send all requests that would have otherwise triggered SES to the lamba function instead. This also means you'll have to add logic to the custom sender for all your use cases that would otherwise trigger sending an email - sign up, sign in, account recovery, etc, if applicable. If even just enabling SES (but not using) on your user pool is not an option for you, let us know and we can provide further assistance with the custom auth flow. |
Thanks @jjarvisp, this works! And thanks to all of you for helping me |
Before creating a new issue, please confirm:
On which framework/platform are you having an issue?
React Native
Which UI component?
Other
How is your app built?
npx react-native init YourProjectName
What browsers are you seeing the problem on?
iOS (React Native), Android (React Native)
Which region are you seeing the problem in?
us-east-2
Please describe your bug.
We are implementing a custom authentication flow using AWS Cognito with email-based MFA. While the DefineAuthChallenge Lambda function triggers as expected and responds with a CUSTOM_CHALLENGE, the CreateAuthChallenge Lambda function does not execute. This results in the challenge not being generated (e.g., create logs and otp show in log). Below are the details of the implementation and issues encountered.
What's the expected behaviour?
After the DefineAuthChallenge indicates a CUSTOM_CHALLENGE, the CreateAuthChallenge function should:
Generate the custom challenge (e.g., a 6-digit OTP).
Send the OTP via email to the user.
Store the OTP in private challenge parameters.
and verify otp in VerifyAuthChallenge
Help us reproduce the bug!
Configure AWS Cognito user pool with Lambda triggers for custom authentication:
DefineAuthChallenge
CreateAuthChallenge
VerifyAuthChallengeResponse
Set up permissions for the Lambda functions (IAM roles are correctly configured).
Sign in with the USER_SRP_AUTH flow using the AWS SDK.
Observe that the DefineAuthChallenge trigger runs, but the CreateAuthChallenge trigger does not execute.
Code Snippet
siginIn function
const {isSignedIn, nextStep} = await signIn({
username: username,
password: password,
options: {authFlowType: 'CUSTOM_WITH_SRP'},
});
Console log output
No response
Additional information and screens
hots
No response
The text was updated successfully, but these errors were encountered: