Skip to content

Regression, Revoked Local Token #3677

@vishna

Description

@vishna

[REQUIRED] Environment info

firebase-tools: 9.16.3 (Works OK in 9.16.0)

Platform: Ubuntu

[REQUIRED] Test case

  1. Generate user with a token
  2. Verify token in functions

[REQUIRED] Steps to reproduce

  1. Run local emulator
  2. Create a user/token (e.g. integration test)
await firebase.auth().createUserWithEmailAndPassword(email, password)
const userCredential = await firebase.auth().signInWithEmailAndPassword(email, password)
const idToken = await userCredential.user.getIdToken(true)
  1. Use this token to make a call (e.g. integration test) to a local function that verifies the token, e.g.:
await axios.get(
    `http://localhost:5001/project-id/us-central1${path}`,
    {
           headers: { "Authorization": `Bearer ${user.idToken}` }
    }
)
  1. Verify token on the function side:
const decodedIdToken = await admin.auth().verifyIdToken(idToken);
  1. Observe an error thrown:
{"severity":"ERROR","message":"Error while verifying Firebase ID token: FirebaseAuthError: The Firebase ID token has been revoked.
    at FirebaseAuthError.FirebaseError [as constructor] (/Users/vagrant/git/firebase/functions/node_modules/firebase-admin/lib/utils/error.js:44:28)
    at FirebaseAuthError.PrefixedFirebaseError [as constructor] (/Users/vagrant/git/firebase/functions/node_modules/firebase-admin/lib/utils/error.js:90:28)
    at new FirebaseAuthError (/Users/vagrant/git/firebase/functions/node_modules/firebase-admin/lib/utils/error.js:149:16)\n    at /Users/vagrant/git/firebase/functions/node_modules/firebase-admin/lib/auth/auth.js:675:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.validateFirebaseIdToken (/Users/vagrant/git/firebase/functions/lib/utils.js:101:32)\n    at async /Users/vagrant/git/firebase/functions/lib/index.js:124:18
    at async runFunction (/Users/vagrant/.nvm/versions/node/v14.17.5/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:614:9)
    at async runHTTPS (/Users/vagrant/.nvm/versions/node/v14.17.5/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:634:5)
    at async handler (/Users/vagrant/.nvm/versions/node/v14.17.5/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:563:17) {
  errorInfo: {
    code: 'auth/id-token-revoked',
    message: 'The Firebase ID token has been revoked.'
  },
  codePrefix: 'auth'
}"}

[REQUIRED] Expected behavior

Token is verified correctly

[REQUIRED] Actual behavior

An error is thrown during verification

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions