role

package
v0.0.0-...-055c0a6 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2022 License: MulanPSL-2.0 Imports: 18 Imported by: 0

README

角色管理

Documentation

Index

Constants

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

Variables

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 (
	RoleType_name = map[int32]string{
		0: "BUILDIN",
		1: "GLOBAL",
		2: "CUSTOM",
	}
	RoleType_value = map[string]int32{
		"BUILDIN": 0,
		"GLOBAL":  1,
		"CUSTOM":  2,
	}
)

Enum value maps for RoleType.

View Source
var File_apps_role_pb_permission_proto protoreflect.FileDescriptor
View Source
var File_apps_role_pb_role_proto protoreflect.FileDescriptor
View Source
var File_apps_role_pb_rpc_proto protoreflect.FileDescriptor
View Source
var RPC_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "devcloud.mcenter.role.RPC",
	HandlerType: (*RPCServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "QueryRole",
			Handler:    _RPC_QueryRole_Handler,
		},
		{
			MethodName: "DescribeRole",
			Handler:    _RPC_DescribeRole_Handler,
		},
		{
			MethodName: "QueryPermission",
			Handler:    _RPC_QueryPermission_Handler,
		},
		{
			MethodName: "DescribePermission",
			Handler:    _RPC_DescribePermission_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apps/role/pb/rpc.proto",
}

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

Functions

func RegisterRPCServer

func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer)

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 []*Spec `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() []*Spec

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 CreateRoleRequest

type CreateRoleRequest struct {

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

func (x *CreateRoleRequest) GetSpecs() []*Spec

func (*CreateRoleRequest) GetType

func (x *CreateRoleRequest) GetType() RoleType

func (*CreateRoleRequest) ProtoMessage

func (*CreateRoleRequest) ProtoMessage()

func (*CreateRoleRequest) ProtoReflect

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

func (*CreateRoleRequest) Reset

func (x *CreateRoleRequest) Reset()

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 (*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

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=devcloud.mcenter.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"`
	// 创建时间
	// @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"`
	// 角色Id
	// @gotags: bson:"role_id" json:"role_id"
	RoleId string `protobuf:"bytes,3,opt,name=role_id,json=roleId,proto3" json:"role_id" bson:"role_id"`
	// 权限具体定义, 那个服务 的那个接口
	// @gotags: bson:"spec" json:"spec"
	Spec *Spec `protobuf:"bytes,4,opt,name=spec,proto3" json:"spec" bson:"spec"`
	// 范围, 角色范围限制, 由策略引擎动态补充
	// @gotags: bson:"-" json:"scope"
	Scope string `protobuf:"bytes,5,opt,name=scope,proto3" json:"scope" bson:"-"`
	// contains filtered or unexported fields
}

Permission 权限

func NewDeaultPermission

func NewDeaultPermission() *Permission

func NewPermission

func NewPermission(roleId string, perms []*Spec) []*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) GetId

func (x *Permission) GetId() string

func (*Permission) GetRoleId

func (x *Permission) GetRoleId() string

func (*Permission) GetScope

func (x *Permission) GetScope() string

func (*Permission) GetSpec

func (x *Permission) GetSpec() *Spec

func (*Permission) HasPerm

func (p *Permission) HasPerm(ed *endpoint.Endpoint) bool

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: json:"page"
	Page *request.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page"`
	// @gotags: json:"namespace"
	Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace"`
	// @gotags: json:"username"
	Username string `protobuf:"bytes,3,opt,name=username,proto3" json:"username"`
	// 查询角色权限
	// @gotags: json:"role_id"
	RoleId string `protobuf:"bytes,4,opt,name=role_id,json=roleId,proto3" json:"role_id"`
	// 忽略数据
	// @gotags: json:"skip_items"
	SkipItems bool `protobuf:"varint,5,opt,name=skip_items,json=skipItems,proto3" json:"skip_items"`
	// contains filtered or unexported fields
}

QueryPermissionRequest 查询用户权限

func NewQueryPermissionRequest

func NewQueryPermissionRequest() *QueryPermissionRequest

NewQueryPermissionRequest todo

func (*QueryPermissionRequest) Descriptor deprecated

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

Deprecated: Use QueryPermissionRequest.ProtoReflect.Descriptor instead.

func (*QueryPermissionRequest) GetNamespace

func (x *QueryPermissionRequest) GetNamespace() string

func (*QueryPermissionRequest) GetPage

func (*QueryPermissionRequest) GetRoleId

func (x *QueryPermissionRequest) GetRoleId() string

func (*QueryPermissionRequest) GetSkipItems

func (x *QueryPermissionRequest) GetSkipItems() bool

func (*QueryPermissionRequest) GetUsername

func (x *QueryPermissionRequest) GetUsername() string

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=devcloud.mcenter.role.RoleType,oneof" json:"type"`
	// 属于那个域
	// @gotags: json:"domain"
	Domain string `protobuf:"bytes,3,opt,name=domain,proto3" json:"domain"`
	// 是否需要查询permission
	// @gotags: json:"with_permission"
	WithPermission bool `protobuf:"varint,4,opt,name=with_permission,json=withPermission,proto3" json:"with_permission"`
	// contains filtered or unexported fields
}

QueryRoleRequest 列表查询

func NewQueryRoleRequest

func NewQueryRoleRequest() *QueryRoleRequest

NewQueryRoleRequest 列表查询请求

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) GetWithPermission

func (x *QueryRoleRequest) GetWithPermission() bool

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 RPCClient

type RPCClient interface {
	// 角色本身查询
	QueryRole(ctx context.Context, in *QueryRoleRequest, opts ...grpc.CallOption) (*RoleSet, error)
	DescribeRole(ctx context.Context, in *DescribeRoleRequest, 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)
}

RPCClient is the client API for RPC 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 NewRPCClient

func NewRPCClient(cc grpc.ClientConnInterface) RPCClient

type RPCServer

type RPCServer interface {
	// 角色本身查询
	QueryRole(context.Context, *QueryRoleRequest) (*RoleSet, error)
	DescribeRole(context.Context, *DescribeRoleRequest) (*Role, error)
	// 权限的查询
	QueryPermission(context.Context, *QueryPermissionRequest) (*PermissionSet, error)
	DescribePermission(context.Context, *DescribePermissionRequest) (*Permission, error)
	// contains filtered or unexported methods
}

RPCServer is the server API for RPC service. All implementations must embed UnimplementedRPCServer for forward compatibility

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:"-" json:"scope"
	Scope string `protobuf:"bytes,4,opt,name=scope,proto3" json:"scope" bson:"-"`
	// 角色描述信息
	// @gotags: bson:"spec" json:"spec"
	Spec *CreateRoleRequest `protobuf:"bytes,5,opt,name=spec,proto3" json:"spec" bson:"spec"`
	// 角色描述信息, permission 是动态补充
	// @gotags: bson:"-" json:"permissions"
	Permissions []*Permission `protobuf:"bytes,6,rep,name=permissions,proto3" json:"permissions" 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) Descriptor deprecated

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

Deprecated: Use Role.ProtoReflect.Descriptor instead.

func (*Role) GetCreateAt

func (x *Role) GetCreateAt() int64

func (*Role) GetId

func (x *Role) GetId() string

func (*Role) GetPermissions

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

func (*Role) GetScope

func (x *Role) GetScope() string

func (*Role) GetSpec

func (x *Role) GetSpec() *CreateRoleRequest

func (*Role) GetUpdateAt

func (x *Role) GetUpdateAt() int64

func (*Role) HasPerm

func (r *Role) HasPerm(ed *endpoint.Endpoint) *Permission

判断该角色是否具有权限A

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 RoleSet

type RoleSet 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() *RoleSet

NewRoleSet 实例化make

func (*RoleSet) Add

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

Add todo

func (*RoleSet) Descriptor deprecated

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

Deprecated: Use RoleSet.ProtoReflect.Descriptor instead.

func (*RoleSet) GetItems

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

func (*RoleSet) GetTotal

func (x *RoleSet) GetTotal() int64

func (*RoleSet) HasPerm

func (s *RoleSet) HasPerm(ed *endpoint.Endpoint) *Permission

func (*RoleSet) ProtoMessage

func (*RoleSet) ProtoMessage()

func (*RoleSet) ProtoReflect

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

func (*RoleSet) Reset

func (x *RoleSet) Reset()

func (*RoleSet) String

func (x *RoleSet) String() string

type RoleType

type RoleType int32

RoleType 角色

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

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 Spec

type Spec struct {

	// 创建人
	// @gotags: bson:"create_by" json:"create_by"
	CreateBy string `protobuf:"bytes,1,opt,name=create_by,json=createBy,proto3" json:"create_by" bson:"create_by"`
	// 权限描述
	// @gotags: bson:"desc" json:"desc"
	Desc string `protobuf:"bytes,2,opt,name=desc,proto3" json:"desc" bson:"desc"`
	// 效力
	// @gotags: bson:"effect" json:"effect"
	Effect EffectType `protobuf:"varint,4,opt,name=effect,proto3,enum=devcloud.mcenter.role.EffectType" json:"effect" bson:"effect"`
	// 服务ID
	// @gotags: bson:"service_id" json:"service_id"
	ServiceId string `protobuf:"bytes,5,opt,name=service_id,json=serviceId,proto3" json:"service_id" bson:"service_id"`
	// 资源列表
	// @gotags: bson:"resource_name" json:"resource_name"
	ResourceName string `protobuf:"bytes,6,opt,name=resource_name,json=resourceName,proto3" json:"resource_name" bson:"resource_name"`
	// 维度, action
	// @gotags: bson:"label_key" json:"label_key"
	LabelKey string `protobuf:"bytes,7,opt,name=label_key,json=labelKey,proto3" json:"label_key" bson:"label_key"`
	// 适配所有值
	// @gotags: bson:"match_all" json:"match_all"
	MatchAll bool `protobuf:"varint,8,opt,name=match_all,json=matchAll,proto3" json:"match_all" bson:"match_all"`
	// 标识值, [list, create, update, get]
	// @gotags: bson:"label_values" json:"label_values"
	LabelValues []string `protobuf:"bytes,9,rep,name=label_values,json=labelValues,proto3" json:"label_values" bson:"label_values"`
	// contains filtered or unexported fields
}

用户对那个服务的那个接口 由访问权限 用户的功能的直接绑定? 后面服务更新,添加一个接口 如何才能解构 功能与权限的直接绑定? Lable, 采用标签进行解构 注册上来一个功能条目: 服务 接口 resource:a, action:list , role: permisson: a:list 由收起(a:*)

func (*Spec) Descriptor deprecated

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

Deprecated: Use Spec.ProtoReflect.Descriptor instead.

func (*Spec) GetCreateBy

func (x *Spec) GetCreateBy() string

func (*Spec) GetDesc

func (x *Spec) GetDesc() string

func (*Spec) GetEffect

func (x *Spec) GetEffect() EffectType

func (*Spec) GetLabelKey

func (x *Spec) GetLabelKey() string

func (*Spec) GetLabelValues

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

func (*Spec) GetMatchAll

func (x *Spec) GetMatchAll() bool

func (*Spec) GetResourceName

func (x *Spec) GetResourceName() string

func (*Spec) GetServiceId

func (x *Spec) GetServiceId() string

func (*Spec) HashID

func (req *Spec) HashID(roleId string) string

cmdb host [create, list]

func (*Spec) ProtoMessage

func (*Spec) ProtoMessage()

func (*Spec) ProtoReflect

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

func (*Spec) Reset

func (x *Spec) Reset()

func (*Spec) String

func (x *Spec) String() string

type UnimplementedRPCServer

type UnimplementedRPCServer struct {
}

UnimplementedRPCServer must be embedded to have forward compatible implementations.

func (UnimplementedRPCServer) DescribePermission

func (UnimplementedRPCServer) DescribeRole

func (UnimplementedRPCServer) QueryPermission

func (UnimplementedRPCServer) QueryRole

type UnsafeRPCServer

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

UnsafeRPCServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RPCServer 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 (*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