Skip to content
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

[Feature Request] Add OTP SMS authentication #179

Open
tinti opened this issue Jun 19, 2024 · 5 comments
Open

[Feature Request] Add OTP SMS authentication #179

tinti opened this issue Jun 19, 2024 · 5 comments

Comments

@tinti
Copy link
Contributor

tinti commented Jun 19, 2024

I have a fully working SMS OTP authentication patch. Would it be accepted or SMS OTP authentication is too insecure to be merged in this project?

It is basically a copy of magic-link implementation but without using KMS to generate and validate the OTP codes. From a security perspective I was thinking in storing some validation in to compensate:

event.response.privateChallengeParameters = {
email: email,
};

This way the only one who could use the OTP is the one who requested it.

@ottokruse
Copy link
Contributor

Very interested in that.

That similar to this implementation?: https://github.com/aws-samples/amazon-cognito-passwordless-email-auth

But using dynamodb again, like magic links, for rate limiting? Implementing OTP is easier than magic link because you don't have to deal with the link being opened in a different browser. On the other hand, I'd like to include the option to send the OTP using either email or SMS, depending on the user's choice at the time of signing in.

@tinti
Copy link
Contributor Author

tinti commented Jun 24, 2024

Very interested in that.

That similar to this implementation?: https://github.com/aws-samples/amazon-cognito-passwordless-email-auth

I would say that is closer to the magic link implementation. I have copied most of the code from it. The idea is the same.

But using dynamodb again, like magic links, for rate limiting?

Yes.

Implementing OTP is easier than magic link because you don't have to deal with the link being opened in a different browser. On the other hand, I'd like to include the option to send the OTP using either email or SMS, depending on the user's choice at the time of signing in.

It is doable. I can adjust.

What to you think of this proposal?

  1. For OTP the exact same session that initiated the authentication flow should be the one that enters the OTP code.
  2. The default for OTP will be e-mail and an SMS example will be given.

For (1) does Cognito provides a "guest" session that I can use?

Thanks.

@ottokruse
Copy link
Contributor

Not sure what you mean with guest session. You shouldn't need it I think ?

Maybe we should implement this as 2 separate flows. Email OTP and SMS OTP.

Even though they share a lot of code, may be beneficial for implementation simplicity to keep it separate

@tinti
Copy link
Contributor Author

tinti commented Jun 26, 2024

Not sure what you mean with guest session. You shouldn't need it I think ?

I mean is there a way I can guarantee that given an authentication flow X that called the define authentication challenge requesting an OTP code, only X can use the OTP?

Maybe we should implement this as 2 separate flows. Email OTP and SMS OTP.

Even though they share a lot of code, may be beneficial for implementation simplicity to keep it separate

Agree.

@ottokruse
Copy link
Contributor

I mean is there a way I can guarantee that given an authentication flow X that called the define authentication challenge requesting an OTP code, only X can use the OTP?

That's what Cognito takes care of for you (it's tied to the session, which is the very long string Cognito returns to you in custom auth calls, that you must provide back again in respondtoauthchallenge)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants