quest'n'click 4.5.0 · r1

Built for quest'n'click 4.5.0, revision r1. Whether it is published, and which one is current, is recorded at publication.json.

Several tenants

Français · Type: how-to · Audience: admin · Context: Reality Bridge · Status: ready · Applies from: 4.2.5

The Reality Bridge, distributed profile (Postgres) · contract: experimental · verified by CI (support matrix of 4.4.0, 2026-10-23): Postgres 16 in CI; The qualification profile: HTTPS, three instances (ops/qualify/) · automated checks: jobs bridge-postgres, deployment-smoke; CI plan reality; 1 test file · people's passes: bridge-postgres-https not run (#77) · known limits: bridge-tenants-demo-webhooks, bridge-tenants-shared-process

How to serve several games, or one game in several environments, from one Bridge deployment, and how to run several instances of it on one store. A tenant is one operator's game in one environment: its own folder, its own Biscuit root, event key, operator token, quotas, rotation and revocations. What isolates them, and where that stops: Guarantees.

What you get

One serve (or several identical ones) holding several tenants on one SQL store, each reached by its own host name, each signing WorldSignalV2 signals that name their tenant, with connector tokens bound to their tenant.

Context and versions

Prerequisites

Where to run the commands

On the deployment's machine (or each instance's), with one folder per tenant, for example /srv/bridge/a and /srv/bridge/b. npm run bridge -- … in the engine repository, npx quest-n-click-bridge … with the package (then pass --manifest= to init).

Steps

  1. Make each tenant's folder, with its id, its environment and its host names:

    # on the deployment's machine, in the engine repository
    npm run bridge -- init --dir=/srv/bridge/a --tenant=a --environment=prod --hosts=bridge.a.example --no-demo-webhooks --origin=https://game-a.example
    npm run bridge -- init --dir=/srv/bridge/b --tenant=b --environment=staging --hosts=bridge.b.example --no-demo-webhooks --origin=https://game-b.example
    

    --environment is prod, staging or dev (prod by default); it is named in every signal and in the keys the tenant lists.

  1. Serve them together on one SQL store:

    # on the deployment's machine, in the engine repository
    BRIDGE_STORE=postgres://… npm run bridge -- serve --tenants=/srv/bridge/a,/srv/bridge/b [--tenant-header]
    

    A request is routed by its Host (each tenant's hosts), or by X-Web-Scumm-Tenant with --tenant-header, before anything is read; no tenant, a 404. Two folders that configure the same tenant are refused at start, and so is a journal (several tenants share a SQL store: --store=sqlite:<file>, BRIDGE_STORE=postgres://… or BRIDGE_STORE_FILE).

  1. Grant each tenant's connectors from that tenant's folder: grant adds the tenant to the token, so no other tenant accepts it.

    # on the deployment's machine, in the engine repository
    npm run bridge -- grant --dir=/srv/bridge/a --connector=mail-a --source=mail --signals=mail.answer.correct --pair > mail-a.token
    
  1. For more capacity, start as many identical serve as needed on the same store, with no sticky sessions, behind a load balancer. Instances are stateless.

Expected result, and how to check it

How instances share one store

Limit · bridge-tenants-demo-webhooks One server keeps one map of demonstration webhooks, by source, across all its tenants: two tenants with a webhook of the same source collide. Give the tenants of a shared server --no-demo-webhooks and one grant per connector.

Limit · bridge-tenants-shared-process The tenants of one server share its process, its CORS list (every tenant's --origin together) and its database. The isolation is the Bridge's code; there is no row-level security per tenant in Postgres, and a compromised instance holds every tenant's keys.

Common errors

MessageCauseFix
✖ two directories configure the same tenant (a, a)Two folders with the same --tenantOne folder per tenant
✖ several tenants share a SQL store: --store=sqlite:<file>, BRIDGE_STORE=postgres://… or BRIDGE_STORE_FILEThe first tenant's configuration names the journalName a SQL store
404 {"error":"tenant","message":"no tenant here"}The Host is none of the tenants' hosts, and no allowed headerAdd the host to the tenant's hosts in config.json, or --tenant-header behind a proxy that sets it
403 on POST /v1/signalsThe connector's token belongs to another tenantgrant from the right tenant's folder
BRIDGE_STORE_FILE: … does not exist / … is emptyThe secret file is missing or emptyMount it; an empty one is refused rather than falling back to a journal

Files or data changed

One folder per tenant (config.json, root.key, admin-token); the shared store, where every row carries its tenant.

Recovery or going back

References


Edit the source of this page · Report an error