Documentation ¶
Index ¶
- Constants
- Variables
- func InitDefaultRBAC(db *gorm.DB)
- type CheckPermissionBody
- type ConfigRBAC
- type RBACManager
- func (x *RBACManager) AddPermission(permissions []*kk_rbac_models.Permission) error
- func (x *RBACManager) AddRole(roles []*kk_rbac_models.Role) error
- func (x *RBACManager) AddUser(users []*kk_rbac_models.User) error
- func (x *RBACManager) CheckPermission(checkPermissionBody CheckPermissionBody) error
- func (x *RBACManager) DeletePermission(apiIds []string) error
- func (x *RBACManager) DeleteRole(roleNames []string) error
- func (x *RBACManager) DeleteUser(userIds []uint64) error
- func (x *RBACManager) GetRoleApiIdsCache() map[string][]string
- func (x *RBACManager) GetUserRoleIdsCache() map[uint64][]string
- func (x *RBACManager) PermissionList() (permissions []*kk_rbac_models.Permission, err error)
- func (x *RBACManager) RefreshCache() error
- func (x *RBACManager) RoleList(roleNames []string) (roles []*kk_rbac_models.Role, err error)
- func (x *RBACManager) UpdatePermission(permissions []*kk_rbac_models.Permission) error
- func (x *RBACManager) UpdateRole(roles []*kk_rbac_models.Role) error
- func (x *RBACManager) UpdateUser(users []*kk_rbac_models.User) error
- func (x *RBACManager) UserList() (users []*kk_rbac_models.User, err error)
Constants ¶
View Source
const KKRBACAdmin = "KKRBACAdmin"
KKRBACAdmin is the default admin role name has all permissions
Variables ¶
View Source
var (
ErrRoleNotExist = fmt.Errorf("role not exist")
)
Functions ¶
func InitDefaultRBAC ¶
InitDefaultRBAC init RBAC put kk_rbac/kk_rbac_api/kk_rbac_api/api.go api to DB load data to catch from DB now you can use the global variable RBAC
Types ¶
type CheckPermissionBody ¶
type ConfigRBAC ¶
func (*ConfigRBAC) Close ¶
func (x *ConfigRBAC) Close()
func (*ConfigRBAC) Init ¶
func (x *ConfigRBAC) Init()
type RBACManager ¶
type RBACManager struct {
// contains filtered or unexported fields
}
RBACManager RBAC
var RBAC *RBACManager
RBAC should be initialized by InitDefaultRBAC or NewRBAC
func (*RBACManager) AddPermission ¶
func (x *RBACManager) AddPermission(permissions []*kk_rbac_models.Permission) error
func (*RBACManager) AddRole ¶
func (x *RBACManager) AddRole(roles []*kk_rbac_models.Role) error
AddRole add roles do not forget to call RefreshCache()
func (*RBACManager) AddUser ¶
func (x *RBACManager) AddUser(users []*kk_rbac_models.User) error
AddUser add user-role relation do not forget to call RefreshCache()
func (*RBACManager) CheckPermission ¶
func (x *RBACManager) CheckPermission(checkPermissionBody CheckPermissionBody) error
func (*RBACManager) DeletePermission ¶
func (x *RBACManager) DeletePermission(apiIds []string) error
func (*RBACManager) DeleteRole ¶
func (x *RBACManager) DeleteRole(roleNames []string) error
func (*RBACManager) DeleteUser ¶
func (x *RBACManager) DeleteUser(userIds []uint64) error
func (*RBACManager) GetRoleApiIdsCache ¶
func (x *RBACManager) GetRoleApiIdsCache() map[string][]string
func (*RBACManager) GetUserRoleIdsCache ¶
func (x *RBACManager) GetUserRoleIdsCache() map[uint64][]string
func (*RBACManager) PermissionList ¶
func (x *RBACManager) PermissionList() (permissions []*kk_rbac_models.Permission, err error)
func (*RBACManager) RefreshCache ¶
func (x *RBACManager) RefreshCache() error
func (*RBACManager) RoleList ¶
func (x *RBACManager) RoleList(roleNames []string) (roles []*kk_rbac_models.Role, err error)
func (*RBACManager) UpdatePermission ¶
func (x *RBACManager) UpdatePermission(permissions []*kk_rbac_models.Permission) error
func (*RBACManager) UpdateRole ¶
func (x *RBACManager) UpdateRole(roles []*kk_rbac_models.Role) error
func (*RBACManager) UpdateUser ¶
func (x *RBACManager) UpdateUser(users []*kk_rbac_models.User) error
func (*RBACManager) UserList ¶
func (x *RBACManager) UserList() (users []*kk_rbac_models.User, err error)
Click to show internal directories.
Click to hide internal directories.