Support for creating custom tokens without service account credentials#285
Support for creating custom tokens without service account credentials#285hiranya911 merged 23 commits intomasterfrom
Conversation
|
Resolves #224 |
src/auth/auth.ts
Outdated
There was a problem hiding this comment.
Rename newSessionCookieVerifier and newIdTokenVerifier to createSessionCookieVerifier and createIdTokenVerifier.
| ); | ||
| } | ||
|
|
||
| public sign(buffer: Buffer): Promise<Buffer> { |
There was a problem hiding this comment.
Add javadoc descriptions to all function declarations.
src/auth/token-generator.ts
Outdated
src/auth/token-generator.ts
Outdated
src/auth/token-verifier.ts
Outdated
There was a problem hiding this comment.
* @param {string} projectId Project ID string.
* @return {FirebaseTokenVerifier}
There was a problem hiding this comment.
same here. these tests should not depend on Auth.
There was a problem hiding this comment.
These tests basically check the verifyIdToken() and verifySessionCookie() methods on Auth. They are better off in auth.spec.
There was a problem hiding this comment.
'explicit service account id'
There was a problem hiding this comment.
first encoding argument of toString() and the second argument of Buffer.from is `base64' making this confusing. Change to 'base64string' or something different.
There was a problem hiding this comment.
Changed to input
There was a problem hiding this comment.
Same here on 'base64' first argument.
| }); | ||
| }); | ||
|
|
||
| it('should return the discovered service account', () => { |
There was a problem hiding this comment.
Add a test when getAccount() rejects with an error and confirm expected error.
|
I'm posting a decoded custom token generated against the master branch and this branch for comparison. Notice that other than the order of some claims (which has no significance in JSON and JWT), nothing has changed. During the last code review round I noticed that the Tokens decoded via https://jwt.io/ JWT HeaderBefore: After: JWT BodyBefore: After: |
|
Resolves #224 |
bojeil-google
left a comment
There was a problem hiding this comment.
Thanks for making the changes. I would have preferred keeping the dependency on jsonwebtoken for minting custom tokens with service accounts but since this is undergoing a launchcal review, I leave the final say to reviewers.
Currently the SDK must be initialized with service account credentials in order to be able to call FirebaseAuth.createCustomToken(). With this PR, the SDK will attempt to sign custom tokens by calling the IAM service in the cloud when the service account credentials are not provided.
As a part of this implementation I'm also refactoring the existing
FirebaseTokenGeneratorabstraction by removing all the token verification logic out of it.go/firebase-admin-sign
go/firebase-admin-iam-sign