kk_rbac

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

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

func InitDefaultRBAC(db *gorm.DB)

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 CheckPermissionBody struct {
	UserId uint64
	ApiId  string
}

type ConfigRBAC

type ConfigRBAC struct {
	DB *gorm.DB
}

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 NewRBAC

func NewRBAC(db *gorm.DB) (*RBACManager, error)

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)

Jump to

Keyboard shortcuts

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