Skip to content

Demo

In this tutorial you run two tenants side by side and see that each one is separate. A tenant is its own set of accounts, clients, and signing keys. Each tenant is also its own issuer, the address its tokens name as the one that issued them.

masks has no public demo server. The tutorial uses the dev stack from Try it locally.

  1. Stop ./dev if it is running.

  2. Start it with --multi:

    Terminal window
    ./dev --multi

The stack declares two tenants, demo and acme, and serves each at its own hostname:

masks http://demo.masks.localhost:12345
masks http://acme.masks.localhost:12345
docs http://masks.localhost:12346

masks reads the tenant from the hostname of each request. A hostname that no tenant uses gets a 404 with the body no tenant is served at this hostname:

Terminal window
curl http://nothing.masks.localhost:12345/.well-known/openid-configuration
  1. Fetch the discovery document for each tenant. The discovery document lists a tenant’s issuer and endpoints.

    Terminal window
    curl http://demo.masks.localhost:12345/.well-known/openid-configuration
    curl http://acme.masks.localhost:12345/.well-known/openid-configuration

    The issuer of the first is http://demo.masks.localhost:12345. The issuer of the second is http://acme.masks.localhost:12345. Every endpoint in each document is under the tenant’s own origin.

  2. Fetch each tenant’s signing keys:

    Terminal window
    curl http://demo.masks.localhost:12345/.well-known/jwks.json
    curl http://acme.masks.localhost:12345/.well-known/jwks.json

    Each tenant publishes its own key, with its own kid (key ID). A token that demo signs has a kid that acme does not publish, so a client that trusts acme refuses that token.

  1. Open http://demo.masks.localhost:12345 in a browser. demo has no accounts yet, so it shows the Set up demo screen.
  2. Enter the setup token masks-dev, and follow the screen to the end. See setting a tenant up for each step.
  3. Open http://acme.masks.localhost:12345. It still shows Set up acme, because the account you made belongs to demo only.
  4. Set up acme too. The same nickname and email address work, because no account at demo exists at acme.
  5. On each tenant’s account page, choose Manage this server.

Each /manage lists only its own tenant’s actors and clients.

./dev image builds the production image and runs it with the same two tenants on port 5556.

Terminal window
./dev image

The command fetches each tenant’s discovery document and signing keys. It fails if a tenant:

  • advertises an issuer other than its own origin
  • publishes no keys
  • signs with the same key as the other tenant

When every check passes, it prints:

demo and acme each answer at their own origin, with keys of their own.
http://demo.masks.localhost:5556

The image does not use masks-dev. It prints a setup token for each tenant in the masks-image service’s logs, as a production server does.

./dev down stops the image along with the rest of the stack.

  • Tenants explains how masks keeps tenants apart.
  • Signing keys explains how each tenant’s keys are made and rotated.