Awesome Open Source
Awesome Open Source

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.


go get

Simple Example

package main

import (

func main() {
	// Initialize a Redis adapter and use it in a Casbin enforcer:
	a := redisadapter.NewAdapter("tcp", "") // Your Redis network and address.
	// Use the following if Redis has password like "123"
    //a := redisadapter.NewAdapterWithPassword("tcp", "", "123")
	e := casbin.NewEnforcer("examples/rbac_model.conf", a)

	// Load the policy from DB.

	// Check the permission.
	e.Enforce("alice", "data1", "read")

	// Modify the policy.
	// e.AddPolicy(...)
	// e.RemovePolicy(...)

	// Save the policy back to DB.

Getting Help


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

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
go (14,962
redis (945
authorization (214
auth (96
access-control (65
adapter (64
casbin (41