casbin
1.8.0, released 11 months ago by casbin.org
An authorization library supporting access control models like ACL, RBAC, and ABAC.
What it does
Casbin is an authorization library that enforces access control policies using models based on the PERM metamodel (Policy, Effect, Request, Matchers). It manages role-user mappings, role hierarchies, and evaluates access requests against configured rules.
AI-written summary of version 1.8.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need flexible access control models like ACL, RBAC, or ABAC in your Dart or Flutter application
- You want to manage permissions via configuration files or at runtime using standard APIs
Skip it when
- You need user authentication (verifying usernames and passwords)
- You need a password container or user management database
Strengths
- Supports multiple access control models (ACL, RBAC, ABAC, RESTful, etc.)
- Allows switching authorization mechanisms simply by modifying configuration files
- Provides both primitive management APIs and friendly RBAC APIs
Weaknesses
- Does not handle authentication or user login management
- Requires managing users and roles externally or via provided mapping APIs
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
Add the dependency to pubspec.yaml and initialize the Enforcer with a model file and a policy file.
import 'package:casbin/casbin.dart';
var e = Enforcer.fromModelPathAndPolicyFile('path/to/model.conf', 'path/to/policy.csv');
var sub = 'alice';
var obj = 'data1';
var act = 'read';
if (e.enforce([sub, obj, act])) {
// permit access
} else {
// deny access
}Works with
Packages commonly used together with casbin: ones it builds on, ones built on it, and its own family.