rbac

package
v1.1.23 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Auth *auth

定义全局变量

Functions

func InitAuth

func InitAuth(service IRBACService)

初始化函数

Types

type CustomClaims

type CustomClaims struct {
	Id         int64
	Account    string
	ClientType string
	jwt.StandardClaims
}

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