๐ŸŽ‰ Visit the new Casbin docs at: casbin.org now! ๐Ÿฅณ
Casbin

Casbin

  • ๋ฌธ์„œ
  • API
  • ํŽธ์ง‘๊ธฐ
  • IDE Plugins
  • Single Sign-On (SSO)
  • Forum
  • ๋„์›€๋ง
  • ๋ธ”๋กœ๊ทธ
  • Pricing
  • Contact Sales
  • Languages iconํ•œ๊ตญ์–ด
    • English
    • ไธญๆ–‡
    • ะ ัƒััะบะธะน
    • Franรงais
    • Deutsch
    • ๆ—ฅๆœฌ่ชž
    • ๋ฒˆ์—ญ ์ฐธ์—ฌํ•˜๊ธฐ
  • GitHub

โ€บAPI

๊ธฐ์ดˆ

  • ๊ฐœ์š”(Overview)
  • ์‹œ์ž‘ํ•˜๊ธฐ
  • ์ž‘๋™ ์›๋ฆฌ
  • ์ž์Šต์„œ

๋ชจ๋ธ

  • ์ง€์›ํ•˜๋Š” ์ ‘๊ทผ ์ œ์–ด ๋ชจ๋ธ
  • ๋ชจ๋ธ(Model) ๋ฌธ๋ฒ•
  • Effector
  • ํ•จ์ˆ˜
  • RBAC
  • RBAC with Pattern
  • RBAC + ๋„๋ฉ”์ธ
  • Casbin RBAC v.s. RBAC96
  • ABAC
  • Priority Model
  • Super Admin

์ €์žฅ์†Œ

  • ๋ชจ๋ธ(Model) ์ €์žฅ
  • ์ •์ฑ…(Policy) ์ €์žฅ
  • ์ •์ฑ…(Policy) ๋ถ€๋ถ„ ์ง‘ํ•ฉ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

ํ™•์žฅ ๊ธฐ๋Šฅ

  • Enforcers
  • ์–ด๋Œ‘ํ„ฐ
  • ๊ฐ์‹œ์ž
  • Dispatchers
  • ์—ญํ• (Role) ๊ด€๋ฆฌ์ž
  • ๋ฏธ๋“ค์›จ์–ด
  • GraphQL Middlewares
  • Cloud Native Middlewares

API

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

๊ณ ๊ธ‰ ์‚ฌ์šฉ๋ฒ• (Advanced usage)

  • ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋”ฉ
  • ๋ฒค์น˜๋งˆํฌ
  • Performance Optimization
  • Authorization of Kubernetes
  • Authorization of Service Mesh through Envoy

๊ด€๋ฆฌ

  • ๊ด€๋ฆฌ์ž ํฌํƒˆ
  • Casbin ์„œ๋น„์Šค
  • ๋กœ๊น… ๋ฐ ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ
  • Frontend Usage

Editor

  • ์˜จ๋ผ์ธ ํŽธ์ง‘๊ธฐ
  • IDE Plugins

์ž์„ธํžˆ

  • Casbin ์ ์šฉ ์‚ฌ๋ก€
  • Contributing
  • Privacy Policy
  • Terms of Service
Translate

RBAC with Domains API

A more friendly API for RBAC with domains. This API is a subset of Management API. The RBAC users could use this API to simplify the code.

Reference

global variable e is Enforcer instance.

Go
Node.js
PHP
Python
.NET
Rust
Java
e, err := NewEnforcer("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv")
const e = await newEnforcer('examples/rbac_with_domains_model.conf', 'examples/rbac_with_domains_policy.csv')
$e = new Enforcer('examples/rbac_with_domains_model.conf', 'examples/rbac_with_domains_policy.csv');
e = casbin.Enforcer("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv")
var e = new Enforcer("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv");
let mut e = Enforcer::new("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv").await?;
Enforcer e = new Enforcer("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv");

GetUsersForRoleInDomain()

GetUsersForRoleInDomain gets the users that has a role inside a domain.

For example:

Go
Node.js
Python
res := e.GetUsersForRoleInDomain("admin", "domain1")
const res = e.getUsersForRoleInDomain("admin", "domain1")
res = e.get_users_for_role_in_domain("admin", "domain1")

GetRolesForUserInDomain()

GetRolesForUserInDomain gets the roles that a user has inside a domain.

For example:

Go
Node.js
Python
Java
res := e.GetRolesForUserInDomain("admin", "domain1")
const res = e.getRolesForUserInDomain("alice", "domain1")
res = e.get_roles_for_user_in_domain("alice", "domain1")
List<String> res = e.getRolesForUserInDomain("admin", "domain1");

GetPermissionsForUserInDomain()

GetPermissionsForUserInDomain gets permissions for a user or role inside a domain.

For example:

Go
Java
res := e.GetPermissionsForUserInDomain("alice", "domain1")
List<List<String>> res = e.getPermissionsForUserInDomain("alice", "domain1");

AddRoleForUserInDomain()

AddRoleForUserInDomain adds a role for a user inside a domain. Returns false if the user already has the role (aka not affected).

For example:

Go
Python
Java
ok, err := e.AddRoleForUserInDomain("alice", "admin", "domain1")
ok = e.add_role_for_user_in_domain("alice", "admin", "domain1")
boolean ok = e.addRoleForUserInDomain("alice", "admin", "domain1");

DeleteRoleForUserInDomain()

DeleteRoleForUserInDomain deletes a role for a user inside a domain. Returns false if the user does not have the role (aka not affected).

For example:

Go
Java
ok, err := e.DeleteRoleForUserInDomain("alice", "admin", "domain1")
boolean ok = e.deleteRoleForUserInDomain("alice", "admin", "domain1");

DeleteRolesForUserInDomain()

DeleteRolesForUserInDomain deletes all roles for a user inside a domain. Returns false if the user does not have any roles (aka not affected).

For example:

Go
ok, err := e.DeleteRolesForUserInDomain("alice", "domain1")

GetAllUsersByDomain()

GetAllUsersByDomain would get all users associated with the domain. Returns empty string array if has no domain defined in model.

For example:

Go
res := e.GetAllUsersByDomain("domain1")

DeleteAllUsersByDomain()

DeleteAllUsersByDomain would delete all users associated with the domain. Returns false if has no domain defined in model.

For example:

Go
ok, err := e.DeleteAllUsersByDomain("domain1")

DeleteDomains()

DeleteDomains would delete all associated users and roles. It would delete all domains if parameter is not provided.

For example:

Go
ok, err := e.DeleteDomains("domain1", "domain2")

GetAllDomains()

GetAllDomains would get all domains.

For example:

Go
res, _ := e.GetAllDomains()
note

If you are handling a domain like name::domain, it may lead to unexpected behavior. In Casbin, :: is a reversed keyword, just like for, if in a programming language, we should never put :: in a domain.


โ† RBAC APIRoleManager API โ†’
  • Reference
    • GetUsersForRoleInDomain()
    • GetRolesForUserInDomain()
    • GetPermissionsForUserInDomain()
    • AddRoleForUserInDomain()
    • DeleteRoleForUserInDomain()
    • DeleteRolesForUserInDomain()
    • GetAllUsersByDomain()
    • DeleteAllUsersByDomain()
    • DeleteDomains()
    • GetAllDomains()
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