role

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Artistic-2.0 Imports: 12 Imported by: 0

README

角色管理

role_name---> resource, action

Documentation

Index

Constants

View Source
const (
	AppName = "role"
)

Variables

View Source
var File_apps_role_pb_role_proto protoreflect.FileDescriptor
View Source
var RPC_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "keyauth.role.RPC",
	HandlerType: (*RPCServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "QueryRole",
			Handler:    _RPC_QueryRole_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apps/role/pb/role.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 added in v0.0.12

func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer)

Types

type CreateRoleRequest

type CreateRoleRequest struct {

	// 角色名称
	// @gotags: json:"name" bson:"name"
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name" bson:"name"`
	// 角色标识
	// @gotags: json:"description" bson:"description"
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description" bson:"description"`
	// 角色的权限
	// @gotags: json:"permissions" bson:"permissions"
	Permissions []*Permission `protobuf:"bytes,3,rep,name=permissions,proto3" json:"permissions" bson:"permissions"`
	// 角色的一些额外属性
	// @gotags: json:"meta" bson:"meta"
	Meta map[string]string `` /* 151-byte string literal not displayed */
	// contains filtered or unexported fields
}

func NewCreateRoleRequest added in v0.0.12

func NewCreateRoleRequest() *CreateRoleRequest

func (*CreateRoleRequest) Descriptor deprecated

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

Deprecated: Use CreateRoleRequest.ProtoReflect.Descriptor instead.

func (*CreateRoleRequest) GetDescription

func (x *CreateRoleRequest) GetDescription() 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() []*Permission

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 added in v0.0.12

func (req *CreateRoleRequest) Validate() error

type Featrue

type Featrue struct {

	// 资源名称
	// @gotags: json:"resource" bson:"resource"
	Resource string `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource" bson:"resource"`
	// 资源操作
	// @gotags: json:"action" bson:"action"
	Action string `protobuf:"bytes,4,opt,name=action,proto3" json:"action" bson:"action"`
	// contains filtered or unexported fields
}

func (*Featrue) Descriptor deprecated

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

Deprecated: Use Featrue.ProtoReflect.Descriptor instead.

func (*Featrue) GetAction

func (x *Featrue) GetAction() string

func (*Featrue) GetResource

func (x *Featrue) GetResource() string

func (*Featrue) ProtoMessage

func (*Featrue) ProtoMessage()

func (*Featrue) ProtoReflect

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

func (*Featrue) Reset

func (x *Featrue) Reset()

func (*Featrue) String

func (x *Featrue) String() string

type Permission

type Permission struct {

	// 服务名称
	// @gotags: json:"service" bson:"service"
	Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service" bson:"service"`
	// 是否允许访问所有功能
	// @gotags: json:"allow_all" bson:"allow_all
	AllowAll bool `protobuf:"varint,3,opt,name=allow_all,json=allowAll,proto3" json:"allow_all"`
	// 服务功能
	// @gotags: json:"featrues" bson:"featrues"
	Featrues []*Featrue `protobuf:"bytes,2,rep,name=featrues,proto3" json:"featrues" bson:"featrues"`
	// contains filtered or unexported fields
}

那个服务 的哪些权限

func (*Permission) Descriptor deprecated

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

Deprecated: Use Permission.ProtoReflect.Descriptor instead.

func (*Permission) GetAllowAll added in v0.1.0

func (x *Permission) GetAllowAll() bool

func (*Permission) GetFeatrues

func (x *Permission) GetFeatrues() []*Featrue

func (*Permission) GetService

func (x *Permission) GetService() string

func (*Permission) HasPermission added in v0.0.12

func (p *Permission) HasPermission(req *PermissionRequest) bool

判断角色里面的Permission是不是有权限

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 PermissionRequest added in v0.0.12

type PermissionRequest struct {

	// 服务名称
	// @gotags: json:"service"
	Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service"`
	// 资源名称
	// @gotags: json:"resource"
	Resource string `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource"`
	// 资源操作
	// @gotags: json:"action"
	Action string `protobuf:"bytes,3,opt,name=action,proto3" json:"action"`
	// contains filtered or unexported fields
}

func NewPermissionRequest added in v0.0.12

func NewPermissionRequest(service, resource, action string) *PermissionRequest

func (*PermissionRequest) Descriptor deprecated added in v0.0.12

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

Deprecated: Use PermissionRequest.ProtoReflect.Descriptor instead.

func (*PermissionRequest) GetAction added in v0.0.12

func (x *PermissionRequest) GetAction() string

func (*PermissionRequest) GetResource added in v0.0.12

func (x *PermissionRequest) GetResource() string

func (*PermissionRequest) GetService added in v0.0.12

func (x *PermissionRequest) GetService() string

func (*PermissionRequest) ProtoMessage added in v0.0.12

func (*PermissionRequest) ProtoMessage()

func (*PermissionRequest) ProtoReflect added in v0.0.12

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

func (*PermissionRequest) Reset added in v0.0.12

func (x *PermissionRequest) Reset()

func (*PermissionRequest) String added in v0.0.12

func (x *PermissionRequest) String() string

type QueryRoleRequest added in v0.0.12

type QueryRoleRequest struct {

	// 分页参数
	// @gotags: json:"page"
	Page *request.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page"`
	// 根据role名称批量获取role对象
	// @gotags: json:"role_names"
	RoleNames []string `protobuf:"bytes,2,rep,name=role_names,json=roleNames,proto3" json:"role_names"`
	// contains filtered or unexported fields
}

func NewQueryRoleRequestWithName added in v0.0.12

func NewQueryRoleRequestWithName(names []string) *QueryRoleRequest

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

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

Deprecated: Use QueryRoleRequest.ProtoReflect.Descriptor instead.

func (*QueryRoleRequest) GetPage added in v0.0.12

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

func (*QueryRoleRequest) GetRoleNames added in v0.0.12

func (x *QueryRoleRequest) GetRoleNames() []string

func (*QueryRoleRequest) ProtoMessage added in v0.0.12

func (*QueryRoleRequest) ProtoMessage()

func (*QueryRoleRequest) ProtoReflect added in v0.0.12

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

func (*QueryRoleRequest) Reset added in v0.0.12

func (x *QueryRoleRequest) Reset()

func (*QueryRoleRequest) String added in v0.0.12

func (x *QueryRoleRequest) String() string

type RPCClient added in v0.0.12

type RPCClient interface {
	// 服务功能注册
	QueryRole(ctx context.Context, in *QueryRoleRequest, opts ...grpc.CallOption) (*RoleSet, 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 added in v0.0.12

func NewRPCClient(cc grpc.ClientConnInterface) RPCClient

type RPCServer added in v0.0.12

type RPCServer interface {
	// 服务功能注册
	QueryRole(context.Context, *QueryRoleRequest) (*RoleSet, error)
	// contains filtered or unexported methods
}

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

type Role

type Role struct {

	// 角色id
	// @gotags: json:"id" bson:"_id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"`
	// 角色创建时间
	// @gotags: json:"name" bson:"create_at"
	CreateAt int64 `protobuf:"varint,2,opt,name=create_at,json=createAt,proto3" json:"name" bson:"create_at"`
	// 角色名称
	// @gotags: json:"spec" bson:"spec"
	Spec *CreateRoleRequest `protobuf:"bytes,3,opt,name=spec,proto3" json:"spec" bson:"spec"`
	// contains filtered or unexported fields
}

func NewDefaultRole added in v0.0.12

func NewDefaultRole() *Role

func NewRole added in v0.0.12

func NewRole(req *CreateRoleRequest) *Role

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

func (x *Role) GetSpec() *CreateRoleRequest

func (*Role) HasPermission added in v0.0.12

func (r *Role) HasPermission(req *PermissionRequest) bool

单个角色如何判断有没有权限

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 added in v0.0.12

type RoleSet struct {

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

func NewRoleSet added in v0.0.12

func NewRoleSet() *RoleSet

func (*RoleSet) Add added in v0.0.12

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

func (*RoleSet) Descriptor deprecated added in v0.0.12

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

Deprecated: Use RoleSet.ProtoReflect.Descriptor instead.

func (*RoleSet) GetItems added in v0.0.12

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

func (*RoleSet) GetTotal added in v0.0.12

func (x *RoleSet) GetTotal() int64

func (*RoleSet) HasPermission added in v0.0.12

func (s *RoleSet) HasPermission(req *PermissionRequest) (bool, *Role)

判断一组角色是不是有权限

func (*RoleSet) ProtoMessage added in v0.0.12

func (*RoleSet) ProtoMessage()

func (*RoleSet) ProtoReflect added in v0.0.12

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

func (*RoleSet) Reset added in v0.0.12

func (x *RoleSet) Reset()

func (*RoleSet) String added in v0.0.12

func (x *RoleSet) String() string

type Service added in v0.0.12

type Service interface {
	CreateRole(context.Context, *CreateRoleRequest) (*Role, error)
	RPCServer
}

type UnimplementedRPCServer added in v0.0.12

type UnimplementedRPCServer struct {
}

UnimplementedRPCServer must be embedded to have forward compatible implementations.

func (UnimplementedRPCServer) QueryRole added in v0.0.12

type UnsafeRPCServer added in v0.0.12

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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