You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'm in the progress of setting up an MFA process to my app.
Obviously after setup, the MFA should (for users that have it enabled) require MFA right after login.
In my understanding of nuxt, this should be done as part of a (global) middleware - checking if the MFA challange is missing and redirecting the user to that location.
An (optional) feature added to auth-redirect which automatically redirects the user to a /mfa-challange route (obiviously configurable) if MFA is required (essentially, for the aal1-> aal2 step).
In my understanding so far, there could be a check of the "factors" array of the user object to check if 2FA factors are set up - and if they are, an additional call to supabase.auth.mfa.getAuthenticatorAssuranceLevel() can be made - which will determine if a redirect to /mfa-challange will be necessary.
Describe alternatives you've considered
Implement my own middleware to handle the same thing.
While this will certainly work - it'll mean there will be 2 handlers performing almost identical logic, which will certainly impact performance.
Considering this is also a security feature - it should probably not be left to every developer on it's own to figure out.
Essentially - i created a middleware in my app as follows - called it middleware/mfa.global.ts.
exportdefaultdefineNuxtRouteMiddleware(async(to)=>{constconfig=useRuntimeConfig().public.supabase;const{ callback }=config.redirectOptions;constmfaRoute='/account/mfa/challange';constisExcluded=[callback,mfaRoute]?.some((path)=>{constregex=newRegExp(`^${path.replace(/\*/g,'.*')}$`);returnregex.test(to.path);});if(isExcluded)return;constuser=useSupabaseUser();if(user.value){if((user.value.factors?.length??0)>0){// User has factors ...constsupabase=useSupabaseClient();const{ data, error }=awaitsupabase.auth.mfa.getAuthenticatorAssuranceLevel();if(error){console.error('Error getting mfa assurance level',error);return;}if(data){if(data.currentLevel!='aal2'&&data.nextLevel=='aal2'){// Redirect to MFA pagereturnnavigateTo(mfaRoute);}}}}});
It's effectively a (reduced) copy of the middleware found in this repository (reduced as the middleware from nuxt/supabase applies anyway) - so i suspect incorporating this into the actual middleware would be pretty simple - obviously on a conditional level.
Now i'd be happy to provide a PR for that - but so far, there's been no interaction from maintainers, so i'm not sure if it's worth the time to create a PR - if it's then going to be ignored.
Activity
IzakJackson commentedon Jun 21, 2024
Currently implementing this myself and was hoping the module would be able to handle this for me.
My current thinking is adding a challenge step into the /confirm route.
WHat solution did you come up with @xmatthias and would you mind sharing?
xmatthias commentedon Jun 21, 2024
Essentially - i created a middleware in my app as follows - called it
middleware/mfa.global.ts.It's effectively a (reduced) copy of the middleware found in this repository (reduced as the middleware from nuxt/supabase applies anyway) - so i suspect incorporating this into the actual middleware would be pretty simple - obviously on a conditional level.
Now i'd be happy to provide a PR for that - but so far, there's been no interaction from maintainers, so i'm not sure if it's worth the time to create a PR - if it's then going to be ignored.
IzakJackson commentedon Jun 23, 2024
@xmatthias Thanks for the help!
github-actions commentedon May 6, 2025
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
xmatthias commentedon May 6, 2025
MFA is still not supported.
github-actions commentedon Aug 10, 2026
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
xmatthias commentedon Aug 10, 2026
MFA is still not supported.
Matheun commentedon Sep 12, 2026
Can we get support for this? Its basically a industry standard feature at this point...
Shooteger commentedon Oct 20, 2026
Hello, working on a PR for this as I really need it myself... I will create a PR in the coming weeks