Currently you are not able to use auth module without a service account #1511
Replies: 2 comments 4 replies
-
I also have the same usecase, and in my case I cannot use firebase-admin because it isnt supported by edge workers, so by installing firebase-admin my Nuxt application fails, but without firebase-admin it fails to build all together. Thanks to your context @tux2nicolae I was able to remove
|
Beta Was this translation helpful? Give feedback.
-
@posva I think this is an actual issue and should not have been moved to a discussion. The module should support key-less authentication using the default credentials and not require a service account key file. Aside from security best practices, a very common use case would for example to run on GKE with Workload Identity. |
Beta Was this translation helpful? Give feedback.
-
Reproduction
vuefire/packages/nuxt/src/runtime/auth/plugin-authenticate-user.server.ts
Line 20 in 687ce09
Steps to reproduce the bug
Make sure you don't have the
GOOGLE_APPLICATION_CREDENTIALS
setRun
npm run dev
or build for productionExpected behavior
You should be allowed to use auth module without a service account
Actual behavior
You get this error when using the auth module without a service account specified.
The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services
I think the problem comes from here
vuefire/packages/nuxt/src/runtime/auth/plugin-authenticate-user.server.ts
Line 20 in 687ce09
the
getAdminAuth()
is always called regardless of the fact you may not have a service account.If you move the
const adminAuth = getAdminAuth(firebaseAdminApp)
inside the if blockif (auth.currentUser?.uid !== uid)
the problem goes away, or maybe it should be herevuefire/packages/nuxt/src/module.ts
Line 203 in 687ce09
to add a if block
if (nuxt.options.ssr && hasServiceAccount)
Additional information
Our use case is that, we don't have a service account because we don't need to render anything on the server based on authentication state, we are only using authentication on client side in some
<client-only />
componentsBeta Was this translation helpful? Give feedback.
All reactions