Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression, Revoked Local Token #3677

Closed
vishna opened this issue Aug 13, 2021 · 3 comments
Closed

Regression, Revoked Local Token #3677

vishna opened this issue Aug 13, 2021 · 3 comments

Comments

@vishna
Copy link

vishna commented Aug 13, 2021

[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

@vishna
Copy link
Author

vishna commented Aug 13, 2021

A quick workaround for failing CI was:

npm install -g firebase-tools@9.16.0

@yuchenshi
Copy link
Member

Fixed by #3674, release coming soon

@vishna
Copy link
Author

vishna commented Aug 17, 2021

Fixed indeed 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants