• Stars
    star
    149
  • Rank 248,619 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RethinkDB adapter for Casbin https://github.com/casbin/casbin

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.

More Repositories

1

flutter-gun

This library is a port of GunDB js for the Dart and Flutter. P2P encrypted Communication between multiple users. GUN is an ecosystem of tools that let you build community run and encrypted applications - like an Open Source Firebase or a Decentralized Dropbox.
Dart
27
star
2

react-native-shopping-app

React Native Shopping app
JavaScript
12
star
3

appointment_app

It is a theme for an appointment app in ionic
TypeScript
2
star
4

question_answer_website

Question Answer Website in Asp.net MVC with API and front end with React.js
JavaScript
2
star
5

geofencing-app-in-react-native

JavaScript
2
star
6

Music-Search-Engine-Android-App

It is a music search engine android app using a default api with custom Exo player. With Download option, play song and share with friend
Java
2
star
7

reactjs-firebase-admin-panel

JavaScript
2
star
8

Todo-Angular4-NodeJs-App

This is a Todo app with Angular 4 as front end and NodeJs as backend
JavaScript
2
star
9

memory-console-game

It is a CLI memory game of guessing the number
C
1
star
10

send-email-mailgun

This is a example project for sending emails using mailgun
JavaScript
1
star
11

firebase-android-quiz-app

It is android app which is uses the firebase as server and database. It is fun quiz app
CSS
1
star
12

android-auth-scheduler

Java
1
star
13

CandyRecord

Java
1
star
14

Movies-Info-Asp.Net-React-Js

It is a Imdb like website with Add and Update Movie, Producers, Cast Details developed with Asp.net and React Js.
JavaScript
1
star
15

New-Tab

It is a chrome extension
JavaScript
1
star
16

weather-app-in-react-native

JavaScript
1
star
17

Reactjs-pgsql-nextjs-blog

It is the Simple blogging website with using pgsql, nextjs, and node js
JavaScript
1
star
18

test-react-sort-native

At first built the backend folder and then use install app in the emulator.
JavaScript
1
star
19

gatsbyjs-blog-markdown

It is a blog build using gatsbyjs and blog post store in the markdown .md files
CSS
1
star