Get Started
การติดตั้ง
go get github.com/casbin/casbin/v3
If you're upgrading from Casbin v2 to v3, update your import paths from github.com/casbin/casbin/v2 to github.com/casbin/casbin/v3. This applies to all subpackages as well (e.g., v2/model becomes v3/model).
For Go modules, run:
go get -u github.com/casbin/casbin/v3
Then update all imports in your code from /v2 to /v3.
สำหรับ Maven:
<!-- https://mvnrepository.com/artifact/org.casbin/jcasbin -->
<dependency>
<groupId>org.casbin</groupId>
<artifactId>jcasbin</artifactId>
<version>1.x.y</version>
</dependency>
GraalVM Native Image Support
If you're building a native application with GraalVM (e.g., using Quarkus or Spring Native), jCasbin requires special configuration due to its use of the Aviator expression engine.
By default, Aviator uses dynamic class generation via ASM, which is not supported in GraalVM native images. To resolve this, you must configure Aviator to use interpreter mode instead of compilation mode.
For Quarkus applications
Add the following to your application.properties or pom.xml:
<properties>
<quarkus.native.additional-build-args>
-J-Daviator.eval.mode=INTERPRETER
</quarkus.native.additional-build-args>
</properties>
For other GraalVM native builds
Set the system property when building the native image:
-Daviator.eval.mode=INTERPRETER
Or configure it programmatically before initializing jCasbin:
System.setProperty("aviator.eval.mode", "INTERPRETER");
This configuration switches Aviator from its default compilation mode to interpreter mode. While this may have a slight performance impact, it enables full compatibility with GraalVM native images by avoiding runtime class generation.
# NPM
npm install casbin --save
# Yarn
yarn add casbin
ต้องการแพ็คเกจนี้ในไฟล์ composer.json ของโปรเจกต์ของคุณเพื่อดาวน์โหลดแพ็คเกจ:
composer require casbin/casbin
pip install casbin
dotnet add package Casbin.NET
# Download source
git clone https://github.com/casbin/casbin-cpp.git
# Generate project files
cd casbin-cpp && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release
# Build and install casbin
cmake --build . --config Release --target casbin install -j 10
cargo install cargo-edit
cargo add casbin
// If you use async-std as async executor
cargo add async-std
// If you use tokio as async executor, make sure you activate its `macros` feature
cargo add tokio
Casbin4D is packaged for Delphi 10.3 Rio and installs directly in the IDE. Note that no visual components are included—the library consists of standalone units that you import into your project independently.
luarocks install casbin
If you receive the error "Your user does not have write permissions in /usr/local/lib/luarocks/rocks", run the command with elevated privileges or install to your local tree using the --local flag:
luarocks install casbin --local