Casbin

Casbin

  • 文档
  • API
  • 编辑器
  • IDE 插件
  • Single Sign-On (SSO)
  • 论坛
  • 帮助
  • 博客
  • Pricing
  • Contact Sales
  • Languages icon中文
    • English
    • 한국어
    • Русский
    • Français
    • Deutsch
    • 日本語
    • 参与翻译
  • GitHub

›扩充功能

基础知识

  • 概述
  • 开始使用
  • 工作原理
  • 教程

Model

  • 支持的Models
  • Model语法
  • 效果器
  • 函数
  • 基于角色的访问控制
  • RBAC with Pattern
  • 域内RBAC
  • Casbin RBAC v.s. RBAC96
  • ABAC
  • 优先级模型
  • 超级管理员

存储

  • Model存储
  • Policy存储
  • 政策子集加载

扩充功能

  • Enforcers
  • 适配器
  • 观察者
  • 调度器
  • 角色管理器
  • 中间件
  • Graphql 中间件
  • 云端原生中间值

API

  • API 概述
  • 管理 API
  • RBAC API
  • 域内基于角色的访问控制 API
  • RoleManager API
  • 数据权限

高级用法

  • 多线程
  • 基准测试
  • 性能优化
  • Kubernetes的授权
  • 通过特使核准服务网格。

管理

  • 管理员门户
  • Casbin 服务
  • 日志 & 错误处理
  • 前端使用

编辑器

  • 在线编辑器
  • IDE 插件

更多

  • 本项目使用者
  • 贡献中
  • 隐私政策
  • 服务条款
Translate

观察者

我们支持使用分布式消息系统,例如 etcd 来保持多个Casbin执行器实例之间的一致性。 因此,我们的用户可以同时使用多个Casbin 执行器来处理大量的权限检查请求。

与策略存储 adapters类似,我们没有把watcher的代码放在主库中。 任何对新消息系统的支持都应该作为watcher程序来实现。 完整的Casbin watchers列表如下所示。 欢迎任何第三方对 watcher 进行新的贡献,如果有请告知我们,我将把它放在这个列表中:)

Go
Java
Node.js
Python
.NET
Ruby
PHP
监视器类型作者说明
Etcd 监视器键值对存储Casbinetcd的监视器
Redis Watcher键值对存储CasbinRedis的监视器
Redis 监视器键值对存储@billcobblerRedis的监视器
TiKV 监视器键值对存储CasbinTiKV 的监视器
Kafka 监视器消息传递系统。@wgarunapApache Kafka的监视器
NATS 监视器消息传递系统。SolutoNATS的监视器
ZooKeeper 监视器消息传递系统。GrepsrApache ZooKeeper的监视器
NATS, RabbitMQ, GCP Pub/Sub, AWS SNS & SQS, Kafka, InMemory消息传递系统。@rusenask基于Go Cloud Dev Kit与领先的云供应商和自托管基础设施运作的监视器
RocketMQ 观察器消息传递系统。@fmyxyzApache RocketMQ的监视器
监视器类型作者说明
Etcd 适配器KV store@mapleafgoetcd的监视器
Redis 监视器键值对存储CasbinRedis的监视器
卡夫卡观察者消息系统CasbinApache Kafka的关注者
监视器类型作者说明
Etcd WatcherKV storeCasbinetcd的监视器
Redis WatcherKV storeCasbinRedis的监视器
Pub/Sub WatcherMessaging systemCasbinGoogle Cloud Pub/Sub的监视器
Postgres Watcher数据库Matteo CollinaPostgreSQL的监视器
监视器类型作者说明
Redis 监视器KV storeScienceLogicRedis的监视器
PostgreSQL Watcher数据库CasbinPostgreSQL的监视器
监视器类型作者说明
Redis WatcherKV store@SbouRedis的Watcher
监视器类型作者描述
Redis 监视器键值对存储CasbinRubyetcd的监视器
RabbitMQ 监视器消息传递系统。CasbinRubyRabbitMQ 的监视器
监视器类型作者描述
Redus 监视器键值对存储TinywanRedis的监视器

WatcherEx

为了支持多个实例之间的增量同步,我们提供 WatcherEx 接口。 我们希望它能够在策略改变时通知其他实例,但目前尚未实现 WatcherEx。 我们推荐您使用调度器来实现它。

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

WatcherEx Apis:

api描述
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().
← 适配器调度器 →
  • 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