Skip to content

litcc/casbin-rbatis-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Casbin Rbatis adapter

Get started

RB.init(DatabaseDriver {}, database_url).expect("[abs_admin] rbatis pool init fail!");

let rb_casbin = CasbinRbatisAdapter::new(RB.clone(), true).await?;
let mut e = Enforcer::new("acl.conf", rb_casbin).await?;

let sub = "alice"; // the user that wants to access a resource.
let obj = "data1"; // the resource that is going to be accessed.
let act = "read"; // the operation that the user performs on the resource.

if let Ok(authorized) = e.enforce((sub, obj, act)) {
    if authorized {
        // permit alice to read data1
    } else {
        // deny the request
    }
} else {
    // error occurs
}

完整示例请参考 examples/mysql_sample.rs

About

casbin rbatis adapter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages