express-firebase-authenticate
Express middleware for Firebase Cloud Functions that extracts user data from a Firebase auth token.
Details
Validates the token included using the verifyIdTokens API from the Firebase Admin SDK and attaches the decoded token to req.user. For more details on the API or decodedToken see https://firebase.google.com/docs/auth/admin/verify-id-tokens
Usage
Install module
npm install --save express-firebase-authenticate
Sample
const admin = require('firebase-admin')
const express = require('express')
const firebaseAuth = require('express-firebase-authenticate')
const functions = require('firebase-functions')
admin.initializeApp()
const app = express()
app.use(firebaseAuth)
app.post('*', async (req, res) => {
console.log(req.user.uid)
res.sendStatus(200)
})
exports.widgets = functions.https.onRequest(app)