Skip to content
MSO CloudDocumentation

Tenancy and security

On this page

In short#

Organizations share tables; the host picks the organization, row-level security forced on every organization table filters the rows, and no runtime identity can bypass it. Brands are a second partition inside an organization.

1 · HostExact host to one org idHost beats the cookieUnknown host: nothingbefore any tenant scope2 · ProcedureWraps the whole resolverOne transactionOrg and brand pinnedorgProcedure · brandProcedure3 · PolicyENABLE and FORCE RLSOrg leg and brand legNo pin: zero rowsevery org-scoped table4 · IdentityOwn role per runtimeNo superuser, no bypassGrants from a manifestrefuses to boot if wrongOrganization = tenantMembership, settings, connectors, org-wide rowsAdmins read across brandsBrand = partition inside itEvery fact row carries org id and brand idUnpinned brand reads the org-wide rollup
Four isolation layers in request order, and the two tenancy tiers they enforce.

Secrets are envelope-encrypted and never returned, identifying names are masked at display, and sign-in is configured per organization.

Two tenancy tiers#

An organization is one customer. A brand is a workspace partition inside it, not a separate tenant: every fact or asset table carries both ids. Organization-wide administration reads across brands; brand-scoped reporting does not (Multi-brand workspaces).

Rule How it holds
Brand access Membership belongs to the organization; viewable brands decide which brands a member enters
Brand authorization Decided in the application; the brand policy leg is the safety net under it
Ingest is brand-bound Single-brand organizations pin automatically; a missing or disagreeing brand is refused
Shops A marketplace shop belongs to exactly one brand
Super admins No membership anywhere; the console names the organization it acts on in the URL

How isolation works#

  1. The host resolves the organization. Before any tenant scope exists, fixed-shape database functions exchange one exact host for one organization id. On a tenant subdomain or verified domain the host wins over the cookie; an unknown host resolves to nothing.
  2. The resolver runs in one pinned transaction. The procedure sets organization and brand as transaction-local settings on one connection and runs the whole resolver there; a failed mutation rolls back.
  3. The database applies the policy. Organization tables match the pinned organization; brand-partitioned tables add a brand leg, where an unpinned brand means the organization-wide rollup. The policy is forced, so the table owner is not exempt, and an unset setting denies: no context, zero rows.
  4. The identity cannot bypass it. Web, worker and backup each connect as their own role without superuser or bypass rights and refuse to start on any other; grants come from one declared manifest after a full revoke.

Tables outside row-level security carry a threat-modelled entry in a checked-in exceptions file; cross-tenant work uses fixed-shape database functions granted to one role.

Threats and the layer that stops each#

ThreatHostresolves the orgRequest guardslimits, signaturesForced policyrow-level securityRuntime roleno bypass rightsEncryption andmaskingA query forgets its organization filterstops hereA stale cookie names another organizationstops hereA runtime role tries to skip the policystops hereOne brand's rows reach another brandstops hereA secret in a response, log or archivestops hereA real buyer name on a hidden surfacestops hereCredential stuffing or password sprayingstops hereA forged client address evades a limiterstops hereA forged webhook bodystops heredot = the request passes this layer first; blank = the layer never sees it
Which layer stops which threat. A filled cell is the stopping layer; the layers to its right never see the request.

Rate limits apply to every mutating, sign-in and webhook endpoint; a sign-in that cannot be checked is refused, a webhook signature is validated before its body is parsed, and the client address comes from the connection peer or a configured proxy hop only.

Shared dataset plane#

The social trend feed is one dataset for every org, so its tables (shared_trend_items, shared_trend_history, shared_trend_review_decisions, platform_connector_runs, platform_connector_state) have no org_id and no row-level security: a policy has no tenant key to match. They hold no tenant data, only vendor data and sync bookkeeping. The boundary moves into code and is enforced three ways (ADR 0061, rule 218).

  • One proof-carrying reader. Every read goes through shared-trends-read.ts. Its functions take a scope value that only resolveTrendFeedScope produces, from an authenticated org context (the org of a verified platform token equal to the path org, or the org of a signed-in session) and that org's plugin row. A bare org id cannot read. A static audit allows no other import of the tables outside the schema package, the worker, the reader, the super-admin router and the import script. Apps and the assistant get only rows that passed review.
  • Runtime ACL split. The web role has SELECT on the five tables. Only the worker writes the dataset. The one web write is a super admin's review decision: INSERT, UPDATE and DELETE on shared_trend_review_decisions, plus column-level UPDATE of review_state on shared_trend_items and of revision on platform_connector_state.
  • Vendor session and budget. The vendor login lives in Redis, encrypted with the repo's envelope key, under a key derived from a hash of the account, with the token's own lifetime as TTL. One lock covers login and refresh, so several processes share one session. One Redis counter holds the account's 300 calls per 60 s (limits); keyword search may use at most 30 of them. A super admin sets the account email and password on the Shared trends page; they are stored envelope-encrypted in an org-less table, read by the worker and web at the start of each run, and never reach a log or response (the environment pair is only a fallback, and a stored credential that cannot be decrypted counts as absent). The reader normalises vendor values the contract cannot carry: a sentiment outside -1 to 1 is served as null and text is cut on code points. Super-admin actions on that page are written to the audit log of the first organisation, readable by super admins only.

A shared dataset is org-less by design; an org-scoped table never takes this shape. Redistribution terms of the vendor data remain an open contract question, which is why the feed reaches only orgs that hold it.

Secrets, masking and sample data#

  • Envelope encryption. Connector credentials, directory bind passwords and channel secrets use AES-256-GCM under a versioned key; each row records its key version; rotation keeps prior keys until a tested rewrap proves them unused.
  • Store verbatim, mask at display. Ingest keeps exactly what the source returned, so numbers reconcile. Buyer-identifying fields render masked by default and are revealed only by explicit action; an organization declares names to mask and which roles see them masked (Identity masking).
  • Sample data is flagged. Every fact table and brand carries is_sample, so demo rows never reach a real KPI and seeding one brand never touches another.

Sign-in and request protection#

Sign-in: three rate-limit buckets, then a constant-work password checkBrowserSign-inRate limiterAccount store1email, password, code2check three buckets3pass, or refuse4look up account5constant-work password check6one-time TOTP or recovery code7session cookie, 14 days
Area Rule
Methods Password, magic link, WebAuthn passkeys, TOTP two-factor, Google sign-in when configured
Directory Per organization: LDAP/AD or OpenID Connect, turned on by a super admin
LDAP Bind fails closed, encrypted by default, no auto-created accounts, super admins refused
Sessions 14 days, rolling 24-hour refresh, revocable by sid; httpOnly and secure cookies outside local development
Input Named Zod schema on every API input; user HTML sanitized before rendering
Outbound Sent only when platform, organization and person all allow the channel; in-app by default

A TOTP code is accepted once: a reused time step is refused. Setup: Set up LDAP/AD login and Notifications.

Sessions and sign-out everywhere#

Each sign-in writes an auth_sessions row and stores its sid in the token, so a stateless token is revocable. Every request checks the row. The issuer's end_session call sets revoked_at through an internal route and then sends a back-channel logout to each connected app holding that sid. The session check is cached for 60 s. A token minted before the table existed gets a row on its first request.

A revocable session: token plus row1 · Sign inPassword, passkey, Google,LDAP or org OIDCone amr per method2 · Token and rowAuth.js token carries sidauth_sessions row: user,amr, auth_time, revoked_atyng_auth pool only3 · Every requestRow read by sidrevoked: session droppedold tokens get a lazy row4 · RevokeIssuer end_session setsrevoked_at for the sid(60 s check cache)Issuer fan-outBack-channel logout to every app holding the sidlogout_token verified by each appHandoff keeps the sidA tenant host passes a single-use 60-second token;the platform-host session carries the same sid
The session id (sid) makes a stateless token revocable: the token proves who, the row says whether it still counts.

Connected apps sign in through the MSO issuer with PKCE and private_key_jwt; an access token carries exactly one org (App family and sign-in).

Where it stops#

Masking is a display layer, not anonymization. An archive never carries secrets, and a restore does not bypass isolation (Back up and restore an organization). OpenID Connect login and white-label custom domains are not yet proven against live providers: Project status, last verified 3 October 2026.

Decisions#

Decision Why Enforced by
Every organization table has a forced policy; a missing tenant pin denies An application filter fails open when one query forgets its clause; a policy fails closed Tenancy gate: policy inventory; no-context and wrong-organization reads return zero rows
One transaction wraps the resolver; any function reaching organization data opens its own scope A lost pin reads zero rows, which an entitlement check takes as the most permissive answer Behavioural tests per scope call site, worker audit, null-brand ratchet, outbox audit
Each runtime uses an exact non-bypass role; grants come from one default-deny manifest A bypass role skips the forced policy while every tenancy test still passes Boot identity check, deploy grant-drift stop, gate run as the deployed identity
One resolver derives the organization from the host; one helper builds absolute URLs A cookie-derived origin sends a redirect or an erasure to the wrong tenant Audits on session-organization reads and origin-built URLs; full reload on a switch
Brand-partitioned writers always set the brand; every rollup key contains it A key without the brand shows the sum of all brands inside each one Brand-isolation gate leg, brand-scoped reconciliation, one brand resolver that refuses
A table without org_id is read only through one reader that needs an org proof; only the worker writes it RLS cannot gate a table with no tenant key; a second door would be ungated Shared-dataset single-reader audit, reader tests, runtime ACL manifest
Secrets are envelope-encrypted and never returned; names stored verbatim, masked at display A secret in a log or archive is a breach; a per-surface mask decision leaks names Pre-commit security scan, unmasked-field audit, single masking resolver, leak tests