MongoDB Adapter
MongoDB Adapter is the Mongo DB adapter for Casbin. With this library, Casbin can load policy from MongoDB or save policy to it.
Installation
go get github.com/casbin/mongodb-adapter
Simple Example
package main
import (
"github.com/casbin/casbin"
"github.com/casbin/mongodb-adapter"
)
func main() {
a := mongodbadapter.NewAdapter("127.0.0.1:27017")
e := casbin.NewEnforcer("examples/rbac_model.conf", a)
e.LoadPolicy()
e.Enforce("alice", "data1", "read")
e.SavePolicy()
}
Filtered Policies
import "github.com/globalsign/mgo/bson"
filter := &bson.M{"v0": "alice"}
e.LoadFilteredPolicy(filter)
Getting Help
License
This project is under Apache 2.0 License. See the LICENSE file for the full license text.