Cassandra Adapter is the Apache Cassandra DB adapter for Casbin. With this library, Casbin can load policy from Cassandra or save policy to it.
go get github.com/casbin/cassandra-adapter
package main
import (
"github.com/casbin/casbin"
"github.com/casbin/cassandra-adapter"
)
func main() {
// Initialize a Cassandra adapter and use it in a Casbin enforcer:
a := cassandraadapter.NewAdapter("127.0.0.1") // Your Cassandra hosts.
e := casbin.NewEnforcer("examples/rbac_model.conf", a)
// Load the policy from DB.
e.LoadPolicy()
// Check the permission.
e.Enforce("alice", "data1", "read")
// Modify the policy.
// e.AddPolicy(...)
// e.RemovePolicy(...)
// Save the policy back to DB.
e.SavePolicy()
}
This project is under Apache 2.0 License. See the LICENSE file for the full license text.