Cassandra DB adapter for Casbin

Clone this repo:

Branches

  1. 01749d9 Add empty auto-save functions. by Yang Luo · 9 years ago master
  2. 348b9dd Add comments. by Yang Luo · 9 years ago
  3. 2bbda5d Comment on the trick in test. by Yang Luo · 9 years ago
  4. 0018b39 Merge pull request #1 from ankitm123/master by Yang Luo · 9 years ago
  5. a33da1d Fix wrong package name in Readme by ankit · 9 years ago

Cassandra Adapter Build Status Coverage Status Godoc

Cassandra Adapter is the Apache Cassandra DB adapter for Casbin. With this library, Casbin can load policy from Cassandra or save policy to it.

Installation

go get github.com/casbin/cassandra-adapter

Simple Example

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()
}

Getting Help

License

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