-
Notifications
You must be signed in to change notification settings - Fork 373
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
Improve token verification logic with Auth Emulator. #1148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @yuchenshi. The implementation looks pretty good. However, we need more work to round off testing. My suggestion is to update the CI setup to invoke the auth integ tests against the emulator as part of our regular builds.
@@ -209,7 +202,7 @@ export class FirebaseTokenVerifier { | |||
verifyJwtTokenDocsMessage; | |||
} else if (payload.iss !== this.issuer + projectId) { | |||
errorMessage = `${this.tokenInfo.jwtName} has incorrect "iss" (issuer) claim. Expected ` + | |||
`"${this.issuer}"` + projectId + '" but got "' + | |||
`"${this.issuer}` + projectId + '" but got "' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: took me a while staring at this diff because of the mixed use of string templates and string concatenation via +
. No need to do anything though, probably not in scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a suggestion. Also give @bojeil-google a chance to review before merging.
Discussion
This PR implements http://go/firebase-auth-emulator-admin-sdk (Google internal design doc). Token verification now works everywhere, not just in functions emulator.
Testing
Ran
node ~/w/firebase-tools/lib/bin/firebase.js emulators:exec --project fake-project-id --only auth 'npx mocha test/integration/auth.spec.ts --slow 5000 --timeout 20000 --require ts-node/register'
manually and all tests passed locally (once unrelated pending fixes in the Auth Emulator such as firebase/firebase-tools#3091 and firebase/firebase-tools#3088 are applied).API Changes
(secret API removed; no public API changes)