Custom Login Flow: AWS Cognito SSO (via Passwordless Signin) - Is this possible?

AI-generated summary

The original poster, xprmnts, is trying to enable a custom login flow using AWS Cognito SSO via passwordless signin on Discourse. They want to replicate the same authentication flow used on their mobile and web app, where users enter their email, receive a verification code, and then sign in without using a password.

xprmnts initially followed steps to enable SSO via AWS Cognito, but encountered issues when trying to implement the custom passwordless auth flow. They shared their desired flow and error messages, seeking guidance on how to achieve this functionality.

pfaffman responded, suggesting that the flow should work, but xprmnts clarified the specific requirements and shared more details about their current setup and errors.

Ultimately, xprmnts reported that they were unable to achieve a passwordless setup using Cognito’s default means and had to set up a lightweight OAuth server using Flask and Python to handle the tokens.

I was able to enable SSO via AWS Cognito by following the steps here:

  1. Discourse OpenID Connect (OIDC)
  2. Anyone have a working AWS Cognito configuration w/ ouath2, openid or sso?

However, I am attempting to find ways to enable the same authentication flow in discourse that we have for our mobile and web app. Which is a custom auth flow via passwordless login (users enter their email, receive a verification code).

The expectation is that the SSO would work via this passwordless auth flow, instead of email/password. Since users aren’t using passwords on the main apps.

Any pointers on how to enable this functionality? Or whether this is possible?

Thank you.

Unless I’m missing something, that should work. Just have them go wherever it is to get the link sent and you should be logged in to Discourse. Does that not work? Or do you want to make Discourse send them to the place to request the link?

Hi Jay,

Thanks for the reply.

To clarify.

The flow on our app (not discourse) is passwordless - user enters email → receives a 6 digit code in email → enters code → signs in

To enable this we have lambda triggers that define/create and verify the auth challenges. Further, the ui is custom (i.e. not provided by aws amplify)

What we want is the discourse sign in process to be the same. I attempted to use the same cognito app client configuration for discourse but get this error page


(the network call isn’t very helpful from cognito about this error)

As a follow up to this if any one is interested:

We essentially had to setup an intermediate oauth server to handle the tokens inspired by this post:
https://medium.com/@scott_84836/adding-aws-cognito-authentication-to-discourse-using-oauth2-basic-f20209ba6162

We have a flask/python backend so ended up using: python-oauth2 · PyPI

TLDR: can’t do a passwordless setup using cognito using any default means, had to setup lightweight oauth ourselves.