Skip to content
DynamoDB adapter for Casbin
Branch: master
Clone or download
Latest commit d46a138 Nov 22, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Initial commit 🚀 Nov 13, 2017
.gitignore Gardening Nov 22, 2017
Gopkg.lock Initial commit 🚀 Nov 13, 2017
Gopkg.toml Initial commit 🚀 Nov 13, 2017
README.md Gardening Nov 22, 2017
adapter.go Gardening Nov 22, 2017
adapter_test.go Gardening Nov 22, 2017
debug.test Gardening Nov 22, 2017

README.md

DynamoDB Adapter

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

Installation

go get github.com/hooqtv/dynacasbin

Simple Example

package main

import (
	"github.com/casbin/casbin"
	"github.com/hooqtv/dynacasbin"
	"github.com/aws/aws-sdk-go/aws"
)

func main() {
	// Initialize a DynamoDB adapter and use it in a Casbin enforcer:
	config := &aws.Config{} // Your AWS configuration
	ds := "casbin-rules"
	a := dynacasbin.NewAdapter(config, ds) // Your aws configuration and data source.
	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

You can’t perform that action at this time.