role

package
v1.0.33 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MulanPSL-2.0 Imports: 16 Imported by: 0

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.apps.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 (c *CreateRoleRequest) Validate() error

type Feature

type Feature 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 (*Feature) Descriptor deprecated

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

Deprecated: Use Feature.ProtoReflect.Descriptor instead.

func (*Feature) GetAction

func (x *Feature) GetAction() string

func (*Feature) GetResource

func (x *Feature) GetResource() string

func (*Feature) ProtoMessage

func (*Feature) ProtoMessage()

func (*Feature) ProtoReflect

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

func (*Feature) Reset

func (x *Feature) Reset()

func (*Feature) String

func (x *Feature) 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:"features" bson:"features"
	Features []*Feature `protobuf:"bytes,2,rep,name=features,proto3" json:"features" bson:"features"`
	// 是否允许访问所有功能
	// @gotags: json:"allow_all" bson:"allow_all"
	AllowAll bool `protobuf:"varint,3,opt,name=allow_all,json=allowAll,proto3" json:"allow_all" bson:"allow_all"`
	// 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 v1.0.32

func (x *Permission) GetAllowAll() bool

func (*Permission) GetFeatures

func (x *Permission) GetFeatures() []*Feature

func (*Permission) GetService

func (x *Permission) GetService() string

func (*Permission) Has

func (p *Permission) Has(permission *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:"resource"
	Resource string `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource"`
	//	服务
	//
	// @gotags: json:"service"
	Service string `protobuf:"bytes,2,opt,name=service,proto3" json:"service"`
	//	操作
	//
	// @gotags: json:"action"
	Action string `protobuf:"bytes,3,opt,name=action,proto3" json:"action"`
	// contains filtered or unexported fields
}

func NewCheckPermission

func NewCheckPermission(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 *page.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 NewQueryRoleRequestFromHTTP added in v1.0.14

func NewQueryRoleRequestFromHTTP(r *http.Request) *QueryRoleRequest
func NewQueryRoleRequest() *QueryRoleRequest {
	return &QueryRoleRequest{
		Page: page.NewDefaultPageRequest(),
	}
}

func NewQueryRoleRequestWithNames

func NewQueryRoleRequestWithNames(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() *page.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 {

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

func NewDefaultRole

func NewDefaultRole() *Role

func NewRole

func NewRole(request *CreateRoleRequest) (*Role, error)

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 (s *Role) HasPermission(permission *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 {

	//	总数
	//
	// @gotags: json:"total"
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total"`
	//	角色
	//
	// @gotags: json:"items"
	Items []*Role `protobuf:"bytes,2,rep,name=items,proto3" json:"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(permission *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 {

	// RPCServer绑定的是可以不用认证的方法
	RPCServer
	CreateRole(ctx context.Context, request *CreateRoleRequest) (*Role, error)
}

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