Skip to main content

How duck-iam compares

Honest tradeoffs versus Casbin, CASL, Oso, OPA, AccessControl.js, and roll-your-own.

The space

TypeScript / Node authorization libraries cluster around four archetypes:

  1. DSL-based engines - OPA (Rego), Cedar (AWS).
  2. JSON / object policy engines - Casbin, AccessControl.js.
  3. Code-first builders - CASL, Oso, duck-iam.
  4. Hosted policy services - Permit.io, Cerbos Cloud.

duck-iam is in archetype 3 with a single twist: it runs RBAC and ABAC through one evaluation pipeline. You don't pick one; you write both side by side and the engine combines them.

Quick table

duck-iamCasbinCASLOsoOPA / CedarAccessControl.js
LanguageTypeScript nativeTS / Go / Python / manyTS nativeTS + RustDSL (Rego / Cedar)TS native
RBACFirst-classYes (RBAC model)YesYesYesYes
ABAC (conditions)First-classYes (with caveats)Yes (limited)YesYesNo
One unified pipelineYesTwo model file typesPipeline per abilityOne pipelineOne DSLRBAC only
Combining algorithms4 in-policy + 3 cross-policyCustom matcherSubject-side everySingle policyCustom in RegoNot applicable
Multi-tenantFirst-class scoped rolesManual via subjectsManualManualManualNo
explain() tracesYes (dev mode)LimitedLimitedinspect()OPA explainNo
Hot-reload policiesYes (adapter-driven)Yes (watcher)Reload at app levelYes (load_files)YesReload at app level
TypeScript inferenceConst-typed actions/resources/rolesStringly-typedStrongStrongNone (DSL)Stringly-typed
Dev/prod modesYes (boolean fast path)NoNoNoNoNo
Server adapters shippedExpress, Hono, NestJS, Next.jsBring-your-ownBring-your-ownBring-your-ownBring-your-ownBring-your-own
Client components shippedReact, Vue, vanillaNo<Can /> for ReactNoNoNo
Performance (decisions/sec)<1us prod mode~10us~20us~10us~50us (remote)~5us
LicenseMITApache 2MITApache 2Apache 2MIT

See Benchmarks -> for the duck-iam numbers against seven libraries.

When to pick duck-iam

  • You're building a TypeScript app and want strict types on every action / resource / role name.
  • You need both RBAC and ABAC, and don't want to maintain two separate policy systems.
  • You need multi-tenant scoped roles (different roles per org).
  • You want explain() traces that say exactly which rule matched and why.
  • You want a dev/prod toggle that drops decision overhead to <1us.

When to pick something else

  • OPA / Cedar: when you need a language-agnostic policy service (one set of policies enforced from Go, Python, TypeScript, etc.). duck-iam is TS-only.
  • Casbin: when you need a battle-tested engine with broad ecosystem support and don't mind less type safety.
  • Hosted policy service (Permit, Cerbos Cloud): when you'd rather not run your own policy runtime and want a polished policy editor UI.
  • CASL: when your concerns are mostly about scoping ORM queries (CASL has tight integrations with TypeORM / Sequelize / Mongoose).

What duck-iam is not

  • Not a permission marketplace. Define your own actions and resources; we don't ship a generic "manage:user" taxonomy.
  • Not an audit/SIEM. Hooks are first-class, but you bring the log sink.
  • Not authentication. Pair with duck-auth for the identity side.

See also