Skip to main content

Getting started

Pick the stack you're building on. Each quickstart runs the same four titled steps — install, configure & environment, first permission check, the first admin — and then every tab funnels into one shared walkthrough, From first admin to a running org, that shows the (identical) management API for creating features, roles, and members. The per-library guides go deeper from there.

Install

These quickstarts install each library from Archenstack's GitLab Package Registry — see Installation to point your package manager at it once. Hacking on the library itself instead? Every quickstart works just as well from a local checkout of the monorepo directories (archenstack-rbac-python, archenstack-rbac-nodejs, and the rest): pip install -e ., npm install && npm run build, cargo test, go test ./....

Step 1 · Install​

Install the pure core from Archenstack's package registry — point pip at it once first (Installation):

pip install archenstack-rbac # 1.0.0

The distribution is archenstack-rbac (what pip sees); you import archenstack_rbac.

Step 2 · Configure & environment​

archenstack-rbac reads no environment variables and needs no configuration — it's pure in-memory state you build in code. There is nothing to set for the core itself; where roles, features, and overrides come from (a config file, a database, the wire snapshot) is your host application's concern.

Fail-closed by default

A fresh matrix grants nothing until you set defaults, and an undeclared (feature, role) pair resolves to the conservative NONE fallback — access is opt-in. Every cell resolves to one of four ordered access levels, NONE < VIEW < PARTIAL < FULL (read at VIEW+, write at PARTIAL+ — see Access levels). Declaring a default or override validates names (UnknownRole / UnknownFeature); querying never raises.

Step 3 · First permission check​

Build a matrix, declare its code defaults, and query it:

from archenstack_rbac import Matrix, N, V, P, F

matrix = Matrix(
roles=["administrator", "manager", "staff"],
features={"records.view": "View records", "records.edit": "Edit records"},
superusers={"owner"}, # always FULL, never a column
aliases={"supervisor": "manager"}, # 'supervisor' resolves as 'manager'
)
matrix.define_rows(
["administrator", "manager", "staff"],
{
"records.view": [F, F, V],
"records.edit": [F, P, P],
},
)

matrix.can_write("records.edit", "staff") # True (PARTIAL is writable)
matrix.can_write("records.edit", "supervisor") # True (mirrors manager)
matrix.level("records.edit", "owner").name # 'FULL' (superuser)

matrix.override("records.edit", "staff", N) # layer a runtime override
matrix.can_write("records.edit", "staff") # False

Step 4 · The first admin​

The pure core has no bootstrap knob, no HTTP layer, and no org model — so there is no "first admin" to seed here. The admin lifecycle (seeding an org admin who holds rbac.manage at FULL, then creating features, roles, and inviting members over a management API) belongs to a server adapter that persists this core and serves it over HTTP.

For Django, that's the batteries-included archenstack-rbac-django adapter — it owns the bootstrap knob, the management API, and org provisioning. On any other framework you drive this core directly and add your own HTTP layer.

Continue in From first admin to a running org to create roles, features, and invite members.

Read the full Python guide →

From first admin to a running org​

Every tab above ends here. This last stretch is the same for every backend — the wire API is byte-identical; only your language's bootstrap knob (Step 4 above) differs.

1 · Seed the first admin​

Every management route demands rbac.manage at FULL, so the very first admin assignment is the one grant that can't be made from inside the matrix — it is seeded out-of-band at boot. In a standalone / bring-your-own-auth deployment you set a bootstrap-admin-subject (ARCHENSTACK_RBAC_BOOTSTRAP_ADMIN_SUBJECT, or archenstack-rbac.bootstrap-admin-subject); Archenstack binds that stable sub to the admin role (ARCHENSTACK_RBAC_BOOTSTRAP_ADMIN_ROLE, empty ⇒ the seeded administrator) in the default org at startup — and an empty value is the explicit "off" state, never a crash. In IdP mode a separate orchestrator does the equivalent instead: provision_org(slug, first_admin_sub, plan?) creates the org inactive, seeds a lock-out-safe matrix, binds the first admin, then flips it active — atomically and idempotently, with the org denying at the resolver until that bind resolves FULL. Either way the seeded admin now holds rbac.manage FULL, and nothing else can reach the management API until it exists.

2 · One admin, one org​

That admin always operates inside exactly one organization. A single-org deployment lives in the reserved root org, supplied by ARCHENSTACK_RBAC_DEFAULT_ORG (env-sourced, no inline default — an unset value fails loudly at boot); root is a seed / backfill target only and is never a request-time fallback. A multi-tenant deployment resolves the caller's tenant from the org claim — emitted behind a dedicated organization scope — and selects that org's snapshot server-side; the management paths below are byte-identical whether you serve one org or many. Tenancy is fail-closed: a missing or unknown org denies rather than silently defaulting to root, so a misconfigured claim can only ever remove access, never cross a tenant boundary.

3 · Run the org over the management API​

Day to day, the admin does all of this — features, roles, the matrix, invitations, and assignments — through the web admin UI: the drop-in PermissionsAdmin React component (or the framework-agnostic <archenstack-admin> custom element) from @archenstack/rbac-web, which renders the Features, Roles, Permission Matrix, Members, and Assignments panels over exactly the endpoints below.

Those same endpoints are the management API, shown here as curl for scripting, automation, and non-JS backends. Every path is base-path-mounted — {base}/permissions/… ({base} is /api/v1 on Spring, host-chosen and often empty on Django) — and speaks the same versioned wire_version: 1 envelopes.

# The admin's bearer token — its role resolves rbac.manage at FULL.
BASE="https://api.example.com/api/v1" # {base}/permissions/… ; drop /api/v1 for a bare Django mount
TOKEN="…admin access token…"

Create a feature (a matrix row) — feature definition is restricted one notch tighter, to a super (developer) role, which also resolves rbac.manage FULL:

curl -sX POST "$BASE/permissions/features/" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"key": "records.edit", "label": "Edit records"}'

Create a role (a matrix column; kind defaults to standard):

curl -sX POST "$BASE/permissions/roles/" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"slug": "manager", "label": "Manager"}'

Edit a matrix cell — a bulk override PUT (delta semantics, validated against the lock-out invariant; level is 0..3, the target must be a standard role):

curl -sX PUT "$BASE/permissions/matrix/" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"cells": [{"feature": "records.edit", "role": "manager", "level": 3}]}'

Invite + assign a member — an invite pre-seeds a pending member the subject-picker draws from (POST "$BASE/permissions/members/" with {"email": "…"}); assigning binds that member's OIDC sub to a role (validated against the anti-lockout rule):

curl -sX POST "$BASE/permissions/assignments/" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"subject": "the-members-oidc-sub", "role": "manager"}'

All four require an admin token whose role resolves rbac.manage at FULL (defining features tightens that to a super role). These calls are identical across every backend library — the only thing that differs is {base}; Java, Django, Node, Go, and Rust all serve the same routes, bodies, and wire_version: 1 envelopes.

Where to next​