Plugins
Enforcers
The Enforcer is the main structure in Casbin that acts as an interface for users to perform operations on policy rules and models.
The Enforcer serves as Casbin's primary interface, providing methods for interacting with access control policies and models.
Available Enforcers
Below is a complete list of Casbin enforcers. Third-party enforcer contributions are welcome—please let us know and we'll add them to this list.
| Enforcer | Author | Description |
|---|---|---|
| Enforcer | Casbin | The base Enforcer provides the primary interface for policy and model operations. See the Management API documentation for detailed API information. |
| CachedEnforcer | Casbin | Extends the Enforcer with in-memory caching of enforcement results. Supports configurable cache expiration and includes thread-safe access via read-write locks. Use EnableCache to toggle caching (enabled by default). The remaining API methods match those of the base Enforcer. |
| DistributedEnforcer | Casbin | Designed for distributed deployments, this enforcer wraps SyncedEnforcer to work with dispatchers. Additional information is available in the dispatcher documentation. |
| SyncedEnforcer | Casbin | Extends Enforcer with synchronized access for thread-safe operations. |
| SyncedCachedEnforcer | Casbin | Combines the caching features of CachedEnforcer with the synchronization of SyncedEnforcer. |
| ContextEnforcer | Casbin | Implements the IEnforcerContext interface to provide context-aware operations. Currently supports context for adapter operations like LoadPolicyCtx(), SavePolicyCtx(), AddPolicyCtx(), and RemovePolicyCtx(). This interface is designed for future expansion of context support across additional Casbin operations. |
| Enforcer | Author | Description |
|---|---|---|
| Enforcer | Casbin | The base Enforcer provides the primary interface for policy and model operations. See the Management API documentation for detailed API information. |
| DistributedEnforcer | Casbin | Designed for distributed deployments, this enforcer wraps SyncedEnforcer to work with dispatchers. Additional information is available in the dispatcher documentation. |
| SyncedEnforcer | Casbin | Extends Enforcer with synchronized access for thread-safe operations. |
| AsyncEnforcer | Casbin | Provides asynchronous API methods for non-blocking enforcement operations. |
| FastEnforcer | Casbin | Uses an optimized model architecture offering up to 50× performance improvements over the standard enforcer. More details are available at fastbin's repository. |
