Casbin

Casbin

  • Docs
  • API
  • Editor
  • IDE Plugins
  • Single Sign-On (SSO)
  • Forum
  • Help
  • Blog
  • Pricing
  • Contact Sales
  • Languages iconEnglish
    • 中文
    • 한국어
    • Русский
    • Français
    • Deutsch
    • 日本語
    • Help Translate
  • GitHub

›Extensions

The Basics

  • Overview
  • Get Started
  • How it Works
  • Tutorials

Model

  • Supported Models
  • Syntax for Models
  • Effector
  • Function
  • RBAC
  • RBAC with Pattern
  • RBAC with Domains
  • Casbin RBAC v.s. RBAC96
  • ABAC
  • Priority Model
  • Super Admin

Storage

  • Model Storage
  • Policy Storage
  • Policy Subset Loading

Extensions

  • Enforcers
  • Adapters
  • Watchers
  • Dispatchers
  • Role Managers
  • Middlewares
  • GraphQL Middlewares
  • Cloud Native Middlewares

API

  • API Overview
  • Management API
  • RBAC API
  • RBAC with Domains API
  • RoleManager API
  • Data Permissions

Advanced Usage

  • Multi-threading
  • Benchmarks
  • Performance Optimization
  • Authorization of Kubernetes
  • Authorization of Service Mesh through Envoy

Management

  • Admin Portal
  • Casbin Service
  • Log & Error Handling
  • Frontend Usage

Editor

  • Online Editor
  • IDE Plugins

More

  • Our Adopters
  • Contributing
  • Privacy Policy
  • Terms of Service
Edit

Watchers

We support to use distributed messaging systems like etcd to keep consistence between multiple Casbin enforcer instances. So our users can concurrently use multiple Casbin enforcers to handle large number of permission checking requests.

Similar to policy storage adapters, we don't put watcher code in the main library. Any support for a new messaging system should be implemented as a watcher. A complete list of Casbin watchers is provided as below. Any 3rd-party contribution on a new watcher is welcomed, please inform us and I will put it in this list:)

Go
Java
Node.js
Python
.NET
Ruby
PHP
WatcherTypeAuthorDescription
Etcd WatcherKV storeCasbinWatcher for etcd
Redis WatcherKV storeCasbinWatcher for Redis
Redis WatcherKV store@billcobblerWatcher for Redis
TiKV WatcherKV storeCasbinWatcher for TiKV
Kafka WatcherMessaging system@wgarunapWatcher for Apache Kafka
NATS WatcherMessaging systemSolutoWatcher for NATS
ZooKeeper WatcherMessaging systemGrepsrWatcher for Apache ZooKeeper
NATS, RabbitMQ, GCP Pub/Sub, AWS SNS & SQS, Kafka, InMemoryMessaging System@rusenaskWatcher based on Go Cloud Dev Kit that works with leading cloud providers and self-hosted infrastructure
RocketMQ WatcherMessaging system@fmyxyzWatcher for Apache RocketMQ
WatcherTypeAuthorDescription
Etcd AdapterKV store@mapleafgoWatcher for etcd
Redis WatcherKV storeCasbinWatcher for Redis
Kafka WatcherMessaging systemCasbinWatcher for Apache Kafka
WatcherTypeAuthorDescription
Etcd WatcherKV storeCasbinWatcher for etcd
Redis WatcherKV storeCasbinWatcher for Redis
Pub/Sub WatcherMessaging systemCasbinWatcher for Google Cloud Pub/Sub
Postgres WatcherDatabaseMatteo CollinaWatcher for PostgreSQL
WatcherTypeAuthorDescription
Redis WatcherKV storeScienceLogicWatcher for Redis
PostgreSQL WatcherDatabaseCasbinWatcher for PostgreSQL
WatcherTypeAuthorDescription
Redis WatcherKV store@SbouWatcher for Redis
WatcherTypeAuthorDescription
Redis WatcherKV storeCasbinRubyWatcher for Redis
RabbitMQ WatcherMessaging systemCasbinRubyWatcher for RabbitMQ
WatcherTypeAuthorDescription
Redis WatcherKV storeTinywanWatcher for Redis

WatcherEx

In order to support incremental synchronization between multiple instances, we provide the WatcherEx interface. We hope it can notify other instances when the policy changes, but there is currently no implementation of WatcherEx. We recommend that you use dispatcher to achieve this.

Compared with Watcher interface, WatcherEx can distinguish what type of update action is received, e.g., AddPolicy and RemovePolicy.

WatcherEx Apis:

apidescription
SetUpdateCallback(func(string)) errorSetUpdateCallback sets the callback function that the watcher will call, when the policy in DB has been changed by other instances. A classic callback is Enforcer.LoadPolicy().
Update() errorUpdate calls the update callback of other instances to synchronize their policy. It is usually called after changing the policy in DB, like Enforcer.SavePolicy(), Enforcer.AddPolicy(), Enforcer.RemovePolicy(), etc.
Close()Close stops and releases the watcher, the callback function will not be called any more.
UpdateForAddPolicy(sec, ptype string, params ...string) errorUpdateForAddPolicy calls the update callback of other instances to synchronize their policy. It is called after a policy is added via Enforcer.AddPolicy(), Enforcer.AddNamedPolicy(), Enforcer.AddGroupingPolicy() and Enforcer.AddNamedGroupingPolicy().
UpdateForRemovePolicy(sec, ptype string, params ...string) errorUPdateForRemovePolicy calls the update callback of other instances to synchronize their policy. It is called after a policy is removed by Enforcer.RemovePolicy(), Enforcer.RemoveNamedPolicy(), Enforcer.RemoveGroupingPolicy() and Enforcer.RemoveNamedGroupingPolicy().
UpdateForRemoveFilteredPolicy(sec, ptype string, fieldIndex int, fieldValues ...string) errorUpdateForRemoveFilteredPolicy calls the update callback of other instances to synchronize their policy. It is called after Enforcer.RemoveFilteredPolicy(), Enforcer.RemoveFilteredNamedPolicy(), Enforcer.RemoveFilteredGroupingPolicy() and Enforcer.RemoveFilteredNamedGroupingPolicy().
UpdateForSavePolicy(model model.Model) errorUpdateForSavePolicy calls the update callback of other instances to synchronize their policy. It is called after Enforcer.SavePolicy()
UpdateForAddPolicies(sec string, ptype string, rules ...[]string) errorUpdateForAddPolicies calls the update callback of other instances to synchronize their policy. It is called after Enforcer.AddPolicies(), Enforcer.AddNamedPolicies(), Enforcer.AddGroupingPolicies() and Enforcer.AddNamedGroupingPolicies().
UpdateForRemovePolicies(sec string, ptype string, rules ...[]string) errorUpdateForRemovePolicies calls the update callback of other instances to synchronize their policy. It is called after Enforcer.RemovePolicies(), Enforcer.RemoveNamedPolicies(), Enforcer.RemoveGroupingPolicies() and Enforcer.RemoveNamedGroupingPolicies().
Last updated on 11/28/2022
← AdaptersDispatchers →
  • WatcherEx
Casbin
Docs
Getting StartedManagement APIRBAC APIMiddlewares
Community
Who's using Casbin?Stack Overflow
Casbin          jCasbin
Node-Casbin   PHP-CasbinPyCasbin          Casbin.NETCasbin-CPP        Casbin-RS
Follow @casbinHQ
Copyright © 2022 Casbin Organization