Skip to content

Playbook: External authorization with Topaz (AuthZEN 1.0)

How to pair Plat5’s multi-tenant runtime with Topaz (or any OpenID AuthZEN 1.0 PDP such as Cerbos or OpenFGA with an AuthZEN adapter) for ReBAC/ABAC — without losing zero-auth services, uniform edge 403s, node list filtering, or POST /access/routes.

This playbook uses full-external authorizer mode (top-level authorizer without roles), because Topaz stores both relationships and policy. (Policy engines without their own role store, such as Cerbos or OPA, can alternatively combine authorizer with Plat5-stored roles — see reference/config/authorizer.md.) Whenever authorizer is set, the PDP decides every permission-gated route, node list filter (list_permission), and identity /access/v1/* check across all kinds, while Plat5 still handles authentication, tree membership, org security policies, suspension, credential scope narrowing, rate limits, and audit.

Define types matching Plat5’s AuthZEN payloads (member subjects, node kinds, and your record types). Topaz permission identifiers cannot contain :, so use underscore-separated permission names (organization_read, project_read, docs_read, …) across your Topaz manifest, plat5.yml list_permission values, and service route files (the topaz authorizer integration in plat5dev/registry sets routes.permission_separator: "_" for plat5 routes generate, and the standalone topaz-documents example in plat5dev/templates puts the whole stack together via plat5 init my-docs --example topaz-documents):

model:
version: 3
types:
member: {}
organization:
relations:
admin: member
viewer: member
permissions:
organization_read: viewer | admin
organization_write: admin
organization_delete: admin
organization_bindings_read: admin
organization_bindings_write: admin
project_create: admin
audit_read: viewer | admin
project:
relations:
organization: organization
admin: member
editor: member
viewer: member
permissions:
project_read: viewer | editor | admin | organization->admin
project_write: editor | admin | organization->admin
project_delete: admin | organization->admin
project_bindings_read: admin | organization->admin
project_bindings_write: admin | organization->admin
audit_read: viewer | editor | admin | organization->admin
document:
relations:
owner: member
editor: member
viewer: member
permissions:
docs_read: viewer | editor | owner
docs_write: editor | owner
docs_delete: owner

Run Topaz on your plat5 Docker network exposing its Directory v3 + OpenID AuthZEN 1.0 HTTP gateway on :9393 (or add the authorizer/topaz plugin with plat5 init / plat5 add). Wire both gateway and identity via process environment (reference/env.md):

AUTHORIZER_URL=http://topaz:9393
AUTHORIZER_TIMEOUT=2s
AUTHORIZER_CACHE_TTL=5s
AUTHORIZER_NEGATIVE_CACHE_TTL=2s
# AUTHORIZER_TOKEN=<api-key> # optional bearer token when Topaz requires auth

2. Plat5 config (plat5.yml & services/docs.yml)

Section titled “2. Plat5 config (plat5.yml & services/docs.yml)”

Declare top-level authorizer: in plat5.yml instead of roles / creator_role (authorizer reference):

kinds:
organization:
path: /orgs/{organization}
list_permission: organization_read
project:
parent: organization
path: /projects/{project}
list_permission: project_read
authorizer:
mode: authzen

In services/docs.yml, declare route permissions as usual, and add a flat resource: { type, id } on routes that check a record instead of the node:

docs:
url: http://docs:3000
scopes:
project:
upstream_prefix: /projects/{project.id}
routes:
# Collection: checked against resource { type: "project", id: "<project ulid>" }
- path: /documents
methods:
GET: { permissions: project_read }
POST: { permissions: project_write }
# Record-level routes: checked against resource { type: "document", id: "<project ulid>:<doc_id>" }
- path: /documents/{doc_id}
methods:
GET:
permissions: docs_read
resource: { type: document, id: "{project.id}:{doc_id}" }
PATCH:
permissions: docs_write
resource: { type: document, id: "{project.id}:{doc_id}" }
DELETE:
permissions: docs_delete
resource: { type: document, id: "{project.id}:{doc_id}" }

Using {project.id}:{doc_id} (or globally unique ULIDs) as resource.id guarantees tenant-scoped object IDs inside Topaz.

Identity automatically queries Topaz on node lists (GET /orgs/{org}/projects using each kind’s list_permission) and /access/v1/* calls. In external authorizer mode, creating a root/member/invite/service account creates the member without requiring a role (passing role or grants returns 422), and built-in RBAC endpoints (/bindings, /groups, /roles, /permissions) return 404.

Your docs service still does no auth checks on individual document endpoints — the gateway already enforced Topaz before forwarding. Your service only:

  1. Bootstraps root and project relations in Topaz: in external authorizer mode, creating an organization creates the creator’s member row but writes no role in Plat5. The cleanest synchronous pattern is to wrap POST /orgs and POST /orgs/{organization}/projects in your own service (wrapping identity routes): call identity’s service API (POST /roots/organization, POST /nodes/{org_id}/children/project), write (subject: member:<member_id>, relation: admin, object: organization:<org_id>) (and (subject: organization:<org_id>, relation: organization, object: project:<project_id>) for inheritance) to Topaz’s directory, forward identity’s X-Plat5-Audit-* response headers back to the gateway, and return 201 — so the creator’s very next request succeeds immediately with no async race.
  2. Writes record relations to Topaz on create/share/unshare using X-Plat5-Member-Id and the document ID:
    • On POST /projects/{project_id}/documents: create the document in your DB and write (subject: member:<X-Plat5-Member-Id>, relation: owner, object: document:<project_id>:<doc_id>) to Topaz’s directory.
    • On POST /projects/{project_id}/documents/{doc_id}/shares: write/delete the viewer/editor relation in Topaz.
  3. Tunes cache TTLs for freshness vs latency: keep AUTHORIZER_CACHE_TTL=0s and AUTHORIZER_NEGATIVE_CACHE_TTL=0s (the default) when share/unshare changes must take effect immediately, or set short TTLs (2s–5s) for high-traffic read paths.
  4. Cleans up tuples on lifecycle events: when consuming node.purged (kind: project) or member.removed from identity’s lifecycle log, delete the corresponding objects/relations in Topaz.

4. UI button visibility (POST /access/routes)

Section titled “4. UI button visibility (POST /access/routes)”

Frontends don’t talk to Topaz either. Pass the concrete document paths to POST /access/routes:

POST /access/routes
{
"checks": [
{ "method": "PATCH", "path": "/orgs/acme/projects/web/documents/doc-42" },
{ "method": "DELETE", "path": "/orgs/acme/projects/web/documents/doc-42" }
]
}

The gateway batches all checks into a single AuthZEN POST /access/v1/evaluations call and returns { "checks": [{ "allowed": true }, { "allowed": false }] }.

5. Single-root workspaces with arbitrary inner hierarchies

Section titled “5. Single-root workspaces with arbitrary inner hierarchies”

You do not need a multi-level kinds tree in Plat5 when your product’s primary structure is a user-created, arbitrarily nested, or movable hierarchy (such as nested folders, Notion-style pages, or Drive-style share graphs):

kinds:
workspace:
path: /workspaces/{workspace}
list_permission: workspace_read
authorizer:
mode: authzen

With one root kind and an external AuthZEN PDP:

  • Plat5 owns the workspace boundary and edge: JWT and API key verification, scope narrowing, workspace membership and suspension, per-workspace security policies (IP allowlists, required IdP claims, key restrictions), rate-limit tiers, fail-closed audit, lifecycle events, and batched POST /access/routes UI checks.
  • Your service and PDP own the inner graph: folder trees, reparenting/moves, inheritance, and per-item shares live in your database and Topaz/OpenFGA, enforced at the gateway through route resource: { type, id } templates (for example resource: { type: page, id: "{workspace.id}:{page_id}" }).
  • Public links and cross-workspace views: unauthenticated “anyone with the link” endpoints use scope: public, and cross-workspace views (such as “shared with me”) use scope: user (which receives X-Plat5-User-Id).

If you instead combine authorizer with Plat5-stored roles (for example with Cerbos), keep in mind that Plat5 denies members holding zero roles on the node before calling the PDP (authorizer reference), so assign workspace members a base role or use standalone authorizer mode when the PDP owns all assignments.