Casbin Rbatis adapter
Rbatis adapter for casbin. With this library, Casbin can load policy or save policy from Rbatis supported databases.
Supported databases, see Rbatis
- MySQL
- PostgreSQL
- SQLite
- MSSQL
- ...
Casbin online editor
Get started
Add the following to Cargo.toml:
[]
= "0.1"
# casbin or use casbin_rb_adapter::casbin
= "2"
# rbatis integration
= "4"
= "4"
# choose rbatis driver
# rbdc-mysql = "*"
# rbdc-pg = "*"
# rbdc-sqlite= "*"
# rbdc-mssql = "*"
// or use your project Rbatis static instance
let rb = new;
rb.init.unwrap;
let adapter = new.await?;
// need to call db_sync() to create tables in database
// adapter.db_sync().await?;
let mut e = new.await?;
// e.enforce((sub, obj, act)).await?;
features:
tracinglogger for Adapter.runtime-tokioruntime for casbin.runtime-async-stdruntime for casbin.
Example
How to run examples:
You need to create a .env file in the project root directory, and add the following configuration:
DATABASE_URL=mysql://root:123456@localhost:3306/casbin
update log
- v0.1.9: add
runtime-tokioandruntime-async-stdfeatures for casbin, addtracingfeature logger for Adapter. default featureruntime-tokio.