Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

README.md

consul_adapter

casbin KV store adapter for casbin

Usage

package main

import (
	"github.com/casbin/casbin"
	"github.com/ankitm123/consul-adapter"
)

func main() {
	//This is how it should ideally work:
    // Initialize a consul adapter and use it in a Casbin enforcer:
    
	a := consuladapter.NewDBAdapter()
	e := casbin.NewEnforcer("examples/rbac_model.conf", a)
	
	// Load the policy from consul KV store.
	e.LoadPolicy()
	
	// Check the permission.
	e.Enforce("alice", "data1", "read")
	
	// Modify the policy.
	// e.AddPolicy(...)
	// e.RemovePolicy(...)
	
	// Save the policy back to consul KV store.
	e.SavePolicy()

    //This is how it works now. We have a csv file which is read by the adpater using savepolicy
    e := casbin.NewEnforcer("./rbac/rbac_model.conf", "./rbac/rbac_policy.csv")
	//a := ConsulAdapter.NewDBAdapter()
	a.SavePolicy(e.GetModel())
	//a.LoadPolicy(e.GetModel())
	e = casbin.NewEnforcer("./rbac/rbac_model.conf", a)

	e.LoadPolicy()
}

About

casbin KV store adapter for casbin

Resources

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.