# casbin **Repository Path**: go_27/casbin ## Basic Information - **Project Name**: casbin - **Description**: No description available - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-28 - **Last Updated**: 2025-10-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Casbin Access Control Framework Examples ## Project Introduction This repository provides comprehensive usage examples of the Casbin access control framework, including basic ACL, RBAC permission model implementations, and integration examples with mainstream Go web frameworks and ORMs. ## Casbin Features - Support for multiple access control models: ACL, RBAC, ABAC, etc. - Flexible policy configuration: file-based or database storage - Multi-language implementation: Go, Java, Python, Node.js, etc. - Framework-agnostic: can be integrated with any framework - High performance: optimized policy matching algorithms ## Directory Structure ``` f:\code\casbin/ ├── 1.基本使用.go # Basic ACL permission example ├── 2.rbac.go # RBAC permission model example ├── model.pml # Basic model definition file ├── policy.csv # Basic policy configuration file ├── rbac_model.conf # RBAC model definition ├── rbac_policy.csv # RBAC policy configuration ├── md/ # Documentation directory │ ├── casbin使用说明.md # Casbin basic usage guide (Chinese) │ ├── casbin在Fiber使用.md # Fiber framework integration guide (Chinese) │ ├── casbin在Gin使用.md # Gin framework integration guide (Chinese) │ ├── casbin在Gorm使用.md # GORM ORM integration guide (Chinese) │ └── rbac示例.md # Detailed RBAC example guide (Chinese) ├── go.mod # Go module file └── go.sum # Dependency checksum file ``` ## Quick Start ### 1. Install Dependencies ```bash go get github.com/casbin/casbin/v2 ``` ### 2. Basic Usage Example ```go // Basic ACL permission check example package main import ( "fmt" "github.com/casbin/casbin/v2" ) func main() { // Initialize enforcer e, err := casbin.NewEnforcer("model.pml", "policy.csv") if err != nil { fmt.Printf("Failed to initialize Casbin: %v\n", err) return } // Check permission ok, err := e.Enforce("alice", "data1", "read") if err != nil { fmt.Printf("Permission check error: %v\n", err) } if ok { fmt.Println("Permission granted") } else { fmt.Println("Permission denied") } } ``` ### 3. Run Examples Execute basic example: ```bash go run 1.基本使用.go ``` Execute RBAC example: ```bash go run 2.rbac.go ``` ## Related Resources - [Casbin Official Website](https://casbin.org/) - [Casbin GitHub Repository](https://github.com/casbin/casbin) - [Casbin Go Documentation](https://github.com/casbin/casbin/blob/master/README.md) ## License This project is licensed under the Apache 2.0 License. See the LICENSE file for details.