role

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AdminRoleName 管理员角色名称, 系统初始化时创建
	AdminRoleName = "admin"
	// VisitorRoleName 访客角色名称, 系统初始化时创建
	VisitorRoleName = "visitor"
)
View Source
const (
	AppName = "role"
)
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_apps_role_pb_enum_proto protoreflect.FileDescriptor
View Source
var File_apps_role_pb_request_proto protoreflect.FileDescriptor
View Source
var File_apps_role_pb_role_proto protoreflect.FileDescriptor
View Source
var File_apps_role_pb_service_proto protoreflect.FileDescriptor
View Source
var Service_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "infraboard.keyauth.role.Service",
	HandlerType: (*ServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreateRole",
			Handler:    _Service_CreateRole_Handler,
		},
		{
			MethodName: "QueryRole",
			Handler:    _Service_QueryRole_Handler,
		},
		{
			MethodName: "DescribeRole",
			Handler:    _Service_DescribeRole_Handler,
		},
		{
			MethodName: "DeleteRole",
			Handler:    _Service_DeleteRole_Handler,
		},
		{
			MethodName: "QueryPermission",
			Handler:    _Service_QueryPermission_Handler,
		},
		{
			MethodName: "DescribePermission",
			Handler:    _Service_DescribePermission_Handler,
		},
		{
			MethodName: "AddPermissionToRole",
			Handler:    _Service_AddPermissionToRole_Handler,
		},
		{
			MethodName: "RemovePermissionFromRole",
			Handler:    _Service_RemovePermissionFromRole_Handler,
		},
		{
			MethodName: "UpdatePermission",
			Handler:    _Service_UpdatePermission_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apps/role/pb/service.proto",
}

Service_ServiceDesc is the grpc.ServiceDesc for Service service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func HttpEntry

func HttpEntry() *http.EntrySet

HttpEntry todo

func PermissionHash

func PermissionHash(namesapce string, perm *CreatePermssionRequest) string

func RegisterServiceServer

func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)

Types

type AddPermissionToRoleRequest

type AddPermissionToRoleRequest struct {

	// 创建者ID
	// @gotags: json:"create_by" validate:"required"
	CreateBy string `protobuf:"bytes,3,opt,name=create_by,json=createBy,proto3" json:"create_by" validate:"required"`
	// @gotags: json:"role_id" validate:"required,lte=64"
	RoleId string `protobuf:"bytes,1,opt,name=role_id,json=roleId,proto3" json:"role_id" validate:"required,lte=64"`
	// @gotags: json:"permissions" validate:"required"
	Permissions []*CreatePermssionRequest `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions" validate:"required"`
	// contains filtered or unexported fields
}

func NewAddPermissionToRoleRequest

func NewAddPermissionToRoleRequest() *AddPermissionToRoleRequest

NewAddPermissionToRoleRequest todo

func (*AddPermissionToRoleRequest) Descriptor deprecated

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

Deprecated: Use AddPermissionToRoleRequest.ProtoReflect.Descriptor instead.

func (*AddPermissionToRoleRequest) GetCreateBy

func (x *AddPermissionToRoleRequest) GetCreateBy() string

func (*AddPermissionToRoleRequest) GetPermissions

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

func (*AddPermissionToRoleRequest) GetRoleId

func (x *AddPermissionToRoleRequest) GetRoleId() string

func (*AddPermissionToRoleRequest) Length

func (req *AddPermissionToRoleRequest) Length() int

func (*AddPermissionToRoleRequest) ProtoMessage

func (*AddPermissionToRoleRequest) ProtoMessage()

func (*AddPermissionToRoleRequest) ProtoReflect

func (*AddPermissionToRoleRequest) Reset

func (x *AddPermissionToRoleRequest) Reset()

func (*AddPermissionToRoleRequest) String

func (x *AddPermissionToRoleRequest) String() string

func (*AddPermissionToRoleRequest) Validate

func (req *AddPermissionToRoleRequest) Validate() error

type CreatePermssionRequest

type CreatePermssionRequest struct {

	// 效力
	// @gotags: bson:"effect" json:"effect"
	Effect EffectType `protobuf:"varint,1,opt,name=effect,proto3,enum=infraboard.keyauth.role.EffectType" json:"effect" bson:"effect"`
	// 服务ID
	// @gotags: bson:"service_id" json:"service_id"
	ServiceId string `protobuf:"bytes,2,opt,name=service_id,json=serviceId,proto3" json:"service_id" bson:"service_id"`
	// 资源列表
	// @gotags: bson:"resource_name" json:"resource_name"
	ResourceName string `protobuf:"bytes,3,opt,name=resource_name,json=resourceName,proto3" json:"resource_name" bson:"resource_name"`
	// 维度
	// @gotags: bson:"label_key" json:"label_key"
	LabelKey string `protobuf:"bytes,4,opt,name=label_key,json=labelKey,proto3" json:"label_key" bson:"label_key"`
	// 适配所有值
	// @gotags: bson:"match_all" json:"match_all"
	MatchAll bool `protobuf:"varint,5,opt,name=match_all,json=matchAll,proto3" json:"match_all" bson:"match_all"`
	// 标识值
	// @gotags: bson:"label_values" json:"label_values"
	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

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

Deprecated: Use CreatePermssionRequest.ProtoReflect.Descriptor instead.

func (*CreatePermssionRequest) GetEffect

func (x *CreatePermssionRequest) GetEffect() EffectType

func (*CreatePermssionRequest) GetLabelKey

func (x *CreatePermssionRequest) GetLabelKey() string

func (*CreatePermssionRequest) GetLabelValues

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

func (*CreatePermssionRequest) GetMatchAll

func (x *CreatePermssionRequest) GetMatchAll() bool

func (*CreatePermssionRequest) GetResourceName

func (x *CreatePermssionRequest) GetResourceName() string

func (*CreatePermssionRequest) GetServiceId

func (x *CreatePermssionRequest) GetServiceId() string

func (*CreatePermssionRequest) ProtoMessage

func (*CreatePermssionRequest) ProtoMessage()

func (*CreatePermssionRequest) ProtoReflect

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

func (*CreatePermssionRequest) Reset

func (x *CreatePermssionRequest) Reset()

func (*CreatePermssionRequest) String

func (x *CreatePermssionRequest) String() string

func (*CreatePermssionRequest) Validate

func (p *CreatePermssionRequest) Validate() error

Validate todo

type CreateRoleRequest

type CreateRoleRequest struct {

	// 角色类型
	// @gotags: bson:"type" json:"type"
	Type RoleType `protobuf:"varint,1,opt,name=type,proto3,enum=infraboard.keyauth.role.RoleType" json:"type" bson:"type"`
	// 角色名称
	// @gotags: bson:"name" json:"name" validate:"required,lte=30"
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name" bson:"name" validate:"required,lte=30"`
	// 角色描述
	// @gotags: bson:"description" json:"description" validate:"lte=400"
	Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description" bson:"description" validate:"lte=400"`
	// 角色关联的其他信息,比如展示的视图
	// @gotags: bson:"meta" json:"meta" validate:"lte=400"
	Meta map[string]string `` /* 170-byte string literal not displayed */
	// 所属域
	// @gotags: bson:"domain" json:"domain"
	Domain string `protobuf:"bytes,5,opt,name=domain,proto3" json:"domain" bson:"domain"`
	// 创建者ID
	// @gotags: bson:"create_by" json:"create_by"
	CreateBy string `protobuf:"bytes,6,opt,name=create_by,json=createBy,proto3" json:"create_by" bson:"create_by"`
	// 读权限
	// @gotags: bson:"permissions" json:"permissions"
	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

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

Deprecated: Use CreateRoleRequest.ProtoReflect.Descriptor instead.

func (*CreateRoleRequest) GetCreateBy

func (x *CreateRoleRequest) GetCreateBy() string

func (*CreateRoleRequest) GetDescription

func (x *CreateRoleRequest) GetDescription() string

func (*CreateRoleRequest) GetDomain

func (x *CreateRoleRequest) GetDomain() string

func (*CreateRoleRequest) GetMeta

func (x *CreateRoleRequest) GetMeta() map[string]string

func (*CreateRoleRequest) GetName

func (x *CreateRoleRequest) GetName() string

func (*CreateRoleRequest) GetPermissions

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

func (*CreateRoleRequest) GetType

func (x *CreateRoleRequest) GetType() RoleType

func (*CreateRoleRequest) IsCumstomType

func (req *CreateRoleRequest) IsCumstomType() bool

IsCumstomType todo

func (*CreateRoleRequest) ProtoMessage

func (*CreateRoleRequest) ProtoMessage()

func (*CreateRoleRequest) ProtoReflect

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

func (*CreateRoleRequest) Reset

func (x *CreateRoleRequest) Reset()

func (*CreateRoleRequest) ServiceIds

func (req *CreateRoleRequest) ServiceIds() (ids []string)

func (*CreateRoleRequest) String

func (x *CreateRoleRequest) String() string

func (*CreateRoleRequest) Validate

func (req *CreateRoleRequest) Validate() error

Validate 请求校验

type DeleteRoleRequest

type DeleteRoleRequest struct {

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

DeleteRoleRequest role删除

func NewDeleteRoleWithID

func NewDeleteRoleWithID(id string) *DeleteRoleRequest

NewDeleteRoleWithID todo

func (*DeleteRoleRequest) Descriptor deprecated

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

Deprecated: Use DeleteRoleRequest.ProtoReflect.Descriptor instead.

func (*DeleteRoleRequest) GetDeletePolicy

func (x *DeleteRoleRequest) GetDeletePolicy() bool

func (*DeleteRoleRequest) GetId

func (x *DeleteRoleRequest) GetId() string

func (*DeleteRoleRequest) ProtoMessage

func (*DeleteRoleRequest) ProtoMessage()

func (*DeleteRoleRequest) ProtoReflect

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

func (*DeleteRoleRequest) Reset

func (x *DeleteRoleRequest) Reset()

func (*DeleteRoleRequest) String

func (x *DeleteRoleRequest) String() string

type DescribePermissionRequest

type DescribePermissionRequest struct {

	// @gotags: json:"id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"`
	// contains filtered or unexported fields
}

DescribeRoleRequest role详情

func NewDescribePermissionRequestWithID

func NewDescribePermissionRequestWithID(id string) *DescribePermissionRequest

func (*DescribePermissionRequest) Descriptor deprecated

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

Deprecated: Use DescribePermissionRequest.ProtoReflect.Descriptor instead.

func (*DescribePermissionRequest) GetId

func (x *DescribePermissionRequest) GetId() string

func (*DescribePermissionRequest) ProtoMessage

func (*DescribePermissionRequest) ProtoMessage()

func (*DescribePermissionRequest) ProtoReflect

func (*DescribePermissionRequest) Reset

func (x *DescribePermissionRequest) Reset()

func (*DescribePermissionRequest) String

func (x *DescribePermissionRequest) String() string

func (*DescribePermissionRequest) Validate

func (req *DescribePermissionRequest) Validate() error

type DescribeRoleRequest

type DescribeRoleRequest struct {

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

DescribeRoleRequest role详情

func NewDescribeRoleRequestWithID

func NewDescribeRoleRequestWithID(id string) *DescribeRoleRequest

NewDescribeRoleRequestWithID todo

func NewDescribeRoleRequestWithName

func NewDescribeRoleRequestWithName(name string) *DescribeRoleRequest

NewDescribeRoleRequestWithName todo

func (*DescribeRoleRequest) Descriptor deprecated

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

Deprecated: Use DescribeRoleRequest.ProtoReflect.Descriptor instead.

func (*DescribeRoleRequest) GetId

func (x *DescribeRoleRequest) GetId() string

func (*DescribeRoleRequest) GetName

func (x *DescribeRoleRequest) GetName() string

func (*DescribeRoleRequest) GetType

func (x *DescribeRoleRequest) GetType() RoleType

func (*DescribeRoleRequest) GetWithPermissions

func (x *DescribeRoleRequest) GetWithPermissions() bool

func (*DescribeRoleRequest) ProtoMessage

func (*DescribeRoleRequest) ProtoMessage()

func (*DescribeRoleRequest) ProtoReflect

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

func (*DescribeRoleRequest) Reset

func (x *DescribeRoleRequest) Reset()

func (*DescribeRoleRequest) String

func (x *DescribeRoleRequest) String() string

func (*DescribeRoleRequest) Validate

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

func ParseEffectTypeFromString(str string) (EffectType, error)

ParseEffectTypeFromString Parse EffectType from string

func (EffectType) Descriptor

func (EffectType) Descriptor() protoreflect.EnumDescriptor

func (EffectType) Enum

func (x EffectType) Enum() *EffectType

func (EffectType) EnumDescriptor deprecated

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

Deprecated: Use EffectType.Descriptor instead.

func (EffectType) Equal

func (t EffectType) Equal(target EffectType) bool

Equal type compare

func (EffectType) IsIn

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

IsIn todo

func (EffectType) MarshalJSON

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

MarshalJSON todo

func (EffectType) Number

func (x EffectType) Number() protoreflect.EnumNumber

func (EffectType) String

func (x EffectType) String() string

func (EffectType) Type

func (*EffectType) UnmarshalJSON

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

UnmarshalJSON todo

type Permission

type Permission struct {

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

Permission 权限

func NewDeaultPermission

func NewDeaultPermission() *Permission

func NewPermission

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

func NewSkipPermission

func NewSkipPermission(message string) *Permission

func (*Permission) Descriptor deprecated

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

Deprecated: Use Permission.ProtoReflect.Descriptor instead.

func (*Permission) GetCreateAt

func (x *Permission) GetCreateAt() int64

func (*Permission) GetCreater

func (x *Permission) GetCreater() string

func (*Permission) GetDesc

func (x *Permission) GetDesc() string

func (*Permission) GetEffect

func (x *Permission) GetEffect() EffectType

func (*Permission) GetId

func (x *Permission) GetId() string

func (*Permission) GetLabelKey

func (x *Permission) GetLabelKey() string

func (*Permission) GetLabelValues

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

func (*Permission) GetMatchAll

func (x *Permission) GetMatchAll() bool

func (*Permission) GetResourceName

func (x *Permission) GetResourceName() string

func (*Permission) GetRoleId

func (x *Permission) GetRoleId() string

func (*Permission) GetScope

func (x *Permission) GetScope() string

func (*Permission) GetServiceId

func (x *Permission) GetServiceId() string

func (*Permission) ID

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

ID 计算唯一ID

func (*Permission) MatchLabel

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

MatchLabel 匹配Label

func (*Permission) MatchResource

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

MatchResource 检测资源是否匹配

func (*Permission) ProtoMessage

func (*Permission) ProtoMessage()

func (*Permission) ProtoReflect

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

func (*Permission) Reset

func (x *Permission) Reset()

func (*Permission) String

func (x *Permission) String() string

type PermissionSet

type PermissionSet struct {

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

PermissionSet 用户列表

func NewPermissionSet

func NewPermissionSet() *PermissionSet

NewPermissionSet todo

func (*PermissionSet) Add

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

Add todo

func (*PermissionSet) Descriptor deprecated

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

Deprecated: Use PermissionSet.ProtoReflect.Descriptor instead.

func (*PermissionSet) GetItems

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

func (*PermissionSet) GetTotal

func (x *PermissionSet) GetTotal() int64

func (*PermissionSet) ProtoMessage

func (*PermissionSet) ProtoMessage()

func (*PermissionSet) ProtoReflect

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

func (*PermissionSet) Reset

func (x *PermissionSet) Reset()

func (*PermissionSet) String

func (x *PermissionSet) String() string

type QueryPermissionRequest

type QueryPermissionRequest struct {

	// @gotags: bson:"page" json:"page"
	Page *request.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page" bson:"page"`
	// @gotags: json:"role_id" validate:"required,lte=64"
	RoleId string `protobuf:"bytes,2,opt,name=role_id,json=roleId,proto3" json:"role_id" validate:"required,lte=64"`
	// @gotags: json:"skip_itmes"
	SkipItmes bool `protobuf:"varint,3,opt,name=skip_itmes,json=skipItmes,proto3" json:"skip_itmes"`
	// contains filtered or unexported fields
}

func NewQueryPermissionRequest

func NewQueryPermissionRequest(pageReq *request.PageRequest) *QueryPermissionRequest

NewQueryPermissionRequest todo

func NewQueryPermissionRequestFromHTTP

func NewQueryPermissionRequestFromHTTP(r *http.Request) *QueryPermissionRequest

NewQueryPermissionRequestFromHTTP 列表查询请求

func (*QueryPermissionRequest) Descriptor deprecated

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

Deprecated: Use QueryPermissionRequest.ProtoReflect.Descriptor instead.

func (*QueryPermissionRequest) GetPage

func (*QueryPermissionRequest) GetRoleId

func (x *QueryPermissionRequest) GetRoleId() string

func (*QueryPermissionRequest) GetSkipItmes

func (x *QueryPermissionRequest) GetSkipItmes() bool

func (*QueryPermissionRequest) ProtoMessage

func (*QueryPermissionRequest) ProtoMessage()

func (*QueryPermissionRequest) ProtoReflect

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

func (*QueryPermissionRequest) Reset

func (x *QueryPermissionRequest) Reset()

func (*QueryPermissionRequest) String

func (x *QueryPermissionRequest) String() string

func (*QueryPermissionRequest) Validate

func (req *QueryPermissionRequest) Validate() error

type QueryRoleRequest

type QueryRoleRequest struct {

	// @gotags: json:"page"
	Page *request.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page"`
	// @gotags: json:"type"
	Type RoleType `protobuf:"varint,2,opt,name=type,proto3,enum=infraboard.keyauth.role.RoleType" json:"type"`
	// @gotags: json:"domain"
	Domain string `protobuf:"bytes,3,opt,name=domain,proto3" json:"domain"`
	// contains filtered or unexported fields
}

QueryRoleRequest 列表查询

func NewQueryRoleRequest

func NewQueryRoleRequest(pageReq *request.PageRequest) *QueryRoleRequest

NewQueryRoleRequest 列表查询请求

func NewQueryRoleRequestFromHTTP

func NewQueryRoleRequestFromHTTP(r *http.Request) *QueryRoleRequest

NewQueryRoleRequestFromHTTP 列表查询请求

func (*QueryRoleRequest) Descriptor deprecated

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

Deprecated: Use QueryRoleRequest.ProtoReflect.Descriptor instead.

func (*QueryRoleRequest) GetDomain

func (x *QueryRoleRequest) GetDomain() string

func (*QueryRoleRequest) GetPage

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

func (*QueryRoleRequest) GetType

func (x *QueryRoleRequest) GetType() RoleType

func (*QueryRoleRequest) ProtoMessage

func (*QueryRoleRequest) ProtoMessage()

func (*QueryRoleRequest) ProtoReflect

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

func (*QueryRoleRequest) Reset

func (x *QueryRoleRequest) Reset()

func (*QueryRoleRequest) String

func (x *QueryRoleRequest) String() string

func (*QueryRoleRequest) Validate

func (req *QueryRoleRequest) Validate() error

Validate todo

type RemovePermissionFromRoleRequest

type RemovePermissionFromRoleRequest struct {

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

func NewRemovePermissionFromRoleRequest

func NewRemovePermissionFromRoleRequest() *RemovePermissionFromRoleRequest

NewRemovePermissionFromRoleRequest todo

func (*RemovePermissionFromRoleRequest) Descriptor deprecated

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

Deprecated: Use RemovePermissionFromRoleRequest.ProtoReflect.Descriptor instead.

func (*RemovePermissionFromRoleRequest) GetPermissionId

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

func (*RemovePermissionFromRoleRequest) GetRemoveAll

func (x *RemovePermissionFromRoleRequest) GetRemoveAll() bool

func (*RemovePermissionFromRoleRequest) GetRoleId

func (x *RemovePermissionFromRoleRequest) GetRoleId() string

func (*RemovePermissionFromRoleRequest) ProtoMessage

func (*RemovePermissionFromRoleRequest) ProtoMessage()

func (*RemovePermissionFromRoleRequest) ProtoReflect

func (*RemovePermissionFromRoleRequest) Reset

func (*RemovePermissionFromRoleRequest) String

func (*RemovePermissionFromRoleRequest) Validate

func (req *RemovePermissionFromRoleRequest) Validate() error

type Role

type Role struct {

	// 角色ID
	// @gotags: bson:"_id" json:"id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"`
	// 创建时间
	// @gotags: bson:"create_at" json:"create_at"
	CreateAt int64 `protobuf:"varint,2,opt,name=create_at,json=createAt,proto3" json:"create_at" bson:"create_at"`
	// 更新时间
	// @gotags: bson:"update_at" json:"update_at"
	UpdateAt int64 `protobuf:"varint,3,opt,name=update_at,json=updateAt,proto3" json:"update_at" bson:"update_at"`
	// 角色所属域
	// @gotags: bson:"domain" json:"domain"
	Domain string `protobuf:"bytes,4,opt,name=domain,proto3" json:"domain" bson:"domain"`
	// 创建人
	// @gotags: bson:"creater" json:"creater"
	Creater string `protobuf:"bytes,5,opt,name=creater,proto3" json:"creater" bson:"creater"`
	// 角色类型
	// @gotags: bson:"type" json:"type"
	Type RoleType `protobuf:"varint,6,opt,name=type,proto3,enum=infraboard.keyauth.role.RoleType" json:"type" bson:"type"`
	// 应用名称
	// @gotags: bson:"name" json:"name"
	Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name" bson:"name"`
	// 应用简单的描述
	// @gotags: bson:"description" json:"description"
	Description string `protobuf:"bytes,8,opt,name=description,proto3" json:"description" bson:"description"`
	// 角色关联的一些额外的meta信息, 比如前端视图
	// @gotags: bson:"meta" json:"meta"
	Meta map[string]string `` /* 152-byte string literal not displayed */
	// 读权限
	// @gotags: bson:"-" json:"permissions,omitempty"
	Permissions []*Permission `protobuf:"bytes,9,rep,name=permissions,proto3" json:"permissions,omitempty" bson:"-"`
	// 范围, 角色范围限制, 由策略引擎动态补充
	// @gotags: bson:"-" json:"scope"
	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(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

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

Deprecated: Use Role.ProtoReflect.Descriptor instead.

func (*Role) GetCreateAt

func (x *Role) GetCreateAt() int64

func (*Role) GetCreater

func (x *Role) GetCreater() string

func (*Role) GetDescription

func (x *Role) GetDescription() string

func (*Role) GetDomain

func (x *Role) GetDomain() string

func (*Role) GetId

func (x *Role) GetId() string

func (*Role) GetMeta

func (x *Role) GetMeta() map[string]string

func (*Role) GetName

func (x *Role) GetName() string

func (*Role) GetPermissions

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

func (*Role) GetScope

func (x *Role) GetScope() string

func (*Role) GetType

func (x *Role) GetType() RoleType

func (*Role) GetUpdateAt

func (x *Role) GetUpdateAt() int64

func (*Role) HasPermission

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

HasPermission 权限判断

func (*Role) ProtoMessage

func (*Role) ProtoMessage()

func (*Role) ProtoReflect

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

func (*Role) Reset

func (x *Role) Reset()

func (*Role) String

func (x *Role) String() string

type RoleType

type RoleType int32

RoleType 角色

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

func ParseRoleTypeFromString

func ParseRoleTypeFromString(str string) (RoleType, error)

ParseRoleTypeFromString Parse RoleType from string

func (RoleType) Descriptor

func (RoleType) Descriptor() protoreflect.EnumDescriptor

func (RoleType) Enum

func (x RoleType) Enum() *RoleType

func (RoleType) EnumDescriptor deprecated

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

Deprecated: Use RoleType.Descriptor instead.

func (RoleType) Equal

func (t RoleType) Equal(target RoleType) bool

Equal type compare

func (RoleType) IsIn

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

IsIn todo

func (RoleType) MarshalJSON

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

MarshalJSON todo

func (RoleType) Number

func (x RoleType) Number() protoreflect.EnumNumber

func (RoleType) String

func (x RoleType) String() string

func (RoleType) Type

func (*RoleType) UnmarshalJSON

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

UnmarshalJSON todo

type ServiceClient

type ServiceClient 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)
}

ServiceClient is the client API for Service 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 NewServiceClient

func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient

type ServiceServer

type ServiceServer 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
}

ServiceServer is the server API for Service service. All implementations must embed UnimplementedServiceServer for forward compatibility

type Set

type Set struct {

	// @gotags: bson:"total" json:"total"
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total" bson:"total"`
	// @gotags: bson:"items" json:"items"
	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

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

Deprecated: Use Set.ProtoReflect.Descriptor instead.

func (*Set) GetItems

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

func (*Set) GetTotal

func (x *Set) GetTotal() int64

func (*Set) HasPermission

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

HasPermission todo

func (*Set) Len

func (s *Set) Len() int

func (*Set) Permissions

func (s *Set) Permissions() *PermissionSet

Permissions todo

func (*Set) ProtoMessage

func (*Set) ProtoMessage()

func (*Set) ProtoReflect

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

func (*Set) Reset

func (x *Set) Reset()

func (*Set) RoleNames

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

func (*Set) String

func (x *Set) String() string

type UnimplementedServiceServer

type UnimplementedServiceServer struct {
}

UnimplementedServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedServiceServer) AddPermissionToRole

func (UnimplementedServiceServer) CreateRole

func (UnimplementedServiceServer) DeleteRole

func (UnimplementedServiceServer) DescribePermission

func (UnimplementedServiceServer) DescribeRole

func (UnimplementedServiceServer) QueryPermission

func (UnimplementedServiceServer) QueryRole

func (UnimplementedServiceServer) RemovePermissionFromRole

func (UnimplementedServiceServer) UpdatePermission

type UnsafeServiceServer

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

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

type UpdatePermissionRequest

type UpdatePermissionRequest struct {

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

func NewUpdatePermissionRequest

func NewUpdatePermissionRequest() *UpdatePermissionRequest

func (*UpdatePermissionRequest) Descriptor deprecated

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

Deprecated: Use UpdatePermissionRequest.ProtoReflect.Descriptor instead.

func (*UpdatePermissionRequest) GetId

func (x *UpdatePermissionRequest) GetId() string

func (*UpdatePermissionRequest) GetLabelKey

func (x *UpdatePermissionRequest) GetLabelKey() string

func (*UpdatePermissionRequest) GetLabelValues

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

func (*UpdatePermissionRequest) GetMatchAll

func (x *UpdatePermissionRequest) GetMatchAll() bool

func (*UpdatePermissionRequest) ProtoMessage

func (*UpdatePermissionRequest) ProtoMessage()

func (*UpdatePermissionRequest) ProtoReflect

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

func (*UpdatePermissionRequest) Reset

func (x *UpdatePermissionRequest) Reset()

func (*UpdatePermissionRequest) String

func (x *UpdatePermissionRequest) String() string

func (*UpdatePermissionRequest) Validate

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