update firebase component to match firebase v9 update in redwoodjs#76
update firebase component to match firebase v9 update in redwoodjs#76doesnotexist wants to merge 16 commits intoredwoodjs:mainfrom
Conversation
|
🔨 Explore the source changes: db1e2f7 |
| import firebase from 'firebase/app' | ||
| import 'firebase/auth' | ||
| import { initializeApp, getApp, getApps } from 'firebase/app' | ||
| import * as firebaseAuth from '@firebase/auth' |
There was a problem hiding this comment.
Unfortunately import * defeats the advantage of firebase v9 modular design to support tree-shaking, but the redwoodjs firebase authclient needs the app to 'inject' the firebase auth module like this, so that non-firebase auth apps do not require firebase as a dependency in their web/package.json
…User, fix imports that moved in newer version of redwood
| import admin from 'firebase-admin' | ||
|
|
||
| const config = { | ||
| apiKey: process.env.FIREBASE_API_KEY, | ||
| authDomain: process.env.FIREBASE_AUTH_DOMAIN, | ||
| databaseURL: process.env.FIREBASE_DATABASE_URL, | ||
| projectId: process.env.FIREBASE_PROJECT_ID, | ||
| storageBucket: process.env.FIREBASE_STORAGE_BUCKET, | ||
| messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID, | ||
| appId: process.env.FIREBASE_APP_ID, | ||
| } | ||
|
|
||
| admin.initializeApp(config) | ||
|
|
There was a problem hiding this comment.
Not sure where to put the api-side firebase-admin initialization. Without this, the graphql endpoint currentUser handler will not work, because the token decoder uses firebase's verifyIdToken() to decode the JWT and verify it.
There was a problem hiding this comment.
By any chance @dthyresson or @dac09 have some input here?
I'm upgrading the playground auth from 0.36.0 to 0.37.0 and firebase seems broken. Maybe we could sort this PR out instead of a separate upgrade PR.
There was a problem hiding this comment.
Ok, I upgraded the redwood dependencies in this PR to 0.37.0, had to add a api/src/directives as well and it seems to be working for me.
…rn rw setup auth firebase'
…rged PR in redwoodjs
…nsition from v0.36 to v0.37 and makeMergedSchema() failing
|
No longer seeing that, and I'm not exactly sure what changed if anything. |
|
|
||
| import admin from 'firebase-admin' | ||
|
|
||
| admin.initializeApp({ projectId: process.env.FIREBASE_PROJECT_ID }) |
There was a problem hiding this comment.
Still not sure where to put this firebase admin initialization, but I did pair down the config to only need PROJECT_ID.
A bit perplexed that no service account credentials were necessary since the documentation (https://firebase.google.com/docs/auth/admin/verify-id-tokens) for verifyIdToken states that you need to have a service account, but this works even without credentials from what I can tell.
|
Not sure this requireAuth() method in api/src/lib/auth is ever used or necessary, also is slightly confusing now that there is a requireAuth directive playground-auth/api/src/lib/auth.js Line 31 in aed43e6 |
Sibling pull-request in redwood here:
redwoodjs/graphql#3347