ข้ามไปยังเนื้อหาหลัก

ภาพรวม

Introduction

All users associated with a single Casdoor organization share access to the organization's applications. อย่างไรก็ตาม อาจมีกรณีที่คุณต้องการจำกัดสิทธิ์การเข้าถึงของผู้ใช้ไปยังแอปพลิเคชันบางอย่างหรือทรัพยากรเฉพาะภายในแอปพลิเคชัน ในกรณีเช่นนี้ คุณสามารถใช้คุณสมบัติ Permission ที่มีให้โดย Casbin

Understanding Casbin Concepts

Before delving deeper into the topic, it is important to have a basic understanding of how Casbin works and its related concepts:

  • Model: Defines the structure of your permission policies and the criteria for matching requests against these policies and their outcomes. You can configure models in the Models page in Casdoor.
  • Policy: Describes the specific permission rules (who can access what resources with what actions). You configure policies in the Permissions page in Casdoor.
  • Adapter: An abstraction layer that shields Casbin's executor from the source of the Policy, allowing the storage of Policies in various locations like files or databases. Learn more about Adapters.
เคล็ดลับ

Learn More About Casbin

Visit the Casbin documentation to learn more about access control models and patterns. You can also use the Casbin Online Editor to create and test Model and Policy files for your specific scenarios.

Configuring Permissions in Casdoor

Where to Configure

In the Casdoor Web UI, you'll work with two main pages:

  1. Models Page: Navigate to Models in the sidebar to add or edit Models for your organization.

    Model Edit Page

  2. Permissions Page: Navigate to Permissions in the sidebar to configure permission policies.

    Permission Edit Page

How Permissions Work

Returning to the subject of permission configuration in Casdoor:

  1. Add a Model: First, create a Model for your organization in the Models page within the Casdoor Web UI.
  2. Configure a Policy: Then, add a Policy (permission rules) for your organization in the Permissions page.

เครื่องมือแก้ไขออนไลน์ของ Casbin ที่ Casbin Online Editor สามารถให้ไฟล์โมเดลและนโยบายที่ปรับแต่งได้ตามสถานการณ์การใช้งานเฉพาะของคุณ คุณสามารถนำเข้าไฟล์โมเดลเข้าสู่ Casdoor ผ่าน Web UI ได้อย่างง่ายดายเพื่อใช้โดย Casbin ที่มีอยู่ในตัว For the Policy configuration (i.e., the Permissions page in the Casdoor Web UI), refer to the Permission Configuration guide for detailed instructions.

Using Permissions with Your Application

เช่นเดียวกับที่แอปพลิเคชันของคุณต้องบังคับใช้การควบคุมสิทธิ์การเข้าถึงผ่าน Casbin ที่มีอยู่ในตัวของ Casdoor, Casdoor เองก็ใช้โมเดลและนโยบายของตัวเองเพื่อควบคุมสิทธิ์การเข้าถึงสำหรับ API อินเทอร์เฟซผ่าน Casbin แม้ว่า Casdoor สามารถเรียกใช้ Casbin จากโค้ดภายในได้ แต่แอปพลิเคชันภายนอกไม่สามารถทำได้

เป็นทางออก Casdoor เปิดเผย API สำหรับแอปพลิเคชันภายนอกเพื่อเรียกใช้ Casbin ที่มีอยู่ในตัว See the Exposed Casbin APIs documentation for definitions of these API interfaces and instructions on how to use them.

Account Item Permissions

Casdoor also provides fine-grained permission control at the user account field level through the Edit Organization page:

  • View rule: Control who can view specific user account fields
  • Modify rule: Control who can modify specific user account fields

These rules can be set to:

  • Public: Everyone has permission
  • Self: Each user has their own permission
  • Admin: Only administrators have permission

Learn more in the Account Customization documentation.

Role-Based Access Control

Casdoor supports role-based permissions where you can assign roles to users and configure permission policies for these roles. This allows you to manage permissions at the role level rather than individual user level.

Next Steps

เรามาเริ่มกันเลย!