At point of writing, using nuxt-auth with the documented options looks pretty great, but there's no option to use providers or schemes other than the ones supplied by the module. It seems to have been briefly brought up in #93
Specifically for my use-case, I'd like to be able to use Firebase as an authentication backend, mostly because the users of the app I'm building already have data from different applications stored there..
By allowing people to register custom schemes and providers in their nuxt.config.js there would be more flexibility in what providers they can use.
Hi @nmokkenstorm, thank you for your feature request! The bad news are we have not implemented custom scheme support as stated back in #93.
Closing this as we will probably rework scheme to allow users to create their own schemes through npm packages
The good news is that you can make it work with firebase if you use oauth2. If firebase supports the standard oauth2 scheme(with oauth2 endpoints), you can simply set it up like in the oauth2 docs example
Hey @MathiasCiarlo , first of all thanks for the response.
I'm aware that custom scheme support is not supported at the moment, hence the feature request. Is this something that's planned in the near future? I would be willing to look into creating a PR adding support for this if that's something that would be appreciated, but I'm not that familiar with Nuxt yet.
you could create your own scheme(s) to allow your requirements with firebase: https://auth.nuxtjs.org/guide/scheme.html
Let's take a look on this (old) sample (that need be a little refresh with our needs) that allows you to understand how to provide rest call for firebase auth
https://github.com/davidroyer/auth-module-firebase/blob/master/examples/demo/services/firebase-auth.js
You could merge this approach with 'local' scheme:
https://github.com/nuxt-community/auth-module/blob/dev/lib/schemes/local.js
Here the complete rest documentation for firebase:
https://firebase.google.com/docs/reference/rest/auth
I let you know if I have a full working sample to share.
@MathiasCiarlo: is it the right way?
Hey @stact , I'm not sure if I follow what you're proposing here. Do you want to discuss and work on a PR for this together?
Hey @nmokkenstorm I'm waiting for "refresh token" PRs #361 and #457 to provide a working sample with "firebase rest authentication".
I'm also working on a project with nuxt and firebase (auth + firestore), and today I'm using SPA mode (not SSR) to manage authentication with "firebase client api".
I plan before the end of this year to have a working application with SSR mode.
The problem with SSR, auth-module and "firebase client api":
We can't use "firebase client api" on scheme fetchUser function that allow auth-module to know if the user is authenticated or not on firebase:
eg:
Firebase.auth().onAuthStateChanged((user) => { ... }) user is always null even if you are logged in.
In fact when you refresh your application, this code is executed on server side.
I didn't find a way to force auth-module to execute only on client side.
Let's be patient, Firebase + Nuxt will work together <3
Leaving this here as it's a reference for what needs to happen on the server side https://firebase.google.com/docs/auth/admin/verify-id-tokens#verify_id_tokens_using_the_firebase_admin_sdk
I made this scheme to work with Firebase - it's based on v5. Would be good to get thoughts on possible inclusion?
https://gist.github.com/homerjam/84645afbe069e516ba1fe1f05c2ed08a
Would be very useful to have this module working with Firebase :|
@homerjam Could you please provide the configuration in nuxt.config.js? Since I've tried lots of combinations while always feel weird.
This dependency was not found: * test in ./.nuxt/auth.js strategies: {
test: {
_scheme: '~/plugins/auth-test.ts'
}
}
Class constructor FirebaseScheme cannot be invoked without 'new' it works but the strategy name would be the path of my file, this is so weird for me to use loginWith('~/plugins/auth-test.ts' ...) strategies: {
test: {
name: '~/plugins/auth-test.ts',
_scheme: '~/plugins/auth-test.ts'
}
}
I just want to set it as a custom strategy name and specify the path in _scheme with no luck, any help on this? Much thanks!
@PlusA2M https://gist.github.com/homerjam/84645afbe069e516ba1fe1f05c2ed08a#gistcomment-3405177
I'm also using @nuxtjs/auth-next - I can't remember if this is necessary anymore...
I finally confirm that using scheme property instead of _scheme property is right...on @nuxtjs/auth-next, much appreciated for you swift reply!
@PlusA2M @homerjam just doing some housekeeping in my open issues, is this supported nowadays and can this issue therefore be closed?
@nmokkenstorm AFAIK supported in next (V5) which isn't officially released but I guess you can close it?
Cheers!
Most helpful comment
Hey @nmokkenstorm I'm waiting for "refresh token" PRs #361 and #457 to provide a working sample with "firebase rest authentication".
I'm also working on a project with nuxt and firebase (auth + firestore), and today I'm using SPA mode (not SSR) to manage authentication with "firebase client api".
I plan before the end of this year to have a working application with SSR mode.
The problem with SSR, auth-module and "firebase client api":
We can't use "firebase client api" on scheme fetchUser function that allow auth-module to know if the user is authenticated or not on firebase:
eg:
Firebase.auth().onAuthStateChanged((user) => { ... })useris always null even if you are logged in.In fact when you refresh your application, this code is executed on server side.
I didn't find a way to force auth-module to execute only on client side.
Let's be patient, Firebase + Nuxt will work together <3