diff --git a/gen/go/rbac.pb.go b/gen/go/rbac.pb.go new file mode 100644 index 0000000..0bc3ee8 --- /dev/null +++ b/gen/go/rbac.pb.go @@ -0,0 +1,372 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc v3.21.12 +// source: rbac.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type GetAllPermissionsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + SessionId string `protobuf:"bytes,2,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetAllPermissionsRequest) Reset() { + *x = GetAllPermissionsRequest{} + mi := &file_rbac_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetAllPermissionsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAllPermissionsRequest) ProtoMessage() {} + +func (x *GetAllPermissionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_rbac_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetAllPermissionsRequest.ProtoReflect.Descriptor instead. +func (*GetAllPermissionsRequest) Descriptor() ([]byte, []int) { + return file_rbac_proto_rawDescGZIP(), []int{0} +} + +func (x *GetAllPermissionsRequest) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *GetAllPermissionsRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +type GetAllPermissionsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Module string `protobuf:"bytes,4,opt,name=module,proto3" json:"module,omitempty"` + Roles []string `protobuf:"bytes,5,rep,name=roles,proto3" json:"roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetAllPermissionsResponse) Reset() { + *x = GetAllPermissionsResponse{} + mi := &file_rbac_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetAllPermissionsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAllPermissionsResponse) ProtoMessage() {} + +func (x *GetAllPermissionsResponse) ProtoReflect() protoreflect.Message { + mi := &file_rbac_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetAllPermissionsResponse.ProtoReflect.Descriptor instead. +func (*GetAllPermissionsResponse) Descriptor() ([]byte, []int) { + return file_rbac_proto_rawDescGZIP(), []int{1} +} + +func (x *GetAllPermissionsResponse) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *GetAllPermissionsResponse) GetCode() string { + if x != nil { + return x.Code + } + return "" +} + +func (x *GetAllPermissionsResponse) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *GetAllPermissionsResponse) GetModule() string { + if x != nil { + return x.Module + } + return "" +} + +func (x *GetAllPermissionsResponse) GetRoles() []string { + if x != nil { + return x.Roles + } + return nil +} + +type GetAllRolesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + SessionId string `protobuf:"bytes,2,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetAllRolesRequest) Reset() { + *x = GetAllRolesRequest{} + mi := &file_rbac_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetAllRolesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAllRolesRequest) ProtoMessage() {} + +func (x *GetAllRolesRequest) ProtoReflect() protoreflect.Message { + mi := &file_rbac_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetAllRolesRequest.ProtoReflect.Descriptor instead. +func (*GetAllRolesRequest) Descriptor() ([]byte, []int) { + return file_rbac_proto_rawDescGZIP(), []int{2} +} + +func (x *GetAllRolesRequest) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *GetAllRolesRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +type GetAllRolesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Level int32 `protobuf:"varint,3,opt,name=level,proto3" json:"level,omitempty"` + Permissions []string `protobuf:"bytes,4,rep,name=permissions,proto3" json:"permissions,omitempty"` + LdapMapping []string `protobuf:"bytes,5,rep,name=ldap_mapping,json=ldapMapping,proto3" json:"ldap_mapping,omitempty"` + Accounts []string `protobuf:"bytes,6,rep,name=accounts,proto3" json:"accounts,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetAllRolesResponse) Reset() { + *x = GetAllRolesResponse{} + mi := &file_rbac_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetAllRolesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAllRolesResponse) ProtoMessage() {} + +func (x *GetAllRolesResponse) ProtoReflect() protoreflect.Message { + mi := &file_rbac_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetAllRolesResponse.ProtoReflect.Descriptor instead. +func (*GetAllRolesResponse) Descriptor() ([]byte, []int) { + return file_rbac_proto_rawDescGZIP(), []int{3} +} + +func (x *GetAllRolesResponse) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *GetAllRolesResponse) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *GetAllRolesResponse) GetLevel() int32 { + if x != nil { + return x.Level + } + return 0 +} + +func (x *GetAllRolesResponse) GetPermissions() []string { + if x != nil { + return x.Permissions + } + return nil +} + +func (x *GetAllRolesResponse) GetLdapMapping() []string { + if x != nil { + return x.LdapMapping + } + return nil +} + +func (x *GetAllRolesResponse) GetAccounts() []string { + if x != nil { + return x.Accounts + } + return nil +} + +var File_rbac_proto protoreflect.FileDescriptor + +const file_rbac_proto_rawDesc = "" + + "\n" + + "\n" + + "rbac.proto\x12\arbac.v1\"R\n" + + "\x18GetAllPermissionsRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\tR\x06userId\x12\x1d\n" + + "\n" + + "session_id\x18\x02 \x01(\tR\tsessionId\"\x8f\x01\n" + + "\x19GetAllPermissionsResponse\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04code\x18\x02 \x01(\tR\x04code\x12 \n" + + "\vdescription\x18\x03 \x01(\tR\vdescription\x12\x16\n" + + "\x06module\x18\x04 \x01(\tR\x06module\x12\x14\n" + + "\x05roles\x18\x05 \x03(\tR\x05roles\"L\n" + + "\x12GetAllRolesRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\tR\x06userId\x12\x1d\n" + + "\n" + + "session_id\x18\x02 \x01(\tR\tsessionId\"\xb0\x01\n" + + "\x13GetAllRolesResponse\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12\x14\n" + + "\x05level\x18\x03 \x01(\x05R\x05level\x12 \n" + + "\vpermissions\x18\x04 \x03(\tR\vpermissions\x12!\n" + + "\fldap_mapping\x18\x05 \x03(\tR\vldapMapping\x12\x1a\n" + + "\baccounts\x18\x06 \x03(\tR\baccounts2\xb3\x01\n" + + "\vRbacService\x12Z\n" + + "\x11GetAllPermissions\x12!.rbac.v1.GetAllPermissionsRequest\x1a\".rbac.v1.GetAllPermissionsResponse\x12H\n" + + "\vGetAllRoles\x12\x1b.rbac.v1.GetAllRolesRequest\x1a\x1c.rbac.v1.GetAllRolesResponseB*Z(git.lendry.ru/lendry-erp/proto.git/go;pbb\x06proto3" + +var ( + file_rbac_proto_rawDescOnce sync.Once + file_rbac_proto_rawDescData []byte +) + +func file_rbac_proto_rawDescGZIP() []byte { + file_rbac_proto_rawDescOnce.Do(func() { + file_rbac_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_rbac_proto_rawDesc), len(file_rbac_proto_rawDesc))) + }) + return file_rbac_proto_rawDescData +} + +var file_rbac_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_rbac_proto_goTypes = []any{ + (*GetAllPermissionsRequest)(nil), // 0: rbac.v1.GetAllPermissionsRequest + (*GetAllPermissionsResponse)(nil), // 1: rbac.v1.GetAllPermissionsResponse + (*GetAllRolesRequest)(nil), // 2: rbac.v1.GetAllRolesRequest + (*GetAllRolesResponse)(nil), // 3: rbac.v1.GetAllRolesResponse +} +var file_rbac_proto_depIdxs = []int32{ + 0, // 0: rbac.v1.RbacService.GetAllPermissions:input_type -> rbac.v1.GetAllPermissionsRequest + 2, // 1: rbac.v1.RbacService.GetAllRoles:input_type -> rbac.v1.GetAllRolesRequest + 1, // 2: rbac.v1.RbacService.GetAllPermissions:output_type -> rbac.v1.GetAllPermissionsResponse + 3, // 3: rbac.v1.RbacService.GetAllRoles:output_type -> rbac.v1.GetAllRolesResponse + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_rbac_proto_init() } +func file_rbac_proto_init() { + if File_rbac_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_rbac_proto_rawDesc), len(file_rbac_proto_rawDesc)), + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_rbac_proto_goTypes, + DependencyIndexes: file_rbac_proto_depIdxs, + MessageInfos: file_rbac_proto_msgTypes, + }.Build() + File_rbac_proto = out.File + file_rbac_proto_goTypes = nil + file_rbac_proto_depIdxs = nil +} diff --git a/gen/go/rbac_grpc.pb.go b/gen/go/rbac_grpc.pb.go new file mode 100644 index 0000000..ebddf2f --- /dev/null +++ b/gen/go/rbac_grpc.pb.go @@ -0,0 +1,159 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.6.1 +// - protoc v3.21.12 +// source: rbac.proto + +package pb + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + RbacService_GetAllPermissions_FullMethodName = "/rbac.v1.RbacService/GetAllPermissions" + RbacService_GetAllRoles_FullMethodName = "/rbac.v1.RbacService/GetAllRoles" +) + +// RbacServiceClient is the client API for RbacService 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. +type RbacServiceClient interface { + GetAllPermissions(ctx context.Context, in *GetAllPermissionsRequest, opts ...grpc.CallOption) (*GetAllPermissionsResponse, error) + GetAllRoles(ctx context.Context, in *GetAllRolesRequest, opts ...grpc.CallOption) (*GetAllRolesResponse, error) +} + +type rbacServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewRbacServiceClient(cc grpc.ClientConnInterface) RbacServiceClient { + return &rbacServiceClient{cc} +} + +func (c *rbacServiceClient) GetAllPermissions(ctx context.Context, in *GetAllPermissionsRequest, opts ...grpc.CallOption) (*GetAllPermissionsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetAllPermissionsResponse) + err := c.cc.Invoke(ctx, RbacService_GetAllPermissions_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *rbacServiceClient) GetAllRoles(ctx context.Context, in *GetAllRolesRequest, opts ...grpc.CallOption) (*GetAllRolesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetAllRolesResponse) + err := c.cc.Invoke(ctx, RbacService_GetAllRoles_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// RbacServiceServer is the server API for RbacService service. +// All implementations must embed UnimplementedRbacServiceServer +// for forward compatibility. +type RbacServiceServer interface { + GetAllPermissions(context.Context, *GetAllPermissionsRequest) (*GetAllPermissionsResponse, error) + GetAllRoles(context.Context, *GetAllRolesRequest) (*GetAllRolesResponse, error) + mustEmbedUnimplementedRbacServiceServer() +} + +// UnimplementedRbacServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedRbacServiceServer struct{} + +func (UnimplementedRbacServiceServer) GetAllPermissions(context.Context, *GetAllPermissionsRequest) (*GetAllPermissionsResponse, error) { + return nil, status.Error(codes.Unimplemented, "method GetAllPermissions not implemented") +} +func (UnimplementedRbacServiceServer) GetAllRoles(context.Context, *GetAllRolesRequest) (*GetAllRolesResponse, error) { + return nil, status.Error(codes.Unimplemented, "method GetAllRoles not implemented") +} +func (UnimplementedRbacServiceServer) mustEmbedUnimplementedRbacServiceServer() {} +func (UnimplementedRbacServiceServer) testEmbeddedByValue() {} + +// UnsafeRbacServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to RbacServiceServer will +// result in compilation errors. +type UnsafeRbacServiceServer interface { + mustEmbedUnimplementedRbacServiceServer() +} + +func RegisterRbacServiceServer(s grpc.ServiceRegistrar, srv RbacServiceServer) { + // If the following call panics, it indicates UnimplementedRbacServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&RbacService_ServiceDesc, srv) +} + +func _RbacService_GetAllPermissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetAllPermissionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RbacServiceServer).GetAllPermissions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RbacService_GetAllPermissions_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RbacServiceServer).GetAllPermissions(ctx, req.(*GetAllPermissionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RbacService_GetAllRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetAllRolesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RbacServiceServer).GetAllRoles(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RbacService_GetAllRoles_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RbacServiceServer).GetAllRoles(ctx, req.(*GetAllRolesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// RbacService_ServiceDesc is the grpc.ServiceDesc for RbacService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var RbacService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "rbac.v1.RbacService", + HandlerType: (*RbacServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetAllPermissions", + Handler: _RbacService_GetAllPermissions_Handler, + }, + { + MethodName: "GetAllRoles", + Handler: _RbacService_GetAllRoles_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "rbac.proto", +} diff --git a/gen/rbac.ts b/gen/rbac.ts new file mode 100644 index 0000000..7838f25 --- /dev/null +++ b/gen/rbac.ts @@ -0,0 +1,76 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.11.6 +// protoc v3.21.12 +// source: rbac.proto + +/* eslint-disable */ +import type { Metadata } from "@grpc/grpc-js"; +import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices"; +import { Observable } from "rxjs"; + +export const protobufPackage = "rbac.v1"; + +export interface GetAllPermissionsRequest { + userId: string; + sessionId: string; +} + +export interface GetAllPermissionsResponse { + id: string; + code: string; + description: string; + module: string; + roles: string[]; +} + +export interface GetAllRolesRequest { + userId: string; + sessionId: string; +} + +export interface GetAllRolesResponse { + id: string; + name: string; + level: number; + permissions: string[]; + ldapMapping: string[]; + accounts: string[]; +} + +export const RBAC_V1_PACKAGE_NAME = "rbac.v1"; + +export interface RbacServiceClient { + getAllPermissions(request: GetAllPermissionsRequest, metadata?: Metadata): Observable; + + getAllRoles(request: GetAllRolesRequest, metadata?: Metadata): Observable; +} + +export interface RbacServiceController { + getAllPermissions( + request: GetAllPermissionsRequest, + metadata?: Metadata, + ): Promise | Observable | GetAllPermissionsResponse; + + getAllRoles( + request: GetAllRolesRequest, + metadata?: Metadata, + ): Promise | Observable | GetAllRolesResponse; +} + +export function RbacServiceControllerMethods() { + return function (constructor: Function) { + const grpcMethods: string[] = ["getAllPermissions", "getAllRoles"]; + for (const method of grpcMethods) { + const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); + GrpcMethod("RbacService", method)(constructor.prototype[method], method, descriptor); + } + const grpcStreamMethods: string[] = []; + for (const method of grpcStreamMethods) { + const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); + GrpcStreamMethod("RbacService", method)(constructor.prototype[method], method, descriptor); + } + }; +} + +export const RBAC_SERVICE_NAME = "RbacService";