Skip to content
MSO CloudDocumentation

ADR 0052 — white-label: one per-org entitlement for a set of capabilities

On this page
  • Status: Accepted (platform generalization programme, item 5, 2026-09-21). Code in tree.
  • Date: 2026-09-21
  • Owners: Platform (tenancy & security).
  • Related: generalizes the branded-login entitlement of ADR 0045; same super-admin posture as ADR 0007 (a presentation switch the org itself cannot flip); sits beside the other white-label surfaces, ADR 0016 (tenant domains) and ADR 0033 (org skins, brand ink); §66 (tenancy), §10 (audit-action shape).

Context#

Two capabilities let an org replace the platform's own identity on a surface its customers see: the branded sign-in page (ADR 0045) and, newly, the brand name stamped in the footer of an exported PDF.

The first already had a per-org super-admin flag, org_login_page.enabled, fail-closed in app_get_org_login_page. The second had none: getPdfFooterTemplate() resolved the brand from PDF_FOOTER_BRAND alone, one footer per deployment, which would push a white-label customer onto its own deployment — per-customer infrastructure, the thing this programme exists to remove.

Giving the footer its own flag would have made two toggles that answer the same commercial question, free to drift. The operator's answer settles that question: attribution removal is not sold as a paid add-on; a super admin turns white-label ON for an org, and that unlocks both.

Decisions#

D1 — ONE entitlement on the org row, not one flag per capability

organizations.white_label_enabled (boolean, NOT NULL, default false) is the entitlement. It is DATA on the org, the same shape as chat_assistant_enabled and ai_byok_enabled, never a code branch and never a plugin. It gates the SET of white-label capabilities, and the next such capability joins this flag rather than growing a toggle beside it. Without it an org can change neither the sign-in page nor the PDF footer, and the platform default stands.

Rejected: a flag per capability (two answers to one commercial question, free to drift); a paid add-on tier (the operator priced it at zero); an org-admin self-service toggle (removing the platform attribution would be one click for the org itself, which is what ADR 0007 refuses for the demo posture and what the renderer's own comment refused for the footer).

D2 — Only a super admin grants it, and only a super admin sets the footer brand

admin.toggleOrgWhiteLabel (audit admin.org.whiteLabel.toggle) and admin.setOrgPdfFooterBrand (audit admin.org.pdfFooterBrand.set) are superAdminProcedure, rate-limited and audited against resourceType: 'organizations'. The org's own settings carry neither: orgLoginPageConfigSchema is .strict() and has no entitlement key, and organizations.pdf_footer_brand is written from the admin org panel alone.

The org picks the NAME in the footer. PDF_FOOTER_TEXT and PDF_FOOTER_URL stay deployment-level — the sentence around the name and the link target are the platform's.

D3 — Resolution order for the PDF footer brand

org override (only when the org holds the entitlement AND pdf_footer_brand is non-empty) -> site_settings.site_name (the super-admin platform identity that already exists) -> PDF_FOOTER_BRAND -> the built-in default YouNet Group.

The entitlement is re-checked at render time in resolvePdfFooterBrandForOrg (apps/web/src/server/pdf-footer-brand.ts), so revoking it puts every export back on the platform identity without anyone having to clear the text. getPdfFooterTemplate() stays pure and synchronous, taking the two DB-backed values as an argument, so the order is unit-tested without a database.

D4 — The migration carries every entitled org across, and leaves one flag behind

Migration 0214_org_white_label.sql adds both columns, then backfills:

UPDATE organizations o SET white_label_enabled = true
  FROM org_login_page p WHERE p.org_id = o.id AND p.enabled = true;

then replaces app_get_org_login_page to join organizations.white_label_enabled, then DROPs org_login_page.enabled. The locator is replaced BEFORE the drop deliberately: a string-bodied SQL function records no dependency on the column, so the drop alone would leave the sign-in render path failing at runtime while every static gate stayed green.

No org that has the branded login page on today loses it. Every other org starts at the default, false.

The drop is not reversible by redeploying the previous image. Rolling the code back without rolling the database back leaves the old locator reading a column that no longer exists. A rollback that must keep the branded page working re-adds org_login_page.enabled boolean NOT NULL DEFAULT false, replays the reverse backfill from organizations.white_label_enabled, and restores the previous locator body.

Index review: none needed. Both columns are read by primary-key lookup on organizations.

D5 — The backfill rule is a gate, not a comment

scripts/audit/white-label-entitlement-migration.ts runs in verify:rls. It READS the backfill statement out of the 0214 file and executes it against real rows in a rolled-back transaction that first reconstructs the pre-0214 shape, then asserts: the entitled org holds the entitlement and still resolves its published config through the real app_get_org_login_page; the not-entitled org gets nothing and its published config reaches no visitor; granting the flag is what opens it; and the locator still answers after the file's own DROP.

It is a DB gate rather than a unit test because after the drop there is nothing left in the schema for a later test to compare against — a backfill that matched the wrong rows would pass typecheck, pass every unit test, and surface only when a tenant's sign-in page went back to the platform default.

Consequences#

  • One switch in the admin org panel, labelled White-label, states what it unlocks; the footer-brand field exists only while it is on.
  • org_login_page.enabled is gone. Any future reader of that column is a bug, and there is no second toggle for a reviewer to confuse with the first.
  • PDF_FOOTER_BRAND remains the deployment-wide default and is now the third step of the order, not the only one.