Skip to content
RethinkDB adapter for Casbin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

RethinkDB Adapter

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


go get

Simple Example

package main

import (
    	r ""

func getConnect() r.QueryExecutor {
	url := os.Getenv("RETHINKDB_URL") //Get the Rethinkdb url from system env

	if url == "" {
		url = "localhost:28015"

	session, _ := r.Connect(r.ConnectOpts{
		Address: url,

	return session

func main() {
	// Initialize a RethinkDB get session, add it to adapter and use it in a Casbin enforcer:
	// The adapter will use the database named "casbin".
	// If it doesn't exist, the adapter will create it automatically. (default names - Database: casbin, Table: rethinkdbpolicy)
  	session := getConnect()
	a := rethinkadapter.NewAdapter(session) // Your RethinkDB Session. 
	//Or you can do this
	a := rethinkadapter.NewAdapter(session, "database_name", "table_name") // Your RethinkDB Session.
	e := casbin.NewEnforcer("examples/casbinmodel.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 MIT License. See the LICENSE file for the full license text.

You can’t perform that action at this time.