Allow custom providers and schemes

nmokkenstorm
0
nmokkenstorm
commented 6 months ago

What problem does this feature solve?

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..

What does the proposed changes look like?

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.

idea
0
MathiasCiarlo
770
MathiasCiarlo
commented 6 months ago

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

0
nmokkenstorm
0
nmokkenstorm
commented 6 months ago

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.

0
stact
0
stact
commented 5 months ago

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?

0
nmokkenstorm
0
nmokkenstorm
commented 5 months ago

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?

0
stact
0
stact
commented 5 months ago

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

0
Informations
Feature Request โ€ข Open
#c423 - Created 6 months ago