Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

HOOQTV/dynacasbin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DynamoDB Adapter

Migrated to https://github.coupang.net/coupang/couplay-dynacasbin

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

Releases

No releases published

Packages

No packages published

Languages