Authenticating and authorising

Two different questions, answered in two different places.

Authenticating is proving who somebody is: a password, a provider, a passkey, a token. It happens once, at the start, and it produces a session or a recognised token. That is the Authentication section.

Authorising is deciding whether this caller may have this request. It happens on every request, and it is what this section is about.

Meerkat gates in addition to your service, never instead of it. It never tells your application that a request is legitimate; it refuses the ones that are not allowed to arrive.

Where a rule can be written

Rule Where Answers
A route's access rule the route's Security section may this caller reach this route at all
An endpoint rule Infra > Endpoint security, from the route's OpenAPI spec may this caller call this operation
Membership and groups a tenant's members and groups which roles this person holds, here
The role catalogue Application > Roles which role names exist, and which imply which
Capabilities Application > Users who may administer the gateway itself

Roles come from groups, groups belong to a tenant, and roles only exist inside a tenant: a session with no active tenant holds no roles at all, whatever the person is a member of elsewhere.

The order on one request

  1. The route's predicates decide which routes could answer.
  2. The route's access rule is evaluated - as part of choosing the route, not after it. If the rule poses no condition, the request is proxied immediately and no session is even looked up.
  3. A session or a Bearer token is resolved, and the rule is answered against the caller.
  4. The route's gates and rate limits run.
  5. If the route carries endpoint rules, the operation is matched and its own rule is answered.
  6. The request is proxied, carrying the identity as headers or a signed JWT.

Two consequences of step two being part of the selection:

A worked example: only Finance opens /billing

The four places of the table above, used once each, in the order they depend on each other. The installation serves a single tenant, so its groups and members are under Application; with several tenants, the same screens are under Tenants, the tenant. The Billing route already exists and matches /billing/**.

  1. Create the role. In Application > Roles, the + on the All roles row, Role name BILLING, a description such as Reads and issues invoices, then Create. See Roles.
  2. Put the role in a group. In Application > Groups, tick BILLING in the Finance column. It saves on the click. See Groups.
  3. Put the person in the group. In Application > Members, tick Finance on alice's row. See Members.
  4. Write the route's rule. In Infra > Routes, open Billing, section Security: level In a tenant, roles BILLING, then Save. See A route's access rule.
  5. Check. On Infra > Routes, Routing test: path /billing/, As tenant the tenant, With roles BILLING, then Play: Billing reads takes this request. Without the role it reads matched, but its security refuses this caller. Then sign in as alice in a private window and open /billing/: the page answers. Another member, not in Finance, lands on /refused.

A role granted takes effect within seconds, without signing anyone out.

The default nobody should get wrong

A route that declares no access rule is delegated: the gateway poses no condition, does not resolve a session, and hands the request to the upstream, which applies whatever rules it has of its own.

No rule means not gated. It does not mean "authenticated" and it does not mean "public" - there is no public level to choose, because delegating already is one. If a route must require a session, say so: choose the level Signed in at the very least.

What a refusal looks like

A refusal on a UI route lands on a page, in the visitor's language: the tenant chooser when changing tenant would actually help, the waiting room when the account belongs nowhere, and otherwise /refused, which names the rule that turned them away and offers what this session can open.

The refusal page met by a signed-in member who lacks the role an application asks for: This page is not open to you, the reason, and under Open to you meanwhile the applications this session can open

A refusal on a service route is a 403 with a sentence: nobody reads a page in a curl. A caller with no session at all gets a 401 or, on a navigation, a redirect to the sign-in page.

With no session and no token, on a route whose rule asks for a role:

$ curl -i https://apps.acme.example/billing/api/invoices
HTTP/2 401
www-authenticate: Session
content-type: text/plain; charset=utf-8

authentication required

With a personal API token of somebody who holds no BILLING role in their tenant:

$ curl -i -H "Authorization: Bearer mk_..." https://apps.acme.example/billing/api/invoices
HTTP/2 403
content-type: text/plain; charset=utf-8

forbidden: this endpoint requires one of the roles BILLING

The sentence names what is missing: the tenant, one of the roles, one of the capabilities, or this endpoint is closed for a rule at the level Nobody.

What is not there