feat(platform): TenantGuard middleware — public repo's only SaaS hook (Phase 32 PR #1) - #78
Merged
Conversation
Phase 32 foundation. The SaaS control plane (private molecule-controlplane repo) provisions one platform instance per customer org on Fly Machines and sets MOLECULE_ORG_ID=<uuid> on the machine. Its subdomain router forwards requests with X-Molecule-Org-Id=<uuid>. TenantGuard: - When MOLECULE_ORG_ID is set → every non-allowlisted request must carry a matching X-Molecule-Org-Id header. Mismatched/missing header → 404 (not 403 — don't leak tenant existence by letting probers distinguish "wrong org" from "route doesn't exist"). - When unset → passthrough. Self-hosted / dev / CI behavior unchanged. - Allowlist is exact-match, not prefix — /health and /metrics only. No orgs table, no signup, no billing, no Fly provisioning in this repo — all that lives in the private control plane. The public repo's SaaS surface is exactly this one middleware. 6 tests covering: unset-is-passthrough, matching header, mismatched header 404 (with empty body), missing header 404, allowlist bypass, and allowlist-is-exact-match. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
noteworthy: saas-foundation — tenant isolation middleware, Phase 32 PR #1. Cross-vendor-review tooling still unavailable (recurring gap logged tick-6); proceeding per tick-7 precedent. Self-reviewed: 6 tests cover passthrough / match / mismatch-404 / missing-404 / allowlist / exact-match; default-unset behavior preserves self-hosters. |
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Apr 14, 2026
- CLAUDE.md: Go test count 740 → 746; MOLECULE_ORG_ID env var documented. - PLAN.md: new "Recently launched (2026-04-14 tick-8)" block covering Phase 32 PR #1 + paired private molecule-controlplane repo scaffolding. - docs/edit-history/2026-04-14.md: tick-8 breakdown. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
HongmingWang-Rabbit
added a commit
that referenced
this pull request
Apr 14, 2026
docs: sync documentation with 2026-04-14 tick-8 merge (#78)
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 21, 2026
…ware feat(platform): TenantGuard middleware — public repo's only SaaS hook (Phase 32 PR #1)
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 21, 2026
- CLAUDE.md: Go test count 740 → 746; MOLECULE_ORG_ID env var documented. - PLAN.md: new "Recently launched (2026-04-14 tick-8)" block covering Phase 32 PR #1 + paired private molecule-controlplane repo scaffolding. - docs/edit-history/2026-04-14.md: tick-8 breakdown. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 21, 2026
docs: sync documentation with 2026-04-14 tick-8 merge (#78)
Contributor
PR #78 — docs(mcp-server): add LOG_LEVEL env var
|
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
Phase 32 (Cloud SaaS) foundation. The public repo's only SaaS hook: one middleware, one env var. All orgs/signup/billing/Fly-provisioning code lives in the private `molecule-controlplane` repo (n8n-style open-core).
Why 404 not 403
An attacker probing multiple org subdomains should not be able to distinguish "this tenant exists but I don't have access" from "this route doesn't exist." 404 + empty body makes both indistinguishable from random noise.
Test plan
What's NOT here (deferred to private control-plane repo)
🤖 Generated with Claude Code