gdbadapter

package
v0.0.0-...-22bb83e Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

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 represents the gdb adapter for policy storage. Adapter 代表用于策略存储的gdb适配器。

func NewAdapter

func NewAdapter(driverName string, dataSourceName string) (*Adapter, error)

NewAdapter是Adapter的构造函数。 dbSpecified是可选的bool参数。 默认值为false。 如果dbSpecified == true,则需要确保dataSourceName中的数据库存在。 如果dbSpecified == false,则适配器将自动创建一个名为“ casbin”的数据库。

func NewAdapterByConfig

func NewAdapterByConfig() (a *Adapter, err error)

NewAdapterByConfig

func NewAdapterByDB

func NewAdapterByDB(db gdb.DB, tableName string) (*Adapter, error)

NewAdapterByDB is the constructor for Adapter.Need to pass in gdb.DB NewAdapterByDB 是Adapter的构造函数,需要传入gdb.DB

func NewAdapterFromOptions

func NewAdapterFromOptions(adapter *Adapter) (*Adapter, error)

NewAdapterFromOptions is the constructor for Adapter with existed connection NewAdapterFromOptions 适配器的构造函数是否具有已存在的连接

func (*Adapter) AddPolicies

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

func (*Adapter) AddPolicy

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

AddPolicy adds a policy rule to the storage. AddPolicy 向存储添加策略规则。

func (*Adapter) LoadPolicy

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

LoadPolicy loads policy from database. LoadPolicy 从数据库加载策略。

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. RemoveFilteredPolicy 从存储中删除与筛选器匹配的策略规则。

func (*Adapter) RemovePolicies

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

func (*Adapter) RemovePolicy

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

RemovePolicy removes a policy rule from the storage. RemovePolicy 从存储中删除策略规则。

func (*Adapter) SavePolicy

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

SavePolicy saves policy to database. SavePolicy 将策略保存到数据库。

type CasbinRule

type CasbinRule struct {
	PType string `orm:"ptype" json:"ptype"`
	V0    string `orm:"v0" json:"v0"`
	V1    string `orm:"v1" json:"v1"`
	V2    string `orm:"v2" json:"v2"`
	V3    string `orm:"v3" json:"v3"`
	V4    string `orm:"v4" json:"v4"`
	V5    string `orm:"v5" json:"v5"`
}

func (*CasbinRule) TableName

func (c *CasbinRule) TableName() string

Jump to

Keyboard shortcuts

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