Documentation ¶
Index ¶
- type Adapter
- func (p *Adapter) AddPolicies(sec string, ptype string, rules [][]string) error
- func (p *Adapter) AddPolicy(sec string, ptype string, rule []string) error
- func (p *Adapter) IsFiltered() bool
- func (p *Adapter) LoadFilteredPolicy(model model.Model, filterPtr interface{}) error
- func (p *Adapter) LoadPolicy(model model.Model) error
- func (p *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
- func (p *Adapter) RemovePolicies(sec string, ptype string, rules [][]string) (err error)
- func (p *Adapter) RemovePolicy(sec string, ptype string, rule []string) error
- func (p *Adapter) SavePolicy(model model.Model) error
- func (p *Adapter) UpdateFilteredPolicies(sec, ptype string, newPolicies [][]string, fieldIndex int, ...) (oldPolicies [][]string, err error)
- func (p *Adapter) UpdatePolicies(sec, ptype string, oldRules, newRules [][]string) (err error)
- func (p *Adapter) UpdatePolicy(sec, ptype string, oldRule, newPolicy []string) error
- type CasbinRule
- type Filter
- type IncludeExcludeFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter define the sqlx adapter for Casbin. It can load policy lines or save policy lines from sqlx connected database.
func NewAdapter ¶
NewAdapter the constructor for Adapter. db should connected to database and controlled by user. If tableName == "", the Adapter will automatically create a table named "casbin_rule".
func NewAdapterContext ¶
func NewAdapterContext(ctx context.Context, db *sqlx.DB, schemaName, tableName string) (*Adapter, error)
NewAdapterContext the constructor for Adapter. db should connected to database and controlled by user. If tableName == "", the Adapter will automatically create a table named "casbin_rule".
func (*Adapter) AddPolicies ¶
AddPolicies add multiple policy rules to the storage.
func (*Adapter) IsFiltered ¶
IsFiltered returns true if the loaded policy rules has been filtered.
func (*Adapter) LoadFilteredPolicy ¶
LoadFilteredPolicy load policy rules that match the filter. filterPtr must be a pointer.
func (*Adapter) LoadPolicy ¶
LoadPolicy load all policy rules from the storage.
func (*Adapter) RemoveFilteredPolicy ¶
func (p *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
RemoveFilteredPolicy remove policy rules that match the filter from the storage.
func (*Adapter) RemovePolicies ¶
RemovePolicies remove policy rules.
func (*Adapter) RemovePolicy ¶
RemovePolicy remove policy rules from the storage.
func (*Adapter) SavePolicy ¶
SavePolicy save policy rules to the storage.
func (*Adapter) UpdateFilteredPolicies ¶
func (p *Adapter) UpdateFilteredPolicies(sec, ptype string, newPolicies [][]string, fieldIndex int, fieldValues ...string) (oldPolicies [][]string, err error)
UpdateFilteredPolicies deletes old rules and adds new rules.
func (*Adapter) UpdatePolicies ¶
UpdatePolicies updates policy rules to storage.
type CasbinRule ¶
type CasbinRule struct { PType string `db:"p_type"` V0 string `db:"v0"` V1 string `db:"v1"` V2 string `db:"v2"` V3 string `db:"v3"` V4 string `db:"v4"` V5 string `db:"v5"` }
CasbinRule defines the casbin rule model. It used for save or load policy lines from sqlx connected database.
type Filter ¶
type Filter struct { PType []string V0 []string V1 []string V2 []string V3 []string V4 []string V5 []string }
Filter defines the filtering rules for a FilteredAdapter's policy. Empty values are ignored, but all others must match the filter.
type IncludeExcludeFilter ¶
type IncludeExcludeFilter struct { PTypeInclude []string PTypeExclude []string V0Include []string V0Exclude []string V1Include []string V1Exclude []string V2Include []string V2Exclude []string V3Include []string V3Exclude []string V4Include []string V4Exclude []string V5Include []string V5Exclude []string }
V0IncludeV2ExcludeFilter defines the filtering include and exclude rules for a FilteredAdapter's policy.