Ent Adapter is the ent adapter for Casbin. With this library, Casbin can load policy from PostgresSQL/Mysql or save policy to it.
go get github.com/casbin/ent-adapter
a, err := NewAdapter("mysql", "root:@tcp(127.0.0.1:3306)/casbin")
//a, err := NewAdapter("postgres", "user=postgres password=postgres host=127.0.0.1 port=5432 dbname=casbin")
if err != nil {
panic(err)
}
e, err := casbin.NewEnforcer("/path/to/model",a)
The database used in adapter(like casbin) should be created manually before NewAdapter calling.
This project is under Apache 2.0 License. See the LICENSE file for the full license text.