Repository navigation
refactor(db): move the Google credential and token code to src/lib/db/auth/google - #2299
Merged
Merged
Conversation
…/auth/google Firestore's Google credential parsing, ADC chain, grants and token cache move out of the provider directory into a shared layer, src/lib/db/auth, which a second Google provider can sign in through without a copy. Firestore declares its accepted kinds and its server-identity gate as rules and keeps every sentence and request it had. The layer starts with the server-identity gate, the credential-endpoint lane options, a seam guard (AUTH1 to AUTH6) and docs/DB_AUTH.md. A governance test now finds every *_SERVER_CREDENTIALS opt-in under src/ and checks that the preflight refuses it. One hardening: a token or metadata refusal reason that holds a form of the credential is withheld whole instead of quoted.
…/auth/google Review round 1: pin the token URL literal and the 300-character cut of a refusal reason exactly, document the withheld reason in the Firestore error table, word the gate by the managed flag instead of server-written, and narrow the only-way claim to the ADC chain.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
17 tasks done
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.



Moves Firestore's Google credential and token code out of the provider directory into a new shared layer,
src/lib/db/auth, so the next Google provider signs in through one implementation instead of a copy.Firestore keeps every sentence, request, lane option and error it had; its existing tests are the oracle and pass with only import and pin edits.
What changes
src/lib/db/auth/google/credentials.tsandtoken-source.tsare the two Firestore files, moved withgit mvand made provider-neutral.Policy now comes in as a rules object: the accepted kinds (a kind the parser knows and the rules omit is refused as unsupported), the quota-project rule and a server-identity gate.
resolveGoogleCredentialis the one entry to the ADC chain: its reader is no longer exported, so the chain is reachable only through the gate.The token source accepts any credential it is given, so a provider passes it only what
resolveGoogleCredentialreturned.The token source takes one transport factory and builds its lane options itself, through one strategy per credential kind in a typed table.
src/lib/db/auth/server-identity-gate.ts:managedexactly true, then the provider's*_SERVER_CREDENTIALSopt-in exactly"true", in one place.src/lib/db/auth/lanes.ts: the transport options of every credential-endpoint lane (one socket, TLS against the host, no 101, link-local refused unless it is the metadata lane), imported only inside the layer.credential-policy.ts, passes its seams'createTransportstraight through, and builds its secret forms withgoogleCredentialSecrets.GOOGLE_TOKEN_URLand the two ADC variable names leave Firestore'sconstants.ts;FIRESTORE_ENV_NAMESis the same six names in the same order.tests/unit/db/auth/seam-guard.test.tsholds the layer's lines (AUTH1 to AUTH6: imports, ambient effects, engine names, module state, import direction, one copy of each mechanism), each proven with a planted violation.BigQuery's own copy is the one listed AUTH6 exception, with its count.
tests/unit/lib/governance/preflight.test.tsnow finds every*_SERVER_CREDENTIALSliteral undersrc/and checks that the governance preflight refuses it when set to"true".docs/DB_AUTH.mdis new;ARCHITECTURE.md,ADDING_A_PROVIDER.md,docs/providers/firestore.mdand the launcher comment point at it.BigQuery is not touched.
User-visible change
Any other reason is unchanged and still cut at 300 characters.
The error table in
docs/providers/firestore.mdsays so.Test plan
Review the moves with
git diff -M30% origin/main...so the two source files show as renames.