Documentation
¶
Index ¶
- type Adapter
- func (adapter Adapter) AddPolicies(sec string, ptype string, rules [][]string) error
- func (adapter Adapter) AddPolicy(sec string, ptype string, rule []string) error
- func (adapter Adapter) IsFiltered() bool
- func (adapter *Adapter) LoadFilteredPolicy(model model.Model, filterPtr interface{}) error
- func (adapter *Adapter) LoadPolicy(model model.Model) error
- func (adapter Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
- func (adapter Adapter) RemovePolicies(sec string, ptype string, rules [][]string) (err error)
- func (adapter Adapter) RemovePolicy(sec, ptype string, rule []string) error
- func (adapter Adapter) SavePolicy(model model.Model) error
- func (adapter Adapter) UpdateFilteredPolicies(sec, ptype string, newPolicies [][]string, fieldIndex int, ...) (oldPolicies [][]string, err error)
- func (adapter Adapter) UpdatePolicies(sec, ptype string, oldRules, newRules [][]string) (err error)
- func (adapter Adapter) UpdatePolicy(sec, ptype string, oldRule, newPolicy []string) error
- type Filter
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 defines the database adapter for Casbin. It can load policy lines from connected database or save policy lines.
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 NewAdapterWithContext ¶
func NewAdapterWithContext(ctx context.Context, db *sql.DB, driverName, tableName string) (*Adapter, error)
NewAdapterWithContext 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 (adapter 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 ¶
func (Adapter) RemovePolicy ¶
RemovePolicy remove policy rules from the storage.
func (Adapter) SavePolicy ¶
SavePolicy save policy rules to the storage.
func (Adapter) UpdateFilteredPolicies ¶
func (adapter 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.