role

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AdminRoleName 管理员角色名称, 系统初始化时创建
	AdminRoleName = "admin"
	// VisitorRoleName 访客角色名称, 系统初始化时创建
	VisitorRoleName = "visitor"
)
View Source
const (
	// RoleMaxPermission 一个角色允许添加的最大权限数
	RoleMaxPermission = 500
)

Variables

View Source
var (
	RoleType_name = map[int32]string{
		0: "NULL",
		1: "BUILDIN",
		2: "GLOBAL",
		3: "CUSTOM",
	}
	RoleType_value = map[string]int32{
		"NULL":    0,
		"BUILDIN": 1,
		"GLOBAL":  2,
		"CUSTOM":  3,
	}
)

Enum value maps for RoleType.

View Source
var (
	EffectType_name = map[int32]string{
		0: "ALLOW",
		1: "DENY",
	}
	EffectType_value = map[string]int32{
		"ALLOW": 0,
		"DENY":  1,
	}
)

Enum value maps for EffectType.

View Source
var File_pkg_role_pb_enum_proto protoreflect.FileDescriptor
View Source
var File_pkg_role_pb_request_proto protoreflect.FileDescriptor
View Source
var File_pkg_role_pb_role_proto protoreflect.FileDescriptor
View Source
var File_pkg_role_pb_service_proto protoreflect.FileDescriptor

Functions

func HttpEntry added in v0.2.0

func HttpEntry() *http.EntrySet

HttpEntry todo

func PermissionHash added in v0.2.8

func PermissionHash(namesapce string, perm *CreatePermssionRequest) string

func RegisterRoleServiceServer added in v0.2.0

func RegisterRoleServiceServer(s *grpc.Server, srv RoleServiceServer)

Types

type AddPermissionToRoleRequest added in v0.2.8

type AddPermissionToRoleRequest struct {
	RoleId      string                    `protobuf:"bytes,1,opt,name=role_id,json=roleId,proto3" json:"role_id" validate:"required,lte=64"`
	Permissions []*CreatePermssionRequest `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions" validate:"required"`
	// contains filtered or unexported fields
}

func NewAddPermissionToRoleRequest added in v0.2.8

func NewAddPermissionToRoleRequest() *AddPermissionToRoleRequest

NewAddPermissionToRoleRequest todo

func (*AddPermissionToRoleRequest) Descriptor deprecated added in v0.2.8

func (*AddPermissionToRoleRequest) Descriptor() ([]byte, []int)

Deprecated: Use AddPermissionToRoleRequest.ProtoReflect.Descriptor instead.

func (*AddPermissionToRoleRequest) GetPermissions added in v0.2.8

func (x *AddPermissionToRoleRequest) GetPermissions() []*CreatePermssionRequest

func (*AddPermissionToRoleRequest) GetRoleId added in v0.2.8

func (x *AddPermissionToRoleRequest) GetRoleId() string

func (*AddPermissionToRoleRequest) Length added in v0.2.8

func (req *AddPermissionToRoleRequest) Length() int

func (*AddPermissionToRoleRequest) ProtoMessage added in v0.2.8

func (*AddPermissionToRoleRequest) ProtoMessage()

func (*AddPermissionToRoleRequest) ProtoReflect added in v0.2.8

func (*AddPermissionToRoleRequest) Reset added in v0.2.8

func (x *AddPermissionToRoleRequest) Reset()

func (*AddPermissionToRoleRequest) String added in v0.2.8

func (x *AddPermissionToRoleRequest) String() string

func (*AddPermissionToRoleRequest) Validate added in v0.2.8

func (req *AddPermissionToRoleRequest) Validate() error

type CreatePermssionRequest added in v0.2.8

type CreatePermssionRequest struct {

	// 效力
	Effect EffectType `protobuf:"varint,1,opt,name=effect,proto3,enum=keyauth.role.EffectType" json:"effect" bson:"effect"`
	// 服务ID
	ServiceId string `protobuf:"bytes,2,opt,name=service_id,json=serviceId,proto3" json:"service_id" bson:"service_id"`
	// 资源列表
	ResourceName string `protobuf:"bytes,3,opt,name=resource_name,json=resourceName,proto3" json:"resource_name" bson:"resource_name"`
	// 维度
	LabelKey string `protobuf:"bytes,4,opt,name=label_key,json=labelKey,proto3" json:"label_key" bson:"label_key"`
	// 适配所有值
	MatchAll bool `protobuf:"varint,5,opt,name=match_all,json=matchAll,proto3" json:"match_all" bson:"match_all"`
	// 标识值
	LabelValues []string `protobuf:"bytes,6,rep,name=label_values,json=labelValues,proto3" json:"label_values" bson:"label_values"`
	// contains filtered or unexported fields
}

func NewDefaultPermission

func NewDefaultPermission() *CreatePermssionRequest

NewDefaultPermission todo

func (*CreatePermssionRequest) Descriptor deprecated added in v0.2.8

func (*CreatePermssionRequest) Descriptor() ([]byte, []int)

Deprecated: Use CreatePermssionRequest.ProtoReflect.Descriptor instead.

func (*CreatePermssionRequest) GetEffect added in v0.2.8

func (x *CreatePermssionRequest) GetEffect() EffectType

func (*CreatePermssionRequest) GetLabelKey added in v0.2.8

func (x *CreatePermssionRequest) GetLabelKey() string

func (*CreatePermssionRequest) GetLabelValues added in v0.2.8

func (x *CreatePermssionRequest) GetLabelValues() []string

func (*CreatePermssionRequest) GetMatchAll added in v0.2.8

func (x *CreatePermssionRequest) GetMatchAll() bool

func (*CreatePermssionRequest) GetResourceName added in v0.2.8

func (x *CreatePermssionRequest) GetResourceName() string

func (*CreatePermssionRequest) GetServiceId added in v0.2.8

func (x *CreatePermssionRequest) GetServiceId() string

func (*CreatePermssionRequest) ProtoMessage added in v0.2.8

func (*CreatePermssionRequest) ProtoMessage()

func (*CreatePermssionRequest) ProtoReflect added in v0.2.8

func (x *CreatePermssionRequest) ProtoReflect() protoreflect.Message

func (*CreatePermssionRequest) Reset added in v0.2.8

func (x *CreatePermssionRequest) Reset()

func (*CreatePermssionRequest) String added in v0.2.8

func (x *CreatePermssionRequest) String() string

func (*CreatePermssionRequest) Validate added in v0.2.8

func (p *CreatePermssionRequest) Validate() error

Validate todo

type CreateRoleRequest

type CreateRoleRequest struct {

	// 角色类型
	Type RoleType `protobuf:"varint,1,opt,name=type,proto3,enum=keyauth.role.RoleType" json:"type" bson:"type"`
	// 角色名称
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name" bson:"name" validate:"required,lte=30"`
	// 角色描述
	Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description" bson:"description" validate:"lte=400"`
	// 角色关联的page
	PageMarked string `protobuf:"bytes,4,opt,name=page_marked,json=pageMarked,proto3" json:"page_marked" bson:"page_marked" validate:"lte=400"`
	// 读权限
	Permissions []*CreatePermssionRequest `protobuf:"bytes,9,rep,name=permissions,proto3" json:"permissions" bson:"permissions"`
	// contains filtered or unexported fields
}

CreateRoleRequest 创建角色请求

func NewCreateRoleRequest

func NewCreateRoleRequest() *CreateRoleRequest

NewCreateRoleRequest 实例化请求

func (*CreateRoleRequest) Descriptor deprecated added in v0.2.0

func (*CreateRoleRequest) Descriptor() ([]byte, []int)

Deprecated: Use CreateRoleRequest.ProtoReflect.Descriptor instead.

func (*CreateRoleRequest) GetDescription added in v0.2.0

func (x *CreateRoleRequest) GetDescription() string

func (*CreateRoleRequest) GetName added in v0.2.0

func (x *CreateRoleRequest) GetName() string

func (*CreateRoleRequest) GetPageMarked added in v0.2.8

func (x *CreateRoleRequest) GetPageMarked() string

func (*CreateRoleRequest) GetPermissions added in v0.2.0

func (x *CreateRoleRequest) GetPermissions() []*CreatePermssionRequest

func (*CreateRoleRequest) GetType added in v0.2.0

func (x *CreateRoleRequest) GetType() RoleType

func (*CreateRoleRequest) IsCumstomType added in v0.2.0

func (req *CreateRoleRequest) IsCumstomType() bool

IsCumstomType todo

func (*CreateRoleRequest) ProtoMessage added in v0.2.0

func (*CreateRoleRequest) ProtoMessage()

func (*CreateRoleRequest) ProtoReflect added in v0.2.0

func (x *CreateRoleRequest) ProtoReflect() protoreflect.Message

func (*CreateRoleRequest) Reset added in v0.2.0

func (x *CreateRoleRequest) Reset()

func (*CreateRoleRequest) String added in v0.2.0

func (x *CreateRoleRequest) String() string

func (*CreateRoleRequest) Validate

func (req *CreateRoleRequest) Validate() error

Validate 请求校验

type DeleteRoleRequest added in v0.2.0

type DeleteRoleRequest struct {
	Id           string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" validate:"required,lte=64"`
	DeletePolicy bool   `protobuf:"varint,2,opt,name=delete_policy,json=deletePolicy,proto3" json:"delete_policy"`
	// contains filtered or unexported fields
}

DeleteRoleRequest role删除

func NewDeleteRoleWithID added in v0.2.5

func NewDeleteRoleWithID(id string) *DeleteRoleRequest

NewDeleteRoleWithID todo

func (*DeleteRoleRequest) Descriptor deprecated added in v0.2.0

func (*DeleteRoleRequest) Descriptor() ([]byte, []int)

Deprecated: Use DeleteRoleRequest.ProtoReflect.Descriptor instead.

func (*DeleteRoleRequest) GetDeletePolicy added in v0.2.5

func (x *DeleteRoleRequest) GetDeletePolicy() bool

func (*DeleteRoleRequest) GetId added in v0.2.0

func (x *DeleteRoleRequest) GetId() string

func (*DeleteRoleRequest) ProtoMessage added in v0.2.0

func (*DeleteRoleRequest) ProtoMessage()

func (*DeleteRoleRequest) ProtoReflect added in v0.2.0

func (x *DeleteRoleRequest) ProtoReflect() protoreflect.Message

func (*DeleteRoleRequest) Reset added in v0.2.0

func (x *DeleteRoleRequest) Reset()

func (*DeleteRoleRequest) String added in v0.2.0

func (x *DeleteRoleRequest) String() string

type DescribePermissionRequest added in v0.2.8

type DescribePermissionRequest struct {
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"`
	// contains filtered or unexported fields
}

DescribeRoleRequest role详情

func NewDescribePermissionRequestWithID added in v0.2.8

func NewDescribePermissionRequestWithID(id string) *DescribePermissionRequest

func (*DescribePermissionRequest) Descriptor deprecated added in v0.2.8

func (*DescribePermissionRequest) Descriptor() ([]byte, []int)

Deprecated: Use DescribePermissionRequest.ProtoReflect.Descriptor instead.

func (*DescribePermissionRequest) GetId added in v0.2.8

func (x *DescribePermissionRequest) GetId() string

func (*DescribePermissionRequest) ProtoMessage added in v0.2.8

func (*DescribePermissionRequest) ProtoMessage()

func (*DescribePermissionRequest) ProtoReflect added in v0.2.8

func (*DescribePermissionRequest) Reset added in v0.2.8

func (x *DescribePermissionRequest) Reset()

func (*DescribePermissionRequest) String added in v0.2.8

func (x *DescribePermissionRequest) String() string

func (*DescribePermissionRequest) Validate added in v0.2.8

func (req *DescribePermissionRequest) Validate() error

type DescribeRoleRequest

type DescribeRoleRequest struct {
	Id              string   `protobuf:"bytes,1,opt,name=id,proto3" json:"id"`
	Name            string   `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" validate:"required,lte=64"`
	WithPermissions bool     `protobuf:"varint,3,opt,name=with_permissions,json=withPermissions,proto3" json:"with_permissions" bson:"with_permissions"`
	Type            RoleType `protobuf:"varint,4,opt,name=type,proto3,enum=keyauth.role.RoleType" json:"type" bson:"type"`
	// contains filtered or unexported fields
}

DescribeRoleRequest role详情

func NewDescribeRoleRequestWithID added in v0.2.0

func NewDescribeRoleRequestWithID(id string) *DescribeRoleRequest

NewDescribeRoleRequestWithID todo

func NewDescribeRoleRequestWithName added in v0.2.0

func NewDescribeRoleRequestWithName(name string) *DescribeRoleRequest

NewDescribeRoleRequestWithName todo

func (*DescribeRoleRequest) Descriptor deprecated added in v0.2.0

func (*DescribeRoleRequest) Descriptor() ([]byte, []int)

Deprecated: Use DescribeRoleRequest.ProtoReflect.Descriptor instead.

func (*DescribeRoleRequest) GetId added in v0.2.0

func (x *DescribeRoleRequest) GetId() string

func (*DescribeRoleRequest) GetName added in v0.2.0

func (x *DescribeRoleRequest) GetName() string

func (*DescribeRoleRequest) GetType added in v0.2.0

func (x *DescribeRoleRequest) GetType() RoleType

func (*DescribeRoleRequest) GetWithPermissions added in v0.2.0

func (x *DescribeRoleRequest) GetWithPermissions() bool

func (*DescribeRoleRequest) ProtoMessage added in v0.2.0

func (*DescribeRoleRequest) ProtoMessage()

func (*DescribeRoleRequest) ProtoReflect added in v0.2.0

func (x *DescribeRoleRequest) ProtoReflect() protoreflect.Message

func (*DescribeRoleRequest) Reset added in v0.2.0

func (x *DescribeRoleRequest) Reset()

func (*DescribeRoleRequest) String added in v0.2.0

func (x *DescribeRoleRequest) String() string

func (*DescribeRoleRequest) Validate added in v0.2.0

func (req *DescribeRoleRequest) Validate() error

Validate todo

type EffectType

type EffectType int32

EffectType 授权效力包括两种:允许(Allow)和拒绝(Deny)

const (
	// 允许访问
	EffectType_ALLOW EffectType = 0
	// 拒绝访问
	EffectType_DENY EffectType = 1
)

func ParseEffectTypeFromString added in v0.2.0

func ParseEffectTypeFromString(str string) (EffectType, error)

ParseEffectTypeFromString Parse EffectType from string

func (EffectType) Descriptor added in v0.2.0

func (EffectType) Descriptor() protoreflect.EnumDescriptor

func (EffectType) Enum added in v0.2.0

func (x EffectType) Enum() *EffectType

func (EffectType) EnumDescriptor deprecated added in v0.2.0

func (EffectType) EnumDescriptor() ([]byte, []int)

Deprecated: Use EffectType.Descriptor instead.

func (EffectType) Equal added in v0.2.0

func (t EffectType) Equal(target EffectType) bool

Equal type compare

func (EffectType) IsIn added in v0.2.0

func (t EffectType) IsIn(targets ...EffectType) bool

IsIn todo

func (EffectType) MarshalJSON

func (t EffectType) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (EffectType) Number added in v0.2.0

func (x EffectType) Number() protoreflect.EnumNumber

func (EffectType) String

func (x EffectType) String() string

func (EffectType) Type added in v0.2.0

func (*EffectType) UnmarshalJSON

func (t *EffectType) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type Permission

type Permission struct {

	// id
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"`
	// 关联角色ID
	RoleId string `protobuf:"bytes,2,opt,name=role_id,json=roleId,proto3" json:"role_id" bson:"role_id"`
	// 创建时间
	CreateAt int64 `protobuf:"varint,3,opt,name=create_at,json=createAt,proto3" json:"create_at" bson:"create_at"`
	// 创建人
	Creater string `protobuf:"bytes,4,opt,name=creater,proto3" json:"creater" bson:"creater"`
	// 效力
	Effect EffectType `protobuf:"varint,5,opt,name=effect,proto3,enum=keyauth.role.EffectType" json:"effect" bson:"effect"`
	// 服务ID
	ServiceId string `protobuf:"bytes,6,opt,name=service_id,json=serviceId,proto3" json:"service_id" bson:"service_id"`
	// 资源列表
	ResourceName string `protobuf:"bytes,7,opt,name=resource_name,json=resourceName,proto3" json:"resource_name" bson:"resource_name"`
	// 维度
	LabelKey string `protobuf:"bytes,8,opt,name=label_key,json=labelKey,proto3" json:"label_key" bson:"label_key"`
	// 适配所有值
	MatchAll bool `protobuf:"varint,9,opt,name=match_all,json=matchAll,proto3" json:"match_all" bson:"match_all"`
	// 标识值
	LabelValues []string `protobuf:"bytes,10,rep,name=label_values,json=labelValues,proto3" json:"label_values" bson:"label_values"`
	// 范围, 角色范围限制, 由策略引擎动态补充
	Scope string `protobuf:"bytes,11,opt,name=scope,proto3" json:"scope" bson:"-"`
	// 权限描述
	Desc string `protobuf:"bytes,12,opt,name=desc,proto3" json:"desc" bson:"desc"`
	// contains filtered or unexported fields
}

Permission 权限

func NewDeaultPermission added in v0.2.8

func NewDeaultPermission() *Permission

func NewPermission added in v0.2.8

func NewPermission(roleID, creater string, perms []*CreatePermssionRequest) []*Permission

func (*Permission) Descriptor deprecated added in v0.2.0

func (*Permission) Descriptor() ([]byte, []int)

Deprecated: Use Permission.ProtoReflect.Descriptor instead.

func (*Permission) GetCreateAt added in v0.2.8

func (x *Permission) GetCreateAt() int64

func (*Permission) GetCreater added in v0.2.8

func (x *Permission) GetCreater() string

func (*Permission) GetDesc added in v0.3.2

func (x *Permission) GetDesc() string

func (*Permission) GetEffect added in v0.2.0

func (x *Permission) GetEffect() EffectType

func (*Permission) GetId added in v0.2.8

func (x *Permission) GetId() string

func (*Permission) GetLabelKey added in v0.2.0

func (x *Permission) GetLabelKey() string

func (*Permission) GetLabelValues added in v0.2.0

func (x *Permission) GetLabelValues() []string

func (*Permission) GetMatchAll added in v0.2.0

func (x *Permission) GetMatchAll() bool

func (*Permission) GetResourceName added in v0.2.0

func (x *Permission) GetResourceName() string

func (*Permission) GetRoleId added in v0.2.8

func (x *Permission) GetRoleId() string

func (*Permission) GetScope added in v0.3.2

func (x *Permission) GetScope() string

func (*Permission) GetServiceId added in v0.2.0

func (x *Permission) GetServiceId() string

func (*Permission) ID

func (p *Permission) ID(namespace string) string

ID 计算唯一ID

func (*Permission) MatchLabel added in v0.2.0

func (p *Permission) MatchLabel(label map[string]string) bool

MatchLabel 匹配Label

func (*Permission) MatchResource added in v0.2.0

func (p *Permission) MatchResource(serviceID, resourceName string) bool

MatchResource 检测资源是否匹配

func (*Permission) ProtoMessage added in v0.2.0

func (*Permission) ProtoMessage()

func (*Permission) ProtoReflect added in v0.2.0

func (x *Permission) ProtoReflect() protoreflect.Message

func (*Permission) Reset added in v0.2.0

func (x *Permission) Reset()

func (*Permission) String added in v0.2.0

func (x *Permission) String() string

type PermissionSet

type PermissionSet struct {
	Total int64         `protobuf:"varint,1,opt,name=total,proto3" json:"total" bson:"total"`
	Items []*Permission `protobuf:"bytes,2,rep,name=items,proto3" json:"items" bson:"items"`
	// contains filtered or unexported fields
}

PermissionSet 用户列表

func NewPermissionSet added in v0.2.0

func NewPermissionSet() *PermissionSet

NewPermissionSet todo

func (*PermissionSet) Add

func (s *PermissionSet) Add(items ...*Permission)

Add todo

func (*PermissionSet) Descriptor deprecated added in v0.2.0

func (*PermissionSet) Descriptor() ([]byte, []int)

Deprecated: Use PermissionSet.ProtoReflect.Descriptor instead.

func (*PermissionSet) GetItems added in v0.2.0

func (x *PermissionSet) GetItems() []*Permission

func (*PermissionSet) GetTotal added in v0.2.0

func (x *PermissionSet) GetTotal() int64

func (*PermissionSet) ProtoMessage added in v0.2.0

func (*PermissionSet) ProtoMessage()

func (*PermissionSet) ProtoReflect added in v0.2.0

func (x *PermissionSet) ProtoReflect() protoreflect.Message

func (*PermissionSet) Reset added in v0.2.0

func (x *PermissionSet) Reset()

func (*PermissionSet) String added in v0.2.0

func (x *PermissionSet) String() string

type QueryPermissionRequest added in v0.2.8

type QueryPermissionRequest struct {
	Page      *page.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page"`
	RoleId    string            `protobuf:"bytes,2,opt,name=role_id,json=roleId,proto3" json:"role_id,omitempty"`
	SkipItmes bool              `protobuf:"varint,3,opt,name=skip_itmes,json=skipItmes,proto3" json:"skip_itmes,omitempty"`
	// contains filtered or unexported fields
}

func NewQueryPermissionRequest added in v0.2.8

func NewQueryPermissionRequest(pageReq *request.PageRequest) *QueryPermissionRequest

NewQueryPermissionRequest todo

func NewQueryPermissionRequestFromHTTP added in v0.2.8

func NewQueryPermissionRequestFromHTTP(r *http.Request) *QueryPermissionRequest

NewQueryPermissionRequestFromHTTP 列表查询请求

func (*QueryPermissionRequest) Descriptor deprecated added in v0.2.8

func (*QueryPermissionRequest) Descriptor() ([]byte, []int)

Deprecated: Use QueryPermissionRequest.ProtoReflect.Descriptor instead.

func (*QueryPermissionRequest) GetPage added in v0.2.8

func (x *QueryPermissionRequest) GetPage() *page.PageRequest

func (*QueryPermissionRequest) GetRoleId added in v0.2.8

func (x *QueryPermissionRequest) GetRoleId() string

func (*QueryPermissionRequest) GetSkipItmes added in v0.2.8

func (x *QueryPermissionRequest) GetSkipItmes() bool

func (*QueryPermissionRequest) ProtoMessage added in v0.2.8

func (*QueryPermissionRequest) ProtoMessage()

func (*QueryPermissionRequest) ProtoReflect added in v0.2.8

func (x *QueryPermissionRequest) ProtoReflect() protoreflect.Message

func (*QueryPermissionRequest) Reset added in v0.2.8

func (x *QueryPermissionRequest) Reset()

func (*QueryPermissionRequest) String added in v0.2.8

func (x *QueryPermissionRequest) String() string

func (*QueryPermissionRequest) Validate added in v0.2.8

func (req *QueryPermissionRequest) Validate() error

type QueryRoleRequest

type QueryRoleRequest struct {
	Page *page.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page"`
	Type RoleType          `protobuf:"varint,2,opt,name=type,proto3,enum=keyauth.role.RoleType" json:"type,omitempty"`
	// contains filtered or unexported fields
}

QueryRoleRequest 列表查询

func NewQueryRoleRequest

func NewQueryRoleRequest(pageReq *request.PageRequest) *QueryRoleRequest

NewQueryRoleRequest 列表查询请求

func NewQueryRoleRequestFromHTTP added in v0.2.0

func NewQueryRoleRequestFromHTTP(r *http.Request) *QueryRoleRequest

NewQueryRoleRequestFromHTTP 列表查询请求

func (*QueryRoleRequest) Descriptor deprecated added in v0.2.0

func (*QueryRoleRequest) Descriptor() ([]byte, []int)

Deprecated: Use QueryRoleRequest.ProtoReflect.Descriptor instead.

func (*QueryRoleRequest) GetPage added in v0.2.0

func (x *QueryRoleRequest) GetPage() *page.PageRequest

func (*QueryRoleRequest) GetType added in v0.2.0

func (x *QueryRoleRequest) GetType() RoleType

func (*QueryRoleRequest) ProtoMessage added in v0.2.0

func (*QueryRoleRequest) ProtoMessage()

func (*QueryRoleRequest) ProtoReflect added in v0.2.0

func (x *QueryRoleRequest) ProtoReflect() protoreflect.Message

func (*QueryRoleRequest) Reset added in v0.2.0

func (x *QueryRoleRequest) Reset()

func (*QueryRoleRequest) String added in v0.2.0

func (x *QueryRoleRequest) String() string

func (*QueryRoleRequest) Validate added in v0.2.0

func (req *QueryRoleRequest) Validate() error

Validate todo

type RemovePermissionFromRoleRequest added in v0.2.8

type RemovePermissionFromRoleRequest struct {
	RoleId       string   `protobuf:"bytes,1,opt,name=role_id,json=roleId,proto3" json:"role_id" validate:"required,lte=64"`
	RemoveAll    bool     `protobuf:"varint,2,opt,name=remove_all,json=removeAll,proto3" json:"remove_all"`
	PermissionId []string `protobuf:"bytes,3,rep,name=permission_id,json=permissionId,proto3" json:"permission_id"`
	// contains filtered or unexported fields
}

func NewRemovePermissionFromRoleRequest added in v0.2.8

func NewRemovePermissionFromRoleRequest() *RemovePermissionFromRoleRequest

NewRemovePermissionFromRoleRequest todo

func (*RemovePermissionFromRoleRequest) Descriptor deprecated added in v0.2.8

func (*RemovePermissionFromRoleRequest) Descriptor() ([]byte, []int)

Deprecated: Use RemovePermissionFromRoleRequest.ProtoReflect.Descriptor instead.

func (*RemovePermissionFromRoleRequest) GetPermissionId added in v0.2.8

func (x *RemovePermissionFromRoleRequest) GetPermissionId() []string

func (*RemovePermissionFromRoleRequest) GetRemoveAll added in v0.2.8

func (x *RemovePermissionFromRoleRequest) GetRemoveAll() bool

func (*RemovePermissionFromRoleRequest) GetRoleId added in v0.2.8

func (x *RemovePermissionFromRoleRequest) GetRoleId() string

func (*RemovePermissionFromRoleRequest) ProtoMessage added in v0.2.8

func (*RemovePermissionFromRoleRequest) ProtoMessage()

func (*RemovePermissionFromRoleRequest) ProtoReflect added in v0.2.8

func (*RemovePermissionFromRoleRequest) Reset added in v0.2.8

func (*RemovePermissionFromRoleRequest) String added in v0.2.8

func (*RemovePermissionFromRoleRequest) Validate added in v0.2.8

func (req *RemovePermissionFromRoleRequest) Validate() error

type Role

type Role struct {

	// 角色ID
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"`
	// 创建时间`
	CreateAt int64 `protobuf:"varint,2,opt,name=create_at,json=createAt,proto3" json:"create_at" bson:"create_at"`
	// 更新时间
	UpdateAt int64 `protobuf:"varint,3,opt,name=update_at,json=updateAt,proto3" json:"update_at" bson:"update_at"`
	// 角色所属域
	Domain string `protobuf:"bytes,4,opt,name=domain,proto3" json:"domain" bson:"domain"`
	// 创建人
	Creater string `protobuf:"bytes,5,opt,name=creater,proto3" json:"creater" bson:"creater"`
	// 角色类型
	Type RoleType `protobuf:"varint,6,opt,name=type,proto3,enum=keyauth.role.RoleType" json:"type" bson:"type"`
	// 应用名称
	Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name" bson:"name"`
	// 应用简单的描述
	Description string `protobuf:"bytes,8,opt,name=description,proto3" json:"description" bson:"description"`
	// 角色关联的page
	PageMarked string `protobuf:"bytes,10,opt,name=page_marked,json=pageMarked,proto3" json:"page_marked" bson:"page_marked"`
	// 读权限
	Permissions []*Permission `protobuf:"bytes,9,rep,name=permissions,proto3" json:"permissions,omitempty" bson:"-"`
	// 范围, 角色范围限制, 由策略引擎动态补充
	Scope string `protobuf:"bytes,11,opt,name=scope,proto3" json:"scope" bson:"-"`
	// contains filtered or unexported fields
}

Role is rbac's role

func New

func New(tk *token.Token, req *CreateRoleRequest) (*Role, error)

New 新创建一个Role

func NewDefaultRole

func NewDefaultRole() *Role

NewDefaultRole 默认实例

func (*Role) CheckPermission

func (r *Role) CheckPermission() error

CheckPermission 检测该角色是否具有该权限

func (*Role) Descriptor deprecated added in v0.2.0

func (*Role) Descriptor() ([]byte, []int)

Deprecated: Use Role.ProtoReflect.Descriptor instead.

func (*Role) GetCreateAt added in v0.2.0

func (x *Role) GetCreateAt() int64

func (*Role) GetCreater added in v0.2.0

func (x *Role) GetCreater() string

func (*Role) GetDescription added in v0.2.0

func (x *Role) GetDescription() string

func (*Role) GetDomain added in v0.2.0

func (x *Role) GetDomain() string

func (*Role) GetId added in v0.2.0

func (x *Role) GetId() string

func (*Role) GetName added in v0.2.0

func (x *Role) GetName() string

func (*Role) GetPageMarked added in v0.2.8

func (x *Role) GetPageMarked() string

func (*Role) GetPermissions added in v0.2.0

func (x *Role) GetPermissions() []*Permission

func (*Role) GetScope added in v0.3.2

func (x *Role) GetScope() string

func (*Role) GetType added in v0.2.0

func (x *Role) GetType() RoleType

func (*Role) GetUpdateAt added in v0.2.0

func (x *Role) GetUpdateAt() int64

func (*Role) HasPermission added in v0.2.0

func (r *Role) HasPermission(ep *endpoint.Endpoint) (*Permission, bool, error)

HasPermission 权限判断

func (*Role) ProtoMessage added in v0.2.0

func (*Role) ProtoMessage()

func (*Role) ProtoReflect added in v0.2.0

func (x *Role) ProtoReflect() protoreflect.Message

func (*Role) Reset added in v0.2.0

func (x *Role) Reset()

func (*Role) String added in v0.2.0

func (x *Role) String() string

type RoleServiceClient added in v0.2.0

type RoleServiceClient interface {
	CreateRole(ctx context.Context, in *CreateRoleRequest, opts ...grpc.CallOption) (*Role, error)
	QueryRole(ctx context.Context, in *QueryRoleRequest, opts ...grpc.CallOption) (*Set, error)
	DescribeRole(ctx context.Context, in *DescribeRoleRequest, opts ...grpc.CallOption) (*Role, error)
	DeleteRole(ctx context.Context, in *DeleteRoleRequest, opts ...grpc.CallOption) (*Role, error)
	QueryPermission(ctx context.Context, in *QueryPermissionRequest, opts ...grpc.CallOption) (*PermissionSet, error)
	DescribePermission(ctx context.Context, in *DescribePermissionRequest, opts ...grpc.CallOption) (*Permission, error)
	AddPermissionToRole(ctx context.Context, in *AddPermissionToRoleRequest, opts ...grpc.CallOption) (*PermissionSet, error)
	RemovePermissionFromRole(ctx context.Context, in *RemovePermissionFromRoleRequest, opts ...grpc.CallOption) (*PermissionSet, error)
	UpdatePermission(ctx context.Context, in *UpdatePermissionRequest, opts ...grpc.CallOption) (*Permission, error)
}

RoleServiceClient is the client API for RoleService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewRoleServiceClient added in v0.2.0

func NewRoleServiceClient(cc grpc.ClientConnInterface) RoleServiceClient

type RoleServiceServer added in v0.2.0

type RoleServiceServer interface {
	CreateRole(context.Context, *CreateRoleRequest) (*Role, error)
	QueryRole(context.Context, *QueryRoleRequest) (*Set, error)
	DescribeRole(context.Context, *DescribeRoleRequest) (*Role, error)
	DeleteRole(context.Context, *DeleteRoleRequest) (*Role, error)
	QueryPermission(context.Context, *QueryPermissionRequest) (*PermissionSet, error)
	DescribePermission(context.Context, *DescribePermissionRequest) (*Permission, error)
	AddPermissionToRole(context.Context, *AddPermissionToRoleRequest) (*PermissionSet, error)
	RemovePermissionFromRole(context.Context, *RemovePermissionFromRoleRequest) (*PermissionSet, error)
	UpdatePermission(context.Context, *UpdatePermissionRequest) (*Permission, error)
	// contains filtered or unexported methods
}

RoleServiceServer is the server API for RoleService service. All implementations must embed UnimplementedRoleServiceServer for forward compatibility

type RoleType added in v0.2.0

type RoleType int32

RoleType 角色

const (
	RoleType_NULL RoleType = 0
	// 内建角色, 系统初始时创建
	RoleType_BUILDIN RoleType = 1
	// 管理员创建的一些角色, 全局可用
	RoleType_GLOBAL RoleType = 2
	// 用户自定义的角色, 仅域内可见
	RoleType_CUSTOM RoleType = 3
)

func ParseRoleTypeFromString added in v0.2.0

func ParseRoleTypeFromString(str string) (RoleType, error)

ParseRoleTypeFromString Parse RoleType from string

func (RoleType) Descriptor added in v0.2.0

func (RoleType) Descriptor() protoreflect.EnumDescriptor

func (RoleType) Enum added in v0.2.0

func (x RoleType) Enum() *RoleType

func (RoleType) EnumDescriptor deprecated added in v0.2.0

func (RoleType) EnumDescriptor() ([]byte, []int)

Deprecated: Use RoleType.Descriptor instead.

func (RoleType) Equal added in v0.2.0

func (t RoleType) Equal(target RoleType) bool

Equal type compare

func (RoleType) IsIn added in v0.2.0

func (t RoleType) IsIn(targets ...RoleType) bool

IsIn todo

func (RoleType) MarshalJSON added in v0.2.0

func (t RoleType) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (RoleType) Number added in v0.2.0

func (x RoleType) Number() protoreflect.EnumNumber

func (RoleType) String added in v0.2.0

func (x RoleType) String() string

func (RoleType) Type added in v0.2.0

func (*RoleType) UnmarshalJSON added in v0.2.0

func (t *RoleType) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type Set

type Set struct {
	Total int64   `protobuf:"varint,1,opt,name=total,proto3" json:"total" bson:"total"`
	Items []*Role `protobuf:"bytes,2,rep,name=items,proto3" json:"items" bson:"items"`
	// contains filtered or unexported fields
}

func NewRoleSet

func NewRoleSet() *Set

NewRoleSet 实例化make

func (*Set) Add

func (s *Set) Add(item *Role)

Add todo

func (*Set) Descriptor deprecated added in v0.2.0

func (*Set) Descriptor() ([]byte, []int)

Deprecated: Use Set.ProtoReflect.Descriptor instead.

func (*Set) GetItems added in v0.2.0

func (x *Set) GetItems() []*Role

func (*Set) GetTotal added in v0.2.0

func (x *Set) GetTotal() int64

func (*Set) HasPermission added in v0.2.0

func (s *Set) HasPermission(ep *endpoint.Endpoint) (*Permission, bool, error)

HasPermission todo

func (*Set) Permissions added in v0.2.0

func (s *Set) Permissions() *PermissionSet

Permissions todo

func (*Set) ProtoMessage added in v0.2.0

func (*Set) ProtoMessage()

func (*Set) ProtoReflect added in v0.2.0

func (x *Set) ProtoReflect() protoreflect.Message

func (*Set) Reset added in v0.2.0

func (x *Set) Reset()

func (*Set) RoleNames added in v0.3.2

func (s *Set) RoleNames() []string

func (*Set) String added in v0.2.0

func (x *Set) String() string

type UnimplementedRoleServiceServer added in v0.2.0

type UnimplementedRoleServiceServer struct {
}

UnimplementedRoleServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedRoleServiceServer) AddPermissionToRole added in v0.2.8

func (UnimplementedRoleServiceServer) CreateRole added in v0.2.0

func (UnimplementedRoleServiceServer) DeleteRole added in v0.2.0

func (UnimplementedRoleServiceServer) DescribePermission added in v0.2.8

func (UnimplementedRoleServiceServer) DescribeRole added in v0.2.0

func (UnimplementedRoleServiceServer) QueryPermission added in v0.2.8

func (UnimplementedRoleServiceServer) QueryRole added in v0.2.0

func (UnimplementedRoleServiceServer) RemovePermissionFromRole added in v0.2.8

func (UnimplementedRoleServiceServer) UpdatePermission added in v0.2.8

type UnsafeRoleServiceServer added in v0.2.0

type UnsafeRoleServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeRoleServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RoleServiceServer will result in compilation errors.

type UpdatePermissionRequest added in v0.2.8

type UpdatePermissionRequest struct {

	// permission id
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" validate:"required,lte=64"`
	// 维度
	LabelKey string `protobuf:"bytes,2,opt,name=label_key,json=labelKey,proto3" json:"label_key"`
	// 适配所有值
	MatchAll bool `protobuf:"varint,3,opt,name=match_all,json=matchAll,proto3" json:"match_all"`
	// 标识值
	LabelValues []string `protobuf:"bytes,4,rep,name=label_values,json=labelValues,proto3" json:"label_values"`
	// contains filtered or unexported fields
}

func NewUpdatePermissionRequest added in v0.2.8

func NewUpdatePermissionRequest() *UpdatePermissionRequest

func (*UpdatePermissionRequest) Descriptor deprecated added in v0.2.8

func (*UpdatePermissionRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpdatePermissionRequest.ProtoReflect.Descriptor instead.

func (*UpdatePermissionRequest) GetId added in v0.2.8

func (x *UpdatePermissionRequest) GetId() string

func (*UpdatePermissionRequest) GetLabelKey added in v0.2.8

func (x *UpdatePermissionRequest) GetLabelKey() string

func (*UpdatePermissionRequest) GetLabelValues added in v0.2.8

func (x *UpdatePermissionRequest) GetLabelValues() []string

func (*UpdatePermissionRequest) GetMatchAll added in v0.2.8

func (x *UpdatePermissionRequest) GetMatchAll() bool

func (*UpdatePermissionRequest) ProtoMessage added in v0.2.8

func (*UpdatePermissionRequest) ProtoMessage()

func (*UpdatePermissionRequest) ProtoReflect added in v0.2.8

func (x *UpdatePermissionRequest) ProtoReflect() protoreflect.Message

func (*UpdatePermissionRequest) Reset added in v0.2.8

func (x *UpdatePermissionRequest) Reset()

func (*UpdatePermissionRequest) String added in v0.2.8

func (x *UpdatePermissionRequest) String() string

func (*UpdatePermissionRequest) Validate added in v0.2.8

func (req *UpdatePermissionRequest) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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