# README
Casbin SegmentQ Adapter
The SegmentQ DB adapter for Casbin. You can use this library to load and save policies to an SegmentQ DB.
Installation
go get github.com/segmentq/casbin-segmentq-adapter
Simple Example
package main
import (
"context"
adapter "github.com/segmentq/casbin-segmentq-adapter"
"github.com/casbin/casbin/v2"
"github.com/segmentq/db"
)
func main() {
// Initialize some instance of SegmentQ DB
segmentq, _ := db.NewDB(context.Background())
// Initialize a SegmentQ adapter and use it in a Casbin enforcer:
// The adapter will use a SegmentQ DB Index named "casbin_rule".
// If it doesn't exist, the adapter will create it automatically.
a, _ := adapter.NewAdapter(segmentq)
// Create the enforcer
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()
}
# Constants
No description provided by the author
# Type aliases
No description provided by the author