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

Improve token verification logic with Auth Emulator. #1148

Merged
merged 11 commits into from
Feb 4, 2021

Conversation

yuchenshi
Copy link
Member

@yuchenshi yuchenshi commented Jan 28, 2021

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)

Copy link
Contributor

@hiranya911 hiranya911 left a 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.

src/auth/auth.ts Outdated Show resolved Hide resolved
src/auth/token-verifier.ts Outdated Show resolved Hide resolved
test/integration/auth.spec.ts Show resolved Hide resolved
test/integration/setup.ts Show resolved Hide resolved
test/unit/auth/auth.spec.ts Show resolved Hide resolved
test/integration/auth.spec.ts Outdated Show resolved Hide resolved
test/integration/auth.spec.ts Show resolved Hide resolved
test/integration/auth.spec.ts Show resolved Hide resolved
@yuchenshi yuchenshi requested a review from hiranya911 January 29, 2021 00:38
@yuchenshi yuchenshi assigned hiranya911 and unassigned yuchenshi Jan 29, 2021
@@ -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 "' +
Copy link
Contributor

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.

Copy link
Contributor

@hiranya911 hiranya911 left a 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.

src/auth/token-verifier.ts Outdated Show resolved Hide resolved
@yuchenshi yuchenshi removed their assignment Feb 1, 2021
test/integration/setup.ts Outdated Show resolved Hide resolved
test/unit/auth/auth.spec.ts Show resolved Hide resolved
test/unit/auth/auth.spec.ts Outdated Show resolved Hide resolved
@bojeil-google bojeil-google removed their assignment Feb 4, 2021
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

Successfully merging this pull request may close these issues.

5 participants