role

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName = "role"
)
View Source
const (
	RPC_QueryRole_FullMethodName = "/keyauth_g7.role.RPC/QueryRole"
)

Variables

View Source
var File_apps_role_pb_role_proto protoreflect.FileDescriptor
View Source
var RPC_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "keyauth_g7.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

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

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

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.0.7

func (x *Permission) GetAllowAll() bool

func (*Permission) GetFeatrues

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

func (*Permission) GetService

func (x *Permission) GetService() string

func (*Permission) HasPermission

func (p *Permission) HasPermission(req *PermissionRequest) 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 PermissionRequest

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

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

func (*PermissionRequest) Descriptor deprecated

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

Deprecated: Use PermissionRequest.ProtoReflect.Descriptor instead.

func (*PermissionRequest) GetAction

func (x *PermissionRequest) GetAction() string

func (*PermissionRequest) GetResource

func (x *PermissionRequest) GetResource() string

func (*PermissionRequest) GetService

func (x *PermissionRequest) GetService() string

func (*PermissionRequest) ProtoMessage

func (*PermissionRequest) ProtoMessage()

func (*PermissionRequest) ProtoReflect

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

func (*PermissionRequest) Reset

func (x *PermissionRequest) Reset()

func (*PermissionRequest) String

func (x *PermissionRequest) String() string

type QueryRoleRequest

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

func NewQueryRoleRequestWithName(names []string) *QueryRoleRequest

func (*QueryRoleRequest) Descriptor deprecated

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

Deprecated: Use QueryRoleRequest.ProtoReflect.Descriptor instead.

func (*QueryRoleRequest) GetPage

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

func (*QueryRoleRequest) GetRoleNames

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

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

type RPCClient

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

func NewRPCClient(cc grpc.ClientConnInterface) RPCClient

type RPCServer

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

func NewDefaultRole() *Role

func NewRole

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

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

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

func NewRoleSet() *RoleSet

func (*RoleSet) Add

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

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

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

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 Service

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

type UnimplementedRPCServer

type UnimplementedRPCServer struct {
}

UnimplementedRPCServer must be embedded to have forward compatible implementations.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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