rbac

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GormPermitRepo

type GormPermitRepo struct {
	// contains filtered or unexported fields
}

func NewGormPermitRepo

func NewGormPermitRepo(db *gorm.DB, permit IPermit) *GormPermitRepo

func (*GormPermitRepo) GetPermitsByRole

func (r *GormPermitRepo) GetPermitsByRole(role IRole) (map[int64]string, error)

type GormRoleRepo

type GormRoleRepo struct {
	// contains filtered or unexported fields
}

func NewGormRoleRepo

func NewGormRoleRepo(db *gorm.DB, role IRole) *GormRoleRepo

func (*GormRoleRepo) GetRolesByUser

func (r *GormRoleRepo) GetRolesByUser(user IUser) (*[]IRole, error)

根据用户获取角色

type GormUserRepo

type GormUserRepo struct {
	// contains filtered or unexported fields
}

func NewGormUserRepo

func NewGormUserRepo(db *gorm.DB, user IUser) *GormUserRepo

func (*GormUserRepo) GetUserById

func (r *GormUserRepo) GetUserById(id int64) (IUser, error)

type IPermit

type IPermit interface {
	GetId() int64
	GetCode() string
}

type IPermitRepo

type IPermitRepo interface {
	GetPermitsByRole(role IRole) (map[int64]string, error)
}

type IRBACService

type IRBACService interface {
	CheckPermission(userId int64, code string) bool
	GetSecretKey() string
}

type IRole

type IRole interface {
	GetId() int64
	GetAlias() string
	GetPermitIds() []int64
}

type IRoleRepo

type IRoleRepo interface {
	GetRolesByUser(userId IUser) (*[]IRole, error)
}

type IUser

type IUser interface {
	GetId() int64
	GetRoleIds() []int64
}

type IUserRepo

type IUserRepo interface {
	GetUserById(id int64) (IUser, error)
}

type RBACServiceImpl

type RBACServiceImpl struct {
	SecretKey string
	// contains filtered or unexported fields
}

func NewRBACService

func NewRBACService(userRepo IUserRepo, roleRepo IRoleRepo, permitRepo IPermitRepo, secretKey string) *RBACServiceImpl

func (*RBACServiceImpl) CheckPermission

func (s *RBACServiceImpl) CheckPermission(userId int64, code string) bool

func (*RBACServiceImpl) GetSecretKey

func (s *RBACServiceImpl) GetSecretKey() string

Jump to

Keyboard shortcuts

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