boltadapter

package module
v0.0.0-...-678577e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2022 License: Apache-2.0 Imports: 9 Imported by: 1

README

Casbin BoltDB Adapter (Experimental)

I have marked this as experimental because I haven't put an awful amount of time into it. It needs more use to confirm its suitable for others needs.

speza

A simple Casbin BoltDB Adapter (see https://casbin.org/docs/en/adapters). This flavour supports the auto-save functionality.

Right now it supports the autosave functionality, and I've worked in some restricted filtered adapter functionality - difficult with a simple k/v store like Bolt.

Individual policy lines get saved into the specified BoltDB bucket which is keyed using a :: delimited value of the role. The value content is a JSON representation of the policy rule.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdapter

func NewAdapter(db *bolt.DB, bucket string) (*adapter, error)

NewAdapter creates a new adapter. It assumes that the Bolt DB is already open. A bucket name is required and represents the Bolt bucket to save the data into. like to save to. The builtinPolicy is a string representation of a Casbin csv policy definition. If left builtinPolicy will not be used.

Types

type CasbinRule

type CasbinRule struct {
	Key   string `json:"key"`
	PType string `json:"p_type"`
	V0    string `json:"v0"`
	V1    string `json:"v1"`
	V2    string `json:"v2"`
	V3    string `json:"v3"`
	V4    string `json:"v4"`
	V5    string `json:"v5"`
}

CasbinRule represents a Casbin rule line.

func (*CasbinRule) Rule

func (cr *CasbinRule) Rule() []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL