Documentation ¶
Index ¶
- func ParamsMatch(fullNameKey1, key2 string) interface{}
- func ParamsMatchFunc(args ...interface{}) (interface{}, error)
- type Adapter
- func (a *Adapter) AddPolicy(sec string, ptype string, rule []string) 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) RemovePolicy(sec string, ptype string, rule []string) error
- func (a *Adapter) SavePolicy(model model.Model) error
- type CasBinInfo
- type CasBinModel
- func (c *CasBinModel) AddCasBin() (*casbin.Enforcer, bool)
- func (c *CasBinModel) CasBin() *casbin.Enforcer
- func (c *CasBinModel) ClearCasBin(v int, p ...string) (*casbin.Enforcer, bool)
- func (c *CasBinModel) GetCasBinList() (e *casbin.Enforcer, pathMaps []CasBinInfo)
- func (c *CasBinModel) UpdateCasBin() (*casbin.Enforcer, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParamsMatch ¶ added in v0.1.2
func ParamsMatch(fullNameKey1, key2 string) interface{}
ParamsMatch 自定义规则函数
func ParamsMatchFunc ¶ added in v0.1.2
func ParamsMatchFunc(args ...interface{}) (interface{}, error)
ParamsMatchFunc 自定义规则函数
Types ¶
type Adapter ¶
type Adapter struct { DriverName string // 数据库名,例如: Mysql,PostgreSQL LinkInfo string // 链接到数据库的信息,例如: "root:root@tcp(127.0.0.1:3306)/casbin" TableName string // 存储策略的表 DB gdb.DB // 操作数据库的ORM句柄 }
Adapter 用于策略存储的gdb适配器。
func NewAdapter ¶
NewAdapter is the constructor for Adapter.
func NewAdapterFromOptions ¶
NewAdapterFromOptions is the constructor for Adapter with existed connection
func (*Adapter) LoadPolicy ¶
LoadPolicy loads policy from database.
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.
func (*Adapter) RemovePolicy ¶
RemovePolicy removes a policy rule from the storage.
type CasBinInfo ¶ added in v0.1.2
type CasBinInfo struct { Path string `p:"path" json:"path"` // 被操作的资源(即: url路径),对应: obj Method string `p:"method" json:"method"` // 操作的方法,例如: GET、POST,对应: act }
CasBinInfo 请求参数
type CasBinModel ¶ added in v0.1.2
type CasBinModel struct { ID uint `json:"id"` PType string `json:"pType"` // policy缩写,对应: p AuthorityId string `json:"roleName"` // 操作者ID,对应: sub Path string `json:"path"` // 被操作的资源(即: url路径),对应: obj Method string `json:"method"` // 操作的方法,例如: GET、POST,对应: act BaseAdapter *Adapter ReqPolicies []CasBinInfo ModelPath string `json:"modelPath"` // rbac_model.conf 文件路径 }
ReqCasBin 请求参数模型,用于对数据库中policy文件,增、删、改、查。
策略文件 p = sub, obj, act
func (*CasBinModel) AddCasBin ¶ added in v0.1.2
func (c *CasBinModel) AddCasBin() (*casbin.Enforcer, bool)
AddCasBin 添加权限(添加策略规则)
func (*CasBinModel) CasBin ¶ added in v0.1.2
func (c *CasBinModel) CasBin() *casbin.Enforcer
持久化到数据库,引入自定义规则
func (*CasBinModel) ClearCasBin ¶ added in v0.1.2
func (c *CasBinModel) ClearCasBin(v int, p ...string) (*casbin.Enforcer, bool)
ClearCasBin 清除匹配的权限
从当前策略中删除授权规则,可以指定字段过滤器。底层调用了e.RemoveFilteredPolicy()
func (*CasBinModel) GetCasBinList ¶ added in v0.1.2
func (c *CasBinModel) GetCasBinList() (e *casbin.Enforcer, pathMaps []CasBinInfo)
GetCasBinList 获取权限列表
func (*CasBinModel) UpdateCasBin ¶ added in v0.1.2
func (c *CasBinModel) UpdateCasBin() (*casbin.Enforcer, error)
UpdateCasBin 更新casBin权限
Click to show internal directories.
Click to hide internal directories.