Introduction
What Strig decides, how it reaches a verdict, and where it runs.
Strig answers one question: may this subject do this to this resource?
You write a policy. You ask questions. Each answer is a verdict and the grant that produced it. The examples on this page run against Strig 0.10.
The policy, documents.strig, is in the bench beside this text.
Three questions, all about Bruno and document.edit:
| Question | Verdict | Why |
|---|---|---|
| Allow | g-edit gives editors the permission on the project. | |
| Deny | g-seal sits on the folder, a step closer to the document than the project, so it decides. | |
| Deny | Bruno has no role in Zephyr, so no grant applies. |
Bruno can still read the legal folder: g-view allows document.view, and an editor inherits the viewer role.
How it thinks#
Five things make up every decision.
Subject. Who is asking: an id, roles (optionally limited to a place), and attributes. Bruno holds editor in project:apollo, so the role does not reach Zephyr.
Resource. What is being touched, written as a path from the most specific step to the broadest: document:spec → folder:legal → project:apollo → org:acme. The path is how a grant on a project reaches a document inside it.
Permission. A dotted key from the catalog, such as document.edit. The catalog is validated when the policy loads. A permission that is not in it is denied, and depends_on means document.edit only holds where document.view does.
Grant. An allow or a deny for a subject, a permission and a target, optionally limited by scope, a condition or a validity window.
Decision. The engine collects the grants that apply along the resource path, then picks one. The default strategy, most_specific, lets the grant on the closest step decide, and a deny beats an allow on the same step. That is why g-seal overrides g-edit above. The other strategies (deny_overrides, permit_overrides, first_applicable) are one line in the policy.
The decision names the grant that settled it, so "why was this denied?" has an answer without reading code.
One policy, three models#
The same grants carry all three access-control models.
- RBAC. Roles inherit roles, as
editorinheritsviewerabove. - ABAC. A grant can carry a condition over
subject.*,resource.*andenv.*, for examplewhen subject.dept == "legal". - ReBAC. A grant can apply to whoever holds a relation, such as
editoron a document, read from tuples you store.
Ask it#
use strig::{Context, Reason, Request, Resource};
let policy = strig::dsl::parse("documents.strig", SOURCE)?.policy;
let engine = policy.engine_spec().builder()?.build()?;
let bruno = policy.subjects.iter().find(|s| s.id.as_deref() == Some("bruno")).expect("in the policy");
let ctx = Context::new(&policy.grants);
let legal = Resource::new("document", "spec")
.within("folder", "legal")
.within("project", "apollo")
.within("org", "acme");
let decision = engine.decide(&ctx, &Request::new(bruno, "document.edit", &legal));
assert!(!decision.is_allowed());
assert!(matches!(&decision.reason, Reason::Grant { grant_id, .. } if grant_id == "g-seal"));
import { load, scopeFromString } from '@the-hades-organization/strig';
const strig = await load();
const policy = strig.compile(SOURCE, { file: 'documents.strig' });
const { catalog, roles, strategy } = policy;
const engine = new strig.Engine({ catalog, roles, strategy });
const ctx = new strig.Context({ grants: policy.grants });
const bruno = policy.subjects.find((s) => s.id === 'bruno');
const resource = scopeFromString('document:spec/folder:legal/project:apollo/org:acme');
engine.check(ctx, { subject: bruno, permission: 'document.edit', resource }); // false
engine.explain(ctx, { subject: bruno, permission: 'document.edit', resource }).decision.reason.grantId; // 'g-seal'
SOURCE is the policy above. The same policy compiles to the same canonical JSON whether you write it as Rules, Blocks or Actors; see the policy language.
Where it runs#
The core does no IO, needs no async runtime and compiles to WebAssembly. Everything else is a separate crate or package you add only when you need it.
| You want | Use |
|---|---|
| Decisions inside a Rust service | strig |
| Decisions in Node or Bun, native or WebAssembly | @the-hades-organization/strig |
| Decisions in the browser, from the same engine | the WebAssembly build of the same package |
| Decisions from Python, Go or Java | strig-auth, the Go module, the JVM artifact |
| Decisions for services that do not embed the engine | strig-server, an HTTP server with a Rust client that denies when it gets no answer (guide) |
| Grants kept in Postgres or Redis | strig-postgres and strig-redis |
| Permission changes pushed to clients as they happen | strig-sync, with Redis or Postgres between instances, and strig-axum for SSE and WebSocket |
| A policy checked while your crate compiles | strig-macros: policy! and include_policy! |
| A policy tested, diffed and linted in CI | strig test, strig diff, strig lint (tools) |
| The trace of a decision, grant simulation and the audit trail | the inspector, in a window or from the terminal |
On top of the decision, Strig covers how permissions change:
- Field permissions. A permission can name the fields it covers, and a grant narrows to some of them (modeling).
- Governed changes. Governance applies a change only if every invariant passes (no escalation, no lockout, your own rules), and reports who gains and who loses access before it applies (impact).
- Approvals. A change can wait for an approver, be time-boxed as an elevation, or be reviewed in a recertification campaign. Separation of duties keeps incompatible permissions apart.
- Audit. With the
auditfeature, each change, applied or refused, becomes a hash-chained record, and if the record cannot be written the change is refused. A third party can verify the trail without trusting you. - Consistency. A decision can require the revision of a change you just made (consistency).
When to use it, and when not#
Use Strig when permissions depend on where a resource sits (an organization, a project, a folder), when a deny should be a first-class answer, or when you need to explain a decision or audit a change after the fact.
Skip it when the check is a single flag on a user and will stay one. A column is simpler.
Two limits to know before you start:
- Stable from 1.0, not yet released. The current release is 0.10, where a minor version can still break the API. From 1.0, a breaking change to the Rust engine, the JSON spec, the policy language, the audit format or the npm package takes a new major version, with a deprecation window first. The Python, Go and Java and Kotlin packages, the Wasm ABI and the command-line tools are experimental: no semver guarantee until the versioning policy says otherwise. Upgrading lists exactly what that covers.
- The client does not guard anything.
PermissionClientdecides locally for the interface. The server still decides on every operation.
Where to next#
Getting startedInstall the crate or the package and ask the first question.
ConceptsPermissions, roles, grants and how a verdict is reached.
Policy languageOne policy in three syntaxes, with the grammar.
ReferenceEvery public name by crate and package, the HTTP API and the error codes.
PlaygroundEdit a policy and watch the engine answer, in the browser. There is no hosted copy yet; build it from the repository.