Open
Conversation
- [x] Implemented the suggestion made in expl#29 for the maintainer to consider.
Owner
|
Thank you for your PR, just letting you know that I am reviewing it. |
expl
reviewed
Mar 31, 2026
Owner
expl
left a comment
There was a problem hiding this comment.
Thank you for waiting/
Some bigger points before I go into small things:
- Please move custom token logic into separate module to keep the codebase more organized, I would also consider creating separate module for IAM signing client or possibly use https://crates.io/crates/google-cloud-iam-credentials-v1 that is generated from official schema
- Extracting SA email from metadata server is only one way of several, it can be also automated to extract it from external/impersonated account setup without passing this burden to the user of the crate. We already depend on
google-cloud-authcrate, it comes with optionalidtokenfeature that provides OIDC (JWT) token for the active service account (in addition to access token required to call Firebase/IAM services) that contains the service SA email. This way is preferred because it detects best way to get the SA with least overhead. Whenidtokenfeature is enabled IDTokenCredentials trait is implemented forCredentialsstruct.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
All Firebase Admin SDKs have a built-in method for creating / minting custom tokens. This pull request is a suggested implementation in-par with what SDKs in other maintained languages provide. More context.
Typical Flow
Services can call either
create_custom_token/create_custom_token_with_claimsto generate signed JWTs which clients can then exchange for Firebase credentials using Firebase frontend SDKs.API
create_custom_token/create_custom_token_with_claimsMints Firebase custom tokens (RS256 JWTs) via the IAM Credentials
signJwtAPI.Input validation matches other Firebase Admin SDKs:
uidmust be non-empty and ≤ 128 characters (Unicode-aware)claimsmust be a JSON object with no reserved JWT keys (aud,exp,iat,iss,sub, etc.)The signing service account resolves in priority order:
app.auth_with_signer("sa@project.iam.gserviceaccount.com")Comparison NodeJS SDK / Rust Implementation
Case 1. Auto-Discovered
Case 2. Explicit Signer
In a nutshell,
serviceAccountIdin Node.js maps toauth_with_signer()here.Behavior in emulator
When targeting the emulator (
App::emulated()), tokens are minted as unsigned JWTs (alg: none), no IAM call or service account is needed. Consistent with how other Firebase Admin SDKs handle emulator environments.@expl any feedback, happy to help / amend / revise 👍