adapter

package
v0.0.0-...-bddae19 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: Unlicense Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeCasbin

func InitializeCasbin(db *sqlx.DB) error

func Policy

func Policy() *casbin.SyncedEnforcer

Types

type CasbinRule

type CasbinRule struct {
	ID    string
	PType string
	V0    string
	V1    string
	V2    string
	V3    string
	V4    string
	V5    string
}

type IAdapter

type IAdapter interface {
	// LoadPolicy loads all policy rules from the storage.
	LoadPolicy(model model.Model) error
	// SavePolicy saves all policy rules to the storage.
	SavePolicy(model model.Model) error

	// AddPolicy adds a policy rule to the storage.
	// This is part of the Auto-Save feature.
	AddPolicy(sec string, ptype string, rule []string) error
	// RemovePolicy removes a policy rule from the storage.
	// This is part of the Auto-Save feature.
	RemovePolicy(sec string, ptype string, rule []string) error
	// RemoveFilteredPolicy removes policy rules that match the filter from the storage.
	// This is part of the Auto-Save feature.
	RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
}

type PGCasbinAdapter

type PGCasbinAdapter struct {
	// contains filtered or unexported fields
}

func NewCasbinAdapter

func NewCasbinAdapter(db *sqlx.DB, schema string) *PGCasbinAdapter

func (*PGCasbinAdapter) AddPolicy

func (a *PGCasbinAdapter) AddPolicy(sec string, ptype string, rule []string) error

func (*PGCasbinAdapter) LoadPolicy

func (a *PGCasbinAdapter) LoadPolicy(model model.Model) error

func (*PGCasbinAdapter) RemoveFilteredPolicy

func (a *PGCasbinAdapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error

func (*PGCasbinAdapter) RemovePolicy

func (a *PGCasbinAdapter) RemovePolicy(sec string, ptype string, rule []string) error

func (*PGCasbinAdapter) SavePolicy

func (a *PGCasbinAdapter) SavePolicy(model model.Model) error

Jump to

Keyboard shortcuts

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