Skip to content

workits/casbin-zorm-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

casbin-zorm-adapter

Casbin ZORM Adapter is the ZORM Adapter for Casbin. With this library, Casbin can load policy from ZORM supported database or save policy to it.

Based on ZORM Drivers Support, the current supported databases are:

Installation

go get -u github.com/workits/casbin-zorm-adapter

Usage example

dbConfig := &zorm.DataSourceConfig{
    DSN:        "root:password@tcp(127.0.0.1:3306)/casbin?charset=utf8&parseTime=true&loc=Local",
    DriverName: "mysql",
    Dialect:    "mysql",
	// ... more configurations
}
dbDao, err := zorm.NewDBDao(dbConfig)
if err != nil {
	panic(err)
}

a := NewAdapter(dbDao) // you can also use: NewAdapter(dbDao, "your_casbin_rule_table")
e, err := casbin.NewEnforcer("examples/rbac_model.conf", a)
if err != nil {
	panic(err)
}

// ... do your things

Thanks

Special thanks to Casbin Organization, they provide a superb authorization library.

Special thanks to ZORM, a lightweight ORM.

And SQLX Adapter@memwey, which testcase I used.

License

This project is under Apache 2.0 License. See the LICENSE file for the full license text.

Releases

No releases published

Packages

No packages published

Languages