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

RoleManager API

RoleManager

RoleManager provides interface to define the operations for managing roles. Adding matching function to rolemanager allows using wildcards in role name and domain.

AddNamedMatchingFunc()

AddNamedMatchingFunc add MatchingFunc by ptype RoleManager. MatchingFunc will work when operating role matching.

Go
Node.js
    e.AddNamedMatchingFunc("g", "", util.KeyMatch)
_, _ = e.AddGroupingPolicies([][]string{{"*", "admin", "domain1"}})
_, _ = e.GetRoleManager().HasLink("bob", "admin", "domain1") // -> true, nil
    await e.addNamedMatchingFunc('g', Util.keyMatchFunc);
await e.addGroupingPolicies([['*', 'admin', 'domain1']]);
await e.getRoleManager().hasLink('bob', 'admin', 'domain1');

For example:

Go
Node.js
    e, _ := casbin.NewEnforcer("path/to/model", "path/to/policy")
e.AddNamedMatchingFunc("g", "", util.MatchKey)
    const e = await newEnforcer('path/to/model', 'path/to/policy');
await e.addNamedMatchingFunc('g', Util.keyMatchFunc);

AddNamedDomainMatchingFunc()

AddNamedDomainMatchingFunc add MatchingFunc by ptype to RoleManager. DomainMatchingFunc is similar to MatchingFunc listed above.

For example:

Go
Node.js
    e, _ := casbin.NewEnforcer("path/to/model", "path/to/policy")
e.AddNamedDomainMatchingFunc("g", "", util.MatchKey)
    const e = await newEnforcer('path/to/model', 'path/to/policy');
await e.addNamedDomainMatchingFunc('g', Util.keyMatchFunc);

GetRoleManager()

GetRoleManager gets the current role manager for g.

For example:

Go
Node.js
Python
    rm := e.GetRoleManager()
    const rm = await e.getRoleManager();
    rm = e.get_role_manager()

Clear()

Clear clears all stored data and resets the role manager to the initial state.

For example:

Go
Node.js
Python
    rm.Clear()
    await rm.clear();
    rm.clear()

AddLink()

AddLink adds the inheritance link between two roles. role: name1 and role: name2. Domain is a prefix to the roles (can be used for other purposes).

For example:

Go
Node.js
Python
    rm.AddLink("u1", "g1", "domain1")
    await rm.addLink('u1', 'g1', 'domain1');
    rm.add_link("u1", "g1", "domain1")

DeleteLink()

DeleteLink deletes the inheritance link between two roles. role: name1 and role: name2. Domain is a prefix to the roles (can be used for other purposes).

For example:

Go
Node.js
Python
    rm.DeleteLink("u1", "g1", "domain1")
    await rm.deleteLink('u1', 'g1', 'domain1');
    rm.delete_link("u1", "g1", "domain1")

HasLink()

HasLink determines whether a link exists between two roles. role: name1 inherits role: name2. Domain is a prefix to the roles (can be used for other purposes).

For example:

Go
Node.js
Python
    rm.HasLink("u1", "g1", "domain1")
    await rm.hasLink('u1', 'g1', 'domain1');
    rm.has_link("u1", "g1", "domain1")

GetRoles()

GetRoles gets the roles that a user inherits. Domain is a prefix to the roles (can be used for other purposes).

For example:

Go
Node.js
Python
    rm.GetRoles("u1", "domain1")
    await rm.getRoles('u1', 'domain1');
    rm.get_roles("u1", "domain")

GetUsers()

GetUsers gets the users that inherits a role. Domain is a prefix to the users (can be used for other purposes).

For example:

Go
Node.js
Python
    rm.GetUsers("g1")
    await rm.getUsers('g1');
    rm.get_users("g1")

PrintRoles()

PrintRoles prints all the roles to log.

For example:

Go
Node.js
Python
    rm.PrintRoles()
    await rm.printRoles();
    rm.print_roles()

SetLogger()

SetLogger sets role manager's logger.

For example:

Go
    logger := log.DefaultLogger{}
logger.EnableLog(true)
rm.SetLogger(&logger)
_ = rm.PrintRoles()

GetDomains()

GetDomains gets domains that a user has

For example:

Go
    result, err := rm.GetDomains(name)
← RBAC with Domains APIData Permissions →
  • RoleManager
    • AddNamedMatchingFunc()
    • AddNamedDomainMatchingFunc()
    • GetRoleManager()
    • Clear()
    • AddLink()
    • DeleteLink()
    • HasLink()
    • GetRoles()
    • GetUsers()
    • PrintRoles()
    • SetLogger()
    • GetDomains()
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