feat(orb): add a stored tenant-DB-credential secret type + generic revoke path to the token broker - #8080
Merged
Merged
Conversation
…voke path to the token broker (#8064) Adds ORB_SECRET_TYPE_TENANT_DB_CREDENTIAL to src/orb/broker.ts: a STORED (not minted) secret type for a credential the caller already has in hand (e.g. a hosted tenant's Postgres connection string, #7180's provisioning core) rather than the GitHub-token type's mint-on-exchange shape. issueOrbStoredSecret encrypts and stores the value at issue time (new secret_value_ciphertext/iv/ salt/version columns, same shape as repositories.ts's BYOK provider-key storage); brokerOrbToken decrypts and returns it verbatim on exchange, with no installation-eligibility re-check, cache, or re-mint -- none of which apply to a value that isn't derived from a GitHub App. installation_id is always NULL on these rows: an AMS tenant has no GitHub installation at all, and even a hosted ORB tenant's installation lives in control-plane's own registry (#7181), not this table's orb_github_installations. Also adds revokeOrbEnrollment, a generic revoke path that works for ANY secret type -- brokerOrbToken's existing revoked_at check (since #7174) has always refused a revoked row, but nothing has ever written to that column until now. Idempotent: revoking an already-revoked enrollment succeeds without disturbing its original timestamp. POST /v1/internal/orb/enrollments gains an optional { secretType: "tenant_db_credential", secretValue } body for the new stored-secret issuance path; POST /v1/internal/orb/enrollments/:enrollId/revoke is the new admin-facing revoke route. Both sit behind the existing /v1/internal/* Bearer wall. The GitHub-token type's existing behavior is completely unchanged -- this is additive. Broker-side only: control-plane's own injectSecrets/revokeSecrets wiring against this is #8066, a separate, blocked-on-this sub-issue of #7852. Closes #8064
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8080 +/- ##
=======================================
Coverage 91.98% 91.98%
=======================================
Files 748 748
Lines 76617 76649 +32
Branches 23239 23249 +10
=======================================
+ Hits 70474 70506 +32
Misses 5041 5041
Partials 1102 1102
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Contributor
|
Important 🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪 🔍 LoopOver is reviewing…AI analysis is in progress. This comment will update when the review is complete. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing |
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.
Summary
Implements #8064, split from #7852 (itself split from #7180's provisioning core). Broker-side only — control-plane's own
injectSecrets/revokeSecretswiring against this is #8066, separately scoped and blocked on this PR.ORB_SECRET_TYPE_TENANT_DB_CREDENTIAL: a stored (not minted) secret type — a credential the caller already has in hand (e.g. a hosted tenant's Postgres connection string) rather than the GitHub-token type's mint-on-exchange shape.issueOrbStoredSecretencrypts and stores the value at issue time (newsecret_value_ciphertext/iv/salt/versioncolumns, mirroringrepositories.ts's BYOK provider-key storage shape — notbroker.ts's owncached_token_json, which is a TTL'd mint cache, a different thing from a permanently stored value).installation_idis alwaysNULLon these rows: an AMS tenant has no GitHub installation at all, and even a hosted ORB tenant's installation lives in control-plane's own registry (Route incoming GitHub webhooks to the correct tenant's hosted ORB container #7181), not this table'sorb_github_installations.brokerOrbTokendecrypts and returns the stored value verbatim on exchange — no installation-eligibility re-check, no cache, no re-mint, none of which apply to a value that isn't derived from a GitHub App.revokeOrbEnrollment: a generic revoke path that works for any secret type.brokerOrbToken'srevoked_atcheck has existed since Generalize src/orb/broker.ts into a multi-secret-type broker shared by ORB + AMS hosted #7174 but nothing has ever written to that column until now — this closes that gap. Idempotent: revoking an already-revoked enrollment succeeds without disturbing its original timestamp.POST /v1/internal/orb/enrollmentsgains an optional{ secretType: "tenant_db_credential", secretValue }body for the new issuance path;POST /v1/internal/orb/enrollments/:enrollId/revokeis the new admin-facing revoke route. Both sit behind the existing/v1/internal/*Bearer wall.Test plan
npx tsc --noEmitcleannpx tsx scripts/check-migrations.ts— contiguous, next free 0174npx tsx scripts/check-schema-drift.tsclean (orb_enrollmentsis raw-SQL-allowlisted, no Drizzle schema to update)npx tsx scripts/write-ui-openapi.ts --checkclean (these are internal-only routes, not part of the public OpenAPI surface)npx vitest run— full suite, 1091 files / 20359 tests, 0 failures (an unrelated pre-existing local worktree staleness intest/unit/mcp-cli-tools.test.ts/mcp-cli-maintain-tools.test.tswas resolved by rebuilding@loopover/mcp, confirmed present even on a cleanorigin/mainbefore that rebuild — not caused by this change)src/orb/broker.ts(100%/98.27%/100%/100% — the one branch gap is pre-existing, untouched code inreadCachedOrbToken) and confirmed every changed line/branch insrc/api/routes.ts's new route code is coverednpm audit --audit-level=moderate— no dependency changes in this PRCloses #8064