Hi there,
I am having issues implement the 2FA flow I want. My preferred flow is as follows.
General idea
A logged in user can enable or disable 2fa on their profile page (this works fine). When the user enabled 2fa (TOTP using an authenticator app), on next login, they should login with username/password and then execute the 2FA challenge. My goald is to only authenticate the user (generate the JWT Accesstoken), only when the full login flow that is applicable is completed. So there are two options:
2FA Disabled: User logs in with username and password, authToken provided, User is logged in in the Weweb App.
2FA Enabled: User logs in with user name and password, executes the 2FA challenge, authToken is provided, user is logged in in the Weweb app.
The issue is in the Xano auth plugin. I can only configure it once, and I can map it to only one login endpoint, that normally takes username/password, but when 2fA enabled It takes only the code (and in my case a token for the TOTP (linked to the user) to be able to fetch the TOTP secret.
Having said this, I am thinking about best approaches to follow, couple of I can think of.
Single page login/2FA
Implement Login and 2FA on a single page, conditionally show,based on the expanded login endpoint at Xano side, with some logic about the flow to follow.
Xano Auth plugin: Signup
Using the Singup config of the Xano auth plugin, to map to the 2FA challenge Endpoint.
Using Xano extra’s to add second layer of authorization in Authtoken
Provide the JWT access token and authenticate the user after login with username/password, but add extra’s to the JWT token like: otp_pending=true / otp_pending=false. I can expose that status in the auth/me endpoint, but in this case I need to add a "check access workflow to each page that is behind the login. Slight advantage is that I can make the 2FA challenge page, an authenticated page, accessible when otp_pending = true.
Looking forward to some insights in the best approach to follow.