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.
Start two tenants
Section titled “Start two tenants”-
Stop
./devif it is running. -
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:12346masks 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:
curl http://nothing.masks.localhost:12345/.well-known/openid-configurationCompare the two issuers
Section titled “Compare the two issuers”-
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-configurationcurl http://acme.masks.localhost:12345/.well-known/openid-configurationThe
issuerof the first ishttp://demo.masks.localhost:12345. Theissuerof the second ishttp://acme.masks.localhost:12345. Every endpoint in each document is under the tenant’s own origin. -
Fetch each tenant’s signing keys:
Terminal window curl http://demo.masks.localhost:12345/.well-known/jwks.jsoncurl http://acme.masks.localhost:12345/.well-known/jwks.jsonEach tenant publishes its own key, with its own
kid(key ID). A token thatdemosigns has akidthatacmedoes not publish, so a client that trustsacmerefuses that token.
Set up each tenant
Section titled “Set up each tenant”- Open
http://demo.masks.localhost:12345in a browser.demohas no accounts yet, so it shows the Set up demo screen. - Enter the setup token
masks-dev, and follow the screen to the end. See setting a tenant up for each step. - Open
http://acme.masks.localhost:12345. It still shows Set up acme, because the account you made belongs todemoonly. - Set up
acmetoo. The same nickname and email address work, because no account atdemoexists atacme. - On each tenant’s account page, choose Manage this server.
Each /manage lists only its own tenant’s actors and clients.
Run the production image
Section titled “Run the production image”./dev image builds the production image and runs it with the same two tenants on port 5556.
./dev imageThe 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:5556The 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.
Next steps
Section titled “Next steps”- Tenants explains how masks keeps tenants apart.
- Signing keys explains how each tenant’s keys are made and rotated.