Skip to content
Redis adapter for Casbin
Branch: master
Clone or download
hsluoyz Merge pull request #3 from innius/master
don't return an error if redis key does not exist
Latest commit b36d844 Jan 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Add the adapter code. Sep 23, 2017
.gitignore Ignore IDEA files. Sep 23, 2017
.travis.yml Add Travis CI and coverage. Sep 23, 2017
LICENSE Initial commit Sep 22, 2017
README.md Add Travis CI and coverage. Sep 23, 2017
adapter.go don't return an error if redis key does not exist Dec 21, 2018
adapter_test.go don't return an error if redis key does not exist Dec 21, 2018

README.md

Redis Adapter Build Status Coverage Status Godoc

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

Installation

go get github.com/casbin/redis-adapter

Simple Example

package main

import (
	"github.com/casbin/casbin"
	"github.com/casbin/redis-adapter"
)

func main() {
	// Initialize a Redis adapter and use it in a Casbin enforcer:
	a := redisadapter.NewAdapter("tcp", "127.0.0.1:6379") // Your Redis network and address. 
	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.

You can’t perform that action at this time.