Documentation ¶
Index ¶
- Constants
- Variables
- func CasbinAppObjKey(appName, appEnv string) string
- func CasbinGroupKey(gType string, name string) (key string)
- func InitCasbin(adapter persist.Adapter) (err error)
- func PolicyAuthList() (list []db.CasbinPolicyAuth, err error)
- func PolicyGroupList() (list []db.CasbinPolicyGroup, err error)
- type APIItem
- type APIListItem
- type Action
- type AppPermissionItem
- type AppPermissionList
- type CasbinAdapter
- func (a *CasbinAdapter) AddPolicy(sec string, ptype string, rule []string) error
- func (a *CasbinAdapter) LoadPolicy(model casbinModel.Model) (err error)
- func (a *CasbinAdapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
- func (a *CasbinAdapter) RemovePolicy(sec string, ptype string, rule []string) error
- func (a *CasbinAdapter) SavePolicy(model casbinModel.Model) error
- type CasbinService
- func (c *CasbinService) APIList(sub string) (list []APIItem)
- func (c *CasbinService) AppPermissionList() AppPermissionList
- func (c *CasbinService) CheckAPIValid(path, method string) bool
- func (c *CasbinService) CheckAppPermissionKeyValid(key string) bool
- func (c *CasbinService) CheckPermission(sub, object, action string, policyType db.CasbinPolicyType) (ok bool, err error)
- func (c *CasbinService) CheckUserPermission(u *db.User, object string, action string, policyType db.CasbinPolicyType) (ok bool, err error)
- func (c *CasbinService) FullAPIList() (list []APIItem)
- func (c *CasbinService) GetAPIItem(path, method string) (apiItem *APIItem)
- func (c *CasbinService) GetMenu(sub string) (menu view.MenuTree, err error)
- func (c *CasbinService) LoadPolicy() error
- func (c *CasbinService) UserMenu(u *db.User) (menu view.MenuTree, err error)
- type MenuTreeItem
- type Object
- type PermissionTree
- type PolicyType
Constants ¶
View Source
const ( SubSwitchOn = 1 << 2 // single 000, group 100 ObjSwitchOn = 1 << 1 // single 000, group 010 ActSwitchOn = 1 // single 000, group 001 )
View Source
const ( GroupTypeUser = "user" GroupTypeApp = "app" GroupTypeURL = "url" )
Variables ¶
View Source
var ( Casbin *CasbinService ActionReadMenu Action = "menu:read" )
Functions ¶
func CasbinAppObjKey ¶
func CasbinGroupKey ¶
func PolicyAuthList ¶
func PolicyAuthList() (list []db.CasbinPolicyAuth, err error)
func PolicyGroupList ¶
func PolicyGroupList() (list []db.CasbinPolicyGroup, err error)
Types ¶
type APIListItem ¶
type AppPermissionItem ¶
type AppPermissionList ¶
type AppPermissionList []AppPermissionItem
type CasbinAdapter ¶
type CasbinAdapter struct{}
CasbinAdapter ..
func (*CasbinAdapter) AddPolicy ¶
func (a *CasbinAdapter) AddPolicy(sec string, ptype string, rule []string) error
AddPolicy adds a policy rule to the storage. This is part of the Auto-Save feature.
func (*CasbinAdapter) LoadPolicy ¶
func (a *CasbinAdapter) LoadPolicy(model casbinModel.Model) (err error)
LoadPolicy loads all policy rules from the storage.
func (*CasbinAdapter) RemoveFilteredPolicy ¶
func (a *CasbinAdapter) 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 (*CasbinAdapter) RemovePolicy ¶
func (a *CasbinAdapter) RemovePolicy(sec string, ptype string, rule []string) error
RemovePolicy removes a policy rule from the storage. This is part of the Auto-Save feature.
func (*CasbinAdapter) SavePolicy ¶
func (a *CasbinAdapter) SavePolicy(model casbinModel.Model) error
SavePolicy saves all policy rules to the storage.
type CasbinService ¶
type CasbinService struct { *casbin.SyncedEnforcer Resource struct { Permission PermissionTree `yaml:"permission" json:"permission"` App AppPermissionList `yaml:"app" json:"app"` } // contains filtered or unexported fields }
func (*CasbinService) APIList ¶
func (c *CasbinService) APIList(sub string) (list []APIItem)
func (*CasbinService) AppPermissionList ¶
func (c *CasbinService) AppPermissionList() AppPermissionList
func (*CasbinService) CheckAPIValid ¶
func (c *CasbinService) CheckAPIValid(path, method string) bool
func (*CasbinService) CheckAppPermissionKeyValid ¶
func (c *CasbinService) CheckAppPermissionKeyValid(key string) bool
func (*CasbinService) CheckPermission ¶
func (c *CasbinService) CheckPermission(sub, object, action string, policyType db.CasbinPolicyType) (ok bool, err error)
func (*CasbinService) CheckUserPermission ¶
func (c *CasbinService) CheckUserPermission(u *db.User, object string, action string, policyType db.CasbinPolicyType) (ok bool, err error)
func (*CasbinService) FullAPIList ¶
func (c *CasbinService) FullAPIList() (list []APIItem)
获取所有的API权限列表(去重结果)
func (*CasbinService) GetAPIItem ¶
func (c *CasbinService) GetAPIItem(path, method string) (apiItem *APIItem)
func (*CasbinService) GetMenu ¶
func (c *CasbinService) GetMenu(sub string) (menu view.MenuTree, err error)
func (*CasbinService) LoadPolicy ¶ added in v0.4.0
func (c *CasbinService) LoadPolicy() error
type MenuTreeItem ¶
type MenuTreeItem struct { Name string `yaml:"name" json:"name"` Path string `yaml:"path" json:"path"` Icon string `yaml:"icon" json:"icon"` API []APIItem `yaml:"api" json:"api"` Children PermissionTree `yaml:"children" json:"children"` }
type Object ¶
type Object struct { Resource string Type db.CasbinPolicyType }
type PermissionTree ¶
type PermissionTree []MenuTreeItem
type PolicyType ¶
Click to show internal directories.
Click to hide internal directories.