Documentation ¶
Index ¶
- Constants
- Variables
- func CasbinRuleToStringArray(rule *CasbinRule) []string
- type Adapter
- func (a *Adapter) AddPolicies(sec string, ptype string, rules [][]string) error
- func (a *Adapter) AddPolicy(sec string, ptype string, rule []string) error
- func (a *Adapter) IsFiltered() bool
- func (a *Adapter) LoadFilteredPolicy(model model.Model, filter interface{}) error
- func (a *Adapter) LoadPolicy(model model.Model) error
- func (a *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
- func (a *Adapter) RemovePolicies(sec string, ptype string, rules [][]string) error
- func (a *Adapter) RemovePolicy(sec string, ptype string, rule []string) error
- func (a *Adapter) SavePolicy(model model.Model) error
- func (a *Adapter) UpdateFilteredPolicies(sec string, ptype string, newPolicies [][]string, fieldIndex int, ...) ([][]string, error)
- func (a *Adapter) UpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) error
- func (a *Adapter) UpdatePolicy(sec string, ptype string, oldRule, newPolicy []string) error
- func (a *Adapter) WithTx(fn func(tx bun.Tx) error) error
- type CasbinRule
- type Filter
- type Option
Constants ¶
const ( DefaultSchemaName = "public" DefaultTableName = "casbin_rule" )
Variables ¶
var (
ErrUnknownDriver = errors.New("unknown driver")
)
Functions ¶
func CasbinRuleToStringArray ¶
func CasbinRuleToStringArray(rule *CasbinRule) []string
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
func NewAdapter ¶
NewAdapter returns an adapter by driver name and data source string.
func NewAdapterWithClient ¶
NewAdapterWithClient create an adapter with client passed in. This method does not ensure the existence of database, user should create database manually.
func (*Adapter) AddPolicies ¶
AddPolicies adds policy rules to the storage. This is part of the Auto-Save feature.
func (*Adapter) AddPolicy ¶
AddPolicy adds a policy rule to the storage. This is part of the Auto-Save feature.
func (*Adapter) IsFiltered ¶
IsFiltered returns true if the loaded policy has been filtered.
func (*Adapter) LoadFilteredPolicy ¶
LoadFilteredPolicy loads only policy rules that match the filter. Filter parameter here is a Filter structure
func (*Adapter) LoadPolicy ¶
LoadPolicy loads all policy rules from the storage.
func (*Adapter) RemoveFilteredPolicy ¶
func (a *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
RemoveFilteredPolicy removes policy rules that match the filter from the storage. This is part of the Auto-Save feature.
func (*Adapter) RemovePolicies ¶
RemovePolicies removes policy rules from the storage. This is part of the Auto-Save feature.
func (*Adapter) RemovePolicy ¶
RemovePolicy removes a policy rule from the storage. This is part of the Auto-Save feature.
func (*Adapter) SavePolicy ¶
SavePolicy saves all policy rules to the storage.
func (*Adapter) UpdateFilteredPolicies ¶
func (a *Adapter) UpdateFilteredPolicies(sec string, ptype string, newPolicies [][]string, fieldIndex int, fieldValues ...string) ([][]string, error)
UpdateFilteredPolicies deletes old rules and adds new rules.
func (*Adapter) UpdatePolicies ¶
UpdatePolicies updates some policy rules to storage, like db, redis.
func (*Adapter) UpdatePolicy ¶
UpdatePolicy updates a policy rule from storage. This is part of the Auto-Save feature.
type CasbinRule ¶
type CasbinRule struct { Id int64 `bun:"id,pk,autoincrement"` Ptype string `bun:",nullzero,notnull"` V0 string `bun:",nullzero,notnull"` V1 string `bun:",nullzero,notnull"` V2 string `bun:",nullzero,notnull"` V3 string `bun:",nullzero,notnull"` V4 string `bun:",nullzero,notnull"` V5 string `bun:",nullzero,notnull"` V6 string `bun:",nullzero,notnull"` V7 string `bun:",nullzero,notnull"` }