Skip to content

Commit

Permalink
Enable Functions SDK debug mode. (#3873)
Browse files Browse the repository at this point in the history
Functions SDK now includes a debug mode that can be enabled via environment variables to operate in ways that's useful during development. See firebase/firebase-functions#983 for an example.

We will turn on Debug Mode and enable `skipTokenVerification` feature on the Functions Emulator. This means that callable functions will decode but not verify the signature of Auth and App Check tokens which is more or less what the monkey-patching of Firebase Functions SDK achieves. For some function triggers, we will now rely on the debug mode instead of the monkey patching to bypass the token verification.
  • Loading branch information
taeold authored and kroikie committed Mar 4, 2022
1 parent 7cdadbc commit 13d0400
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/emulator/functionsEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,8 @@ export class FunctionsEmulator implements EmulatorInstance {

envs.FUNCTIONS_EMULATOR = "true";
envs.TZ = "UTC"; // Fixes https://github.com/firebase/firebase-tools/issues/2253
envs.FIREBASE_DEBUG_MODE = "true";
envs.FIREBASE_DEBUG_FEATURES = JSON.stringify({ skipTokenVerification: true });

// Make firebase-admin point at the Firestore emulator
const firestoreEmulator = this.getEmulatorInfo(Emulators.FIRESTORE);
Expand Down Expand Up @@ -1225,7 +1227,7 @@ export class FunctionsEmulator implements EmulatorInstance {
// For callable functions we want to accept tokens without actually calling verifyIdToken
const isCallable = trigger.labels && trigger.labels["deployment-callable"] === "true";
const authHeader = req.header("Authorization");
if (authHeader && isCallable) {
if (authHeader && isCallable && trigger.platform !== "gcfv2") {
const token = this.tokenFromAuthHeader(authHeader);
if (token) {
const contextAuth = {
Expand Down

0 comments on commit 13d0400

Please sign in to comment.