adapter

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Prefix = "/rbac"

Functions

This section is empty.

Types

type BatchFilter

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

type EtcdAdapter

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

EtcdAdapter represents the Gorm adapter for policy storage.

func NewEtcdAdapter

func NewEtcdAdapter(conn *clientv3.Client) (*EtcdAdapter, error)

NewEtcdAdapter is the constructor for Adapter.

func (*EtcdAdapter) AddPolicies

func (a *EtcdAdapter) AddPolicies(sec string, ptype string, rules [][]string) error

AddPolicies adds multiple policy rules to the storage.

func (*EtcdAdapter) AddPolicy

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

AddPolicy adds a policy rule to the storage.

func (*EtcdAdapter) IsFiltered

func (a *EtcdAdapter) IsFiltered() bool

IsFiltered returns true if the loaded policy has been filtered.

func (*EtcdAdapter) LoadFilteredPolicy

func (a *EtcdAdapter) LoadFilteredPolicy(model model.Model, filter interface{}) error

LoadFilteredPolicy loads only policy rules that match the filter.

func (*EtcdAdapter) LoadPolicy

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

LoadPolicy loads policy from database.

func (*EtcdAdapter) Preview

func (a *EtcdAdapter) Preview(rules *[][]string, model model.Model) error

Preview Pre-checking to avoid causing partial load success and partial failure deep

func (*EtcdAdapter) RemoveFilteredPolicy

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

RemoveFilteredPolicy removes policy rules that match the filter from the storage.

func (*EtcdAdapter) RemovePolicies

func (a *EtcdAdapter) RemovePolicies(sec string, ptype string, rules [][]string) error

RemovePolicies removes multiple policy rules from the storage.

func (*EtcdAdapter) RemovePolicy

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

RemovePolicy removes a policy rule from the storage.

func (*EtcdAdapter) SavePolicy

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

SavePolicy saves policy to database.

func (*EtcdAdapter) UpdateFilteredPolicies

func (a *EtcdAdapter) UpdateFilteredPolicies(sec string, ptype string, newPolicies [][]string, fieldIndex int, fieldValues ...string) ([][]string, error)

func (*EtcdAdapter) UpdatePolicies

func (a *EtcdAdapter) UpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) error

func (*EtcdAdapter) UpdatePolicy

func (a *EtcdAdapter) UpdatePolicy(sec string, ptype string, oldRule, newPolicy []string) error

UpdatePolicy updates a new policy rule to DB.

type Filter

type Filter struct {
	PType []string
	V0    []string
	V1    []string
	V2    []string
	V3    []string
	V4    []string
	V5    []string
}

type GormAdapter

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

GormAdapter represents the Gorm adapter for policy storage.

func NewGormAdapter

func NewGormAdapter(db *gorm.DB) (*GormAdapter, error)

NewGormAdapter is the constructor for Adapter.

func (*GormAdapter) AddPolicies

func (a *GormAdapter) AddPolicies(sec string, ptype string, rules [][]string) error

AddPolicies adds multiple policy rules to the storage.

func (*GormAdapter) AddPolicy

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

AddPolicy adds a policy rule to the storage.

func (*GormAdapter) IsFiltered

func (a *GormAdapter) IsFiltered() bool

IsFiltered returns true if the loaded policy has been filtered.

func (*GormAdapter) LoadFilteredPolicy

func (a *GormAdapter) LoadFilteredPolicy(model model.Model, filter interface{}) error

LoadFilteredPolicy loads only policy rules that match the filter.

func (*GormAdapter) LoadPolicy

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

LoadPolicy loads policy from database.

func (*GormAdapter) Preview

func (a *GormAdapter) Preview(rules *[]Rule, model model.Model) error

Preview Pre-checking to avoid causing partial load success and partial failure deep

func (*GormAdapter) RemoveFilteredPolicy

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

RemoveFilteredPolicy removes policy rules that match the filter from the storage.

func (*GormAdapter) RemovePolicies

func (a *GormAdapter) RemovePolicies(sec string, ptype string, rules [][]string) error

RemovePolicies removes multiple policy rules from the storage.

func (*GormAdapter) RemovePolicy

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

RemovePolicy removes a policy rule from the storage.

func (*GormAdapter) SavePolicy

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

SavePolicy saves policy to database.

func (*GormAdapter) Transaction

func (a *GormAdapter) Transaction(e casbin.IEnforcer, fc func(casbin.IEnforcer) error, opts ...*sql.TxOptions) (err error)

Transaction perform a set of operations within a transaction

func (*GormAdapter) UpdateFilteredPolicies

func (a *GormAdapter) UpdateFilteredPolicies(sec string, ptype string, newPolicies [][]string, fieldIndex int, fieldValues ...string) ([][]string, error)

func (*GormAdapter) UpdatePolicies

func (a *GormAdapter) UpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) error

func (*GormAdapter) UpdatePolicy

func (a *GormAdapter) UpdatePolicy(sec string, ptype string, oldRule, newPolicy []string) error

UpdatePolicy updates a new policy rule to DB.

type Rule

type Rule struct {
	ID    uint   `gorm:"column:id;primaryKey;autoIncrement"`
	PType string `gorm:"column:ptype;size:100"`
	V0    string `gorm:"column:v0;size:100"`
	V1    string `gorm:"column:v1;size:100"`
	V2    string `gorm:"column:v2;size:100"`
	V3    string `gorm:"column:v3;size:100"`
	V4    string `gorm:"column:v4;size:100"`
	V5    string `gorm:"column:v5;size:100"`
}

func (Rule) TableName

func (Rule) TableName() string

Jump to

Keyboard shortcuts

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