Casbin

Casbin

  • ドキュメント
  • API
  • エディター
  • IDE プラグイン
  • Single Sign-On (SSO)
  • フォーラム
  • ヘルプ
  • ブログ
  • Pricing
  • Contact Sales
  • Languages icon日本語
    • English
    • 中文
    • 한국어
    • Русский
    • Français
    • Deutsch
    • 翻訳に協力する
  • GitHub

›API

基本

  • 概要
  • はじめよう
  • 仕組み
  • チュートリアル

モデル

  • サポートされるモデル
  • モデルの構文
  • エフェクト
  • 関数
  • RBAC
  • RBAC with Pattern
  • ドメイン付きRBAC
  • Casbin RBAC v.s. RBAC96
  • ABAC
  • 優先モデル
  • スーパー管理者

ストレージ

  • モデル ストレージ
  • ポリシーストレージ
  • ポリシーサブセットの読み込み

拡張

  • Enforcers
  • アダプター
  • Watchers
  • 派遣者
  • ロールマネージャー
  • ミドルウェア
  • GraphQL Middlewares
  • Cloud Native Middlewares

API

  • API の概要
  • 管理API
  • RBAC API
  • Domains API による RBAC
  • RoleManager API
  • データ権限

高度な使い方

  • マルチスレッド
  • Benchmarks
  • パフォーマンス最適化
  • Kubernetes の承認
  • Envoyによるサービスメッシュの承認

管理

  • 管理者ポータル
  • カスビンサービス
  • ログとエラー処理
  • フロントエンドの使用法

エディター

  • オンラインエディター
  • IDE プラグイン

もっと見る

  • Adopters
  • コントリビューション
  • プライバシーポリシー
  • 利用規約
Translate

Domains API による RBAC

ドメインとRBAC用のよりフレンドリーなAPI。 この API は管理 API のサブセットです。 RBAC ユーザーはこの API を使用してコードを簡素化することができます。

参照

global variable e は Enforcer インスタンスです。

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 は、ドメイン内のロールを持つユーザーを取得します。

例:

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 は、ユーザーがドメイン内に持つロールを取得します。

例:

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 は、ドメイン内のユーザーまたはロールに対する権限を取得します。

例:

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

AddRoleForUserInDomain()

AddRoleForUserInDomain は、ドメイン内のユーザーにロールを追加します。 ユーザーがすでに役割を持っている場合は、false を返します。

例:

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 は、ドメイン内のユーザーのロールを削除します。 役割を持たない場合は、false を返します。

例:

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

DeleteRolesForUserInDomain()

DeleteRolesForUserInDomain は、ドメイン内のユーザーのすべてのロールを削除します。 ユーザーにロールがない場合は false を返します(影響を受けない場合)。

例:

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

GetAllUsersByDomain()

GetAllUsersByDomain は、ドメインに関連付けられたすべてのユーザーを取得します。 モデルにドメインが定義されていない場合は、空の文字列配列を返します。

例:

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

DeleteAllUsersByDomain()

DeleteAllUsersByDomain は、ドメインに関連付けられているすべてのユーザーを削除します。 モデルにドメインが定義されていない場合は false を返します。

例:

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

DeleteDomains ()

DeleteDomains will delete all associated users and roles. パラメータが指定されていない場合は、すべてのドメインを削除します。

例:

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 →
  • 参照
    • 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