Based on GF ORM, and tested in:
- MySQL
- PostgreSQL
go get github.com/vance-liu/gdb-adapter
opts := &Adapter{
driverName: "mysql",
dataSourceName: "root:1234@tcp(127.0.0.1:3306)/casbin",
tableName: "casbin_rule",
// or reuse an existing connection:
// db: yourDBConn,
}
a := NewAdapterFromOptions(opts)
e := casbin.NewEnforcer("examples/rbac_model.conf", a)
you should create the database on your own.
This project is under Apache 2.0 License. See the LICENSE file for the full license text.