CASL

Isomorphic authorization library for JavaScript/TypeScript. CASL defines what a user CAN do using ability rules — 'user can read Post', 'user cannot delete Post if not owner'. Works in both frontend (hide UI elements) and backend (enforce API access). Supports Role-Based (RBAC), Attribute-Based (ABAC), and subject-based access control. Integrates with Prisma, Mongoose, AngularJS, React, and Vue.

Evaluated Mar 06, 2026 (0d ago) v6+
Homepage ↗ Repo ↗ Developer Tools authorization permissions rbac abac typescript react angular
⚙ Agent Friendliness
66
/ 100
Can an agent use this?
🔒 Security
87
/ 100
Is it safe for agents?
⚡ Reliability
79
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
85
Error Messages
80
Auth Simplicity
88
Rate Limits
100

🔒 Security

TLS Enforcement
90
Auth Strength
85
Scope Granularity
88
Dep. Hygiene
85
Secret Handling
88

In-process authorization — always enforce server-side; never rely on client-side checks for security. Rule definition in code means permissions are version-controlled. MIT licensed.

⚡ Reliability

Uptime/SLA
85
Version Stability
78
Breaking Changes
72
Error Recovery
82
AF Security Reliability

Best When

You need fine-grained, isomorphic authorization with JavaScript/TypeScript that works in both your frontend and backend with the same rules.

Avoid When

You need centralized external policy management, audit logging, or a standardized policy language — use Cerbos or Open Policy Agent for those requirements.

Use Cases

  • Define user permissions for agent systems — 'agent can execute X if authorized for namespace Y' — with unified frontend/backend enforcement
  • Implement RBAC in Node.js APIs where different user roles (admin, editor, viewer) have different CRUD permissions per resource type
  • Hide UI components based on user permissions in React using CASL's React integration (Can component, useAbility hook)
  • Filter database queries based on user permissions using CASL's Prisma/Mongoose integration — automatically scope queries to accessible records
  • Build multi-tenant authorization where users can only access their organization's data using attribute-based conditions

Not For

  • Simple role checks where a basic if/else or enum comparison is sufficient
  • External policy services — CASL is in-process authorization; use Open Policy Agent or Cerbos for external policy engines
  • Complex policy languages — CASL rules are defined in JavaScript, not a separate policy language like Rego (OPA)

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No authentication — authorization library. Integrates with existing auth sessions to define abilities based on authenticated user.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

MIT-licensed open source library.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • CASL ability rules are evaluated in order — more specific rules override general rules; rule ordering matters and affects which rules take precedence
  • Ability rules must be rebuilt when user permissions change — rules are defined at object creation time; changing user role requires creating a new AbilityBuilder with new rules
  • Condition fields in CASL rules ({ author: user.id }) are compared against subject attributes — the subject object must have the matching fields populated for conditions to work
  • Frontend CASL integration (Can component) is for UX only — always enforce permissions server-side; never rely on frontend CASL for security
  • CASL v6 changed the API for defining abilities — v5 and v6 code is not compatible; major version upgrades require ability definition rewrites
  • Database integration (casl-prisma, casl-mongoose) generates query filters but requires explicit application — CASL doesn't automatically filter queries; call accessibleBy() explicitly

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for CASL.

$99

Scores are editorial opinions as of 2026-03-06.

5215
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered