Skip to content

Commit 56b6096

Browse files
authored
Enable Functions SDK debug mode. (#3873)
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.
1 parent 744c073 commit 56b6096

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/emulator/functionsEmulator.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,8 @@ export class FunctionsEmulator implements EmulatorInstance {
903903

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

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

0 commit comments

Comments
 (0)