Categorygithub.com/segmentq/casbin-segmentq-adapter
modulepackage
0.1.0
Repository: https://github.com/segmentq/casbin-segmentq-adapter.git
Documentation: pkg.go.dev

# README

Casbin SegmentQ Adapter

Go Report Card Go Reference Build Reliability Rating Quality Gate Status Coverage

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()
}

# Functions

No description provided by the author
No description provided by the author

# Constants

No description provided by the author

# Structs

No description provided by the author

# Type aliases

No description provided by the author