Rethinkdb Adapter

RethinkDB adapter for Casbin https://github.com/casbin/casbin
Alternatives To Rethinkdb Adapter
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Gorm Adapter613715 days ago53July 03, 2022apache-2.0Go
GORM adapter for Casbin, see extended version of GORM Adapter Ex at: https://github.com/casbin/gorm-adapter-ex
Xorm Adapter37111a month ago11January 20, 2022apache-2.0Go
Xorm adapter for Casbin
Casbin Server276243 days ago6December 21, 20221apache-2.0Go
Casbin as a Service (CaaS)
Mongodb Adapter24252 months ago12September 16, 2022apache-2.0Go
MongoDB adapter for Casbin
Protobuf Adapter186
6 years agoMay 24, 2021apache-2.0Go
Google Protocol Buffers adapter for Casbin
Redis Adapter182
8 months ago2January 20, 2022apache-2.0Go
Redis adapter for Casbin
Rethinkdb Adapter148
a year agoMay 22, 20211mitGo
RethinkDB adapter for Casbin https://github.com/casbin/casbin
Dynacasbin143
2 years agoGo
DynamoDB adapter for Casbin
Typeorm Adapter632517 days ago14August 04, 20221apache-2.0TypeScript
TypeORM adapter for Casbin
Sqlalchemy Adapter63
4 months ago12September 09, 2021apache-2.0Python
SQLAlchemy Adapter for PyCasbin
Alternatives To Rethinkdb Adapter
Select To Compare


Alternative Project Comparisons
Readme

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.

Installation

go get github.com/adityapandey9/rethinkdb-adapter

Simple Example

package main

import (
    	"os"
    	r "gopkg.in/gorethink/gorethink.v3"
	"github.com/casbin/casbin"
	"github.com/adityapandey9/rethinkdb-adapter"
)

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.NewAdapterDB(session, "database_name", "table_name") // Your RethinkDB Session.
	
	e := casbin.NewEnforcer("examples/casbinmodel.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 MIT License. See the LICENSE file for the full license text.

Popular Casbin Projects
Popular Adapter Projects
Popular Security Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Go
Golang
Adapter
Rethinkdb
Casbin