May dave export invoice d1? No. Strig says which grant decided, and where.

Same grants: g1, g2

Request · Rust

let dave = Subject::user("dave")
    .with_role_in("member", Anchor::new("org", "acme"));
let invoice = Resource::new("document", "d1")
    .within("doc_type", "invoice")
    .within("project", "p1")
    .within("org", "acme");

let decision = engine.decide(
    &Context::new(&grants),
    &Request::new(&dave, "document.invoice.export", &invoice),
);
assert!(!decision.is_allowed());

Deny

g2 denies on doc_type:invoice, the most specific step with a grant.

Resource path, broad to specific

  1. org:acmeg1 allows document.export, which implies the request. Candidate, outranked.
  2. project:p1No grant on this step.
  3. doc_type:invoiceg2 denies document.invoice.export to anyone. Decides.
  4. document:d1No grant on this step.

Strategy: MostSpecific, the default. On the deciding step, deny wins.

Request · Rust

let dave = Subject::user("dave")
    .with_role_in("member", Anchor::new("org", "acme"));
let report = Resource::new("document", "d2")
    .within("doc_type", "report")
    .within("project", "p1")
    .within("org", "acme");

let decision = engine.decide(
    &Context::new(&grants),
    &Request::new(&dave, "document.export", &report),
);
assert!(decision.is_allowed());

Allow

g1 allows on org:acme, the only step with a grant.

Resource path, broad to specific

  1. org:acmeg1 allows document.export to role member in org:acme. Decides.
  2. project:p1No grant on this step.
  3. doc_type:reportNo grant on this step. g2 sits on doc_type:invoice only.
  4. document:d2No grant on this step.

Strategy: MostSpecific, the default.

Strig is an authorization engine for Rust, with a policy language and a WebAssembly build. Every answer carries its reason.

The same grants, written as policy. Three syntaxes, one result.

Rules reads aloud, Blocks is explicit, Actors groups by who acts. All three parse to the same policy, so dave gets the same two answers.

policy.strig
language rules

kinds doc_type, document, project
broad org

permission document.export on project, document
permission document.invoice.export on doc_type, document implied by document.export

role member

user:dave has role member in org:acme

g1: allow role member to document.export on org in org:acme
g2: deny anyone to document.invoice.export on doc_type:invoice
language blocks

target_kinds = [doc_type, document, project]
broad_targets = [org]

permission document.export {
  targets = [project, document]
}

permission document.invoice.export {
  targets = [doc_type, document]
  implied_by = [document.export]
}

role member {
}

subject user:dave {
  assign member {
    scope = org:acme
  }
}

grant g1 {
  effect = allow
  subject = role member
  permission = document.export
  target = org
  scope = org:acme
}

grant g2 {
  effect = deny
  subject = anyone
  permission = document.invoice.export
  target = doc_type:invoice
}
language actors

role member
  in org:acme
    allow document.export on org as g1

anyone
  deny document.invoice.export on doc_type:invoice as g2

subject user:dave
  role member in org:acme

catalog
  kinds doc_type, document, project
  broad org
  document.export on project, document
  document.invoice.export on doc_type, document implied by document.export

Change a line. Watch the ruling change. The playground runs the real engine.

Recording · the playground, the real engine in WebAssembly

Loading the recording

Read a decision after the fact. Strig Inspect, on the desktop.

Strig Inspect showing a denied decision, the resource path and every grant with its fate.
Every grant, and what became of it. The one that decided is marked.
Strig Inspect showing who can do what on one resource, as a grid.
Who can do what on a resource, in one grid. Click a cell for its trace.
Strig Inspect listing audit records, a verified hash chain and a re-evaluation.
The hash chain is checked, then each recorded decision is run again against the current policy.
  • It fails closed

    A condition or relation that cannot be evaluated never opens access. The allow is dropped and the deny applies.

  • Three models, one set of grants

    RBAC with inheritance, ABAC with conditions, ReBAC with relation tuples.

  • A core that does no IO

    The same engine runs in Rust, in Node and Bun, and in the browser through WebAssembly.

Install. Rust first, then Node, Bun and the browser.

Strig is pre-1.0: the API can still change between minor versions. The changelog lists each change.

cargo add strig
npm install @the-hades-organization/strig

First decision · Rustsrc/main.rs

use strig::{dsl::fs::read_file, Context, Request, Resource};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let policy = read_file("policy.strig")?.policy;
    let engine = policy.engine_spec().build()?;
    let dave = policy.subjects.iter()
        .find(|s| s.id.as_deref() == Some("dave"))
        .expect("dave is in the policy");
    let d1 = Resource::new("document", "d1")
        .within("doc_type", "invoice")
        .within("project", "p1")
        .within("org", "acme");

    let decision = engine.decide(
        &Context::new(&policy.grants),
        &Request::new(dave, "document.invoice.export", &d1),
    );
    assert!(!decision.is_allowed());
    Ok(())
}

Reading a .strig file takes two features: cargo add strig --features dsl,dsl-fs. The policy is the one above.