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

›Model

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

Effector

Effect is the result of a policy rule. And the Effector is the interface for Casbin effectors.

MergeEffects()

MergeEffects merges all matching results collected by the enforcer into a single decision.

For example:

Go
Effect, explainIndex, err = e.MergeEffects(expr, effects, matches, policyIndex, policyLength)

In this example:

  • Effect is the final decision being merged by this function(Initialized as Indeterminate).
  • explainIndex is the index of eft which is Allow or Deny.(Initialized as -1)
  • err is used to check if the effect is supported.
  • expr is the policy effects stored as string
  • effects is the array of the Effect which can be Allow, Indeterminate or Deny
  • matches is the array showing that if the result is matching the policy.
  • policyIndex is the index of policy in the model.
  • policyLength is the length of the policy.

The code above illustrates how can we pass the parameters to the MergeEffects function and the function will process the effects and matches based on the expr

To deploy an Effector, we can do this:

Go
var e Effector
Effect, explainIndex, err = e.MergeEffects(expr, effects, matches, policyIndex, policyLength)

The basic idea of the MergeEffects indicates that if the expr can match the results which means that the p_eft is allow, then we can merge all effects at last. And if there are no deny rules are matched, then we allow.

note

If the expr can not match "priority(p_eft) || deny" and also the policyIndex is shorter than policyLength-1, it will short-circuit some effects in the middle.

Last updated on 11/28/2022
← Syntax for ModelsFunction →
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