diff --git a/api/main.proto b/api/main.proto index ef0a028..00082a3 100644 --- a/api/main.proto +++ b/api/main.proto @@ -135,6 +135,12 @@ service EveningDetectiveServer { body : "*" }; } + + rpc GetPermissions(GetPermissionsReq) returns (GetPermissionsRsp) { + option (google.api.http) = { + get: "/api/ui/permissions" + }; + } } message PingReq {} @@ -236,3 +242,10 @@ message DeleteUserRoleReq { message DeleteUserRoleRsp { string error = 1; } + +message GetPermissionsReq {} + +message GetPermissionsRsp { + string error = 1; + repeated string permissions = 2; +} diff --git a/cmd/evening_detective_server/main.go b/cmd/evening_detective_server/main.go index 86d81b1..0d16eb4 100644 --- a/cmd/evening_detective_server/main.go +++ b/cmd/evening_detective_server/main.go @@ -9,6 +9,7 @@ import ( "evening_detective_server/internal/modules/processor_jwt" "evening_detective_server/internal/repos/refresh_tokens_repo" "evening_detective_server/internal/repos/users_repo" + "evening_detective_server/internal/services/ui_service" "evening_detective_server/internal/services/users_service" proto "evening_detective_server/proto" "log" @@ -54,6 +55,7 @@ func main() { processorJWT := processor_jwt.NewProcessor(os.Getenv("SECRET")) refreshTokensRepo := refresh_tokens_repo.NewRefreshTokensRepo(dbpool) usersService := users_service.NewUsersService(usersRepo, passwordGenerator, emailSender, processorJWT, refreshTokensRepo) + uiService := ui_service.NewUiService() // Create a listener on TCP port lis, err := net.Listen("tcp", ":8080") @@ -82,6 +84,7 @@ func main() { s, app.NewServer( usersService, + uiService, ), ) // Serve gRPC server diff --git a/cmd/evening_detective_server/main.swagger.json b/cmd/evening_detective_server/main.swagger.json index beea22b..d3c9d48 100644 --- a/cmd/evening_detective_server/main.swagger.json +++ b/cmd/evening_detective_server/main.swagger.json @@ -226,6 +226,28 @@ ] } }, + "/api/ui/permissions": { + "get": { + "operationId": "EveningDetectiveServer_GetPermissions", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/evening_detective_serverGetPermissionsRsp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "tags": [ + "EveningDetectiveServer" + ] + } + }, "/api/users": { "get": { "operationId": "EveningDetectiveServer_GetUsers", @@ -432,6 +454,20 @@ } } }, + "evening_detective_serverGetPermissionsRsp": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "evening_detective_serverGetUserByIdRsp": { "type": "object", "properties": { diff --git a/internal/app/server.go b/internal/app/server.go index 5d71401..d32653f 100644 --- a/internal/app/server.go +++ b/internal/app/server.go @@ -4,6 +4,7 @@ import ( "context" "evening_detective_server/internal/modules/processor_jwt" "evening_detective_server/internal/modules/roles" + "evening_detective_server/internal/services/ui_service" "evening_detective_server/internal/services/users_service" proto "evening_detective_server/proto" @@ -15,13 +16,16 @@ type server struct { proto.UnsafeEveningDetectiveServerServer usersService *users_service.UsersService + uiService *ui_service.UiService } func NewServer( usersService *users_service.UsersService, + uiService *ui_service.UiService, ) proto.EveningDetectiveServerServer { return &server{ usersService: usersService, + uiService: uiService, } } @@ -152,3 +156,14 @@ func (s *server) DeleteUserRole(ctx context.Context, req *proto.DeleteUserRoleRe } return &proto.DeleteUserRoleRsp{}, nil } + +func (s *server) GetPermissions( + ctx context.Context, + req *proto.GetPermissionsReq, +) (*proto.GetPermissionsRsp, error) { + claims := ctx.Value("claims").(*processor_jwt.JWTClaims) + permissions := s.uiService.GetPermissions(claims.Roles) + return &proto.GetPermissionsRsp{ + Permissions: permissions, + }, nil +} diff --git a/internal/services/ui_service/service.go b/internal/services/ui_service/service.go new file mode 100644 index 0000000..71f4226 --- /dev/null +++ b/internal/services/ui_service/service.go @@ -0,0 +1,61 @@ +package ui_service + +import ( + rolesModule "evening_detective_server/internal/modules/roles" + "slices" +) + +var ( + permissions = map[string][]string{ + rolesModule.Admin: { + "users_page", + }, + rolesModule.Author: { + "scenarios_page", + "scenario_editor_page", + }, + rolesModule.Organizer: { + "scenarios_page", + "games_page", + "game_panel_page", + }, + rolesModule.User: { + "games_page", + }, + } +) + +type UiService struct{} + +func NewUiService() *UiService { + return &UiService{} +} + +func (s *UiService) GetPermissions(roles []string) []string { + resMap := s.getPermissionsMap(roles) + res := make([]string, 0, len(resMap)) + for permission := range resMap { + res = append(res, permission) + } + return res +} + +func (s *UiService) getPermissionsMap(roles []string) map[string]any { + resMap := make(map[string]any, 100) + + if slices.Contains(roles, rolesModule.Admin) { + for _, permissionsList := range permissions { + for _, permission := range permissionsList { + resMap[permission] = struct{}{} + } + } + return resMap + } + + for _, role := range roles { + for _, permission := range permissions[role] { + resMap[permission] = struct{}{} + } + } + return resMap +} diff --git a/proto/main.pb.go b/proto/main.pb.go index 3968c5b..f1b2db8 100644 --- a/proto/main.pb.go +++ b/proto/main.pb.go @@ -1132,6 +1132,94 @@ func (x *DeleteUserRoleRsp) GetError() string { return "" } +type GetPermissionsReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPermissionsReq) Reset() { + *x = GetPermissionsReq{} + mi := &file_main_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPermissionsReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPermissionsReq) ProtoMessage() {} + +func (x *GetPermissionsReq) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[23] + 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 GetPermissionsReq.ProtoReflect.Descriptor instead. +func (*GetPermissionsReq) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{23} +} + +type GetPermissionsRsp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` + Permissions []string `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPermissionsRsp) Reset() { + *x = GetPermissionsRsp{} + mi := &file_main_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPermissionsRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPermissionsRsp) ProtoMessage() {} + +func (x *GetPermissionsRsp) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[24] + 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 GetPermissionsRsp.ProtoReflect.Descriptor instead. +func (*GetPermissionsRsp) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{24} +} + +func (x *GetPermissionsRsp) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +func (x *GetPermissionsRsp) GetPermissions() []string { + if x != nil { + return x.Permissions + } + return nil +} + var File_main_proto protoreflect.FileDescriptor const file_main_proto_rawDesc = "" + @@ -1199,7 +1287,11 @@ const file_main_proto_rawDesc = "" + "\x02id\x18\x01 \x01(\x05R\x02id\x12\x12\n" + "\x04role\x18\x02 \x01(\tR\x04role\")\n" + "\x11DeleteUserRoleRsp\x12\x14\n" + - "\x05error\x18\x01 \x01(\tR\x05error2\x88\f\n" + + "\x05error\x18\x01 \x01(\tR\x05error\"\x13\n" + + "\x11GetPermissionsReq\"K\n" + + "\x11GetPermissionsRsp\x12\x14\n" + + "\x05error\x18\x01 \x01(\tR\x05error\x12 \n" + + "\vpermissions\x18\x02 \x03(\tR\vpermissions2\x9e\r\n" + "\x16EveningDetectiveServer\x12{\n" + "\x04Ping\x12'.crabs.evening_detective_server.PingReq\x1a'.crabs.evening_detective_server.PingRsp\"!\x92A\bb\x06\n" + "\x04\n" + @@ -1224,7 +1316,8 @@ const file_main_proto_rawDesc = "" + "\vGetUserById\x12..crabs.evening_detective_server.GetUserByIdReq\x1a..crabs.evening_detective_server.GetUserByIdRsp\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/api/users/{id}\x12r\n" + "\x05GetMe\x12(.crabs.evening_detective_server.GetMeReq\x1a(.crabs.evening_detective_server.GetMeRsp\"\x15\x82\xd3\xe4\x93\x02\x0f\x12\r/api/users/me\x12\x92\x01\n" + "\vAddUserRole\x12..crabs.evening_detective_server.AddUserRoleReq\x1a..crabs.evening_detective_server.AddUserRoleRsp\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/api/users/{id}/role/add\x12\x9e\x01\n" + - "\x0eDeleteUserRole\x121.crabs.evening_detective_server.DeleteUserRoleReq\x1a1.crabs.evening_detective_server.DeleteUserRoleRsp\"&\x82\xd3\xe4\x93\x02 :\x01*\"\x1b/api/users/{id}/role/deleteB\xd7\x01\x92A\xc8\x01\x12U\n" + + "\x0eDeleteUserRole\x121.crabs.evening_detective_server.DeleteUserRoleReq\x1a1.crabs.evening_detective_server.DeleteUserRoleRsp\"&\x82\xd3\xe4\x93\x02 :\x01*\"\x1b/api/users/{id}/role/delete\x12\x93\x01\n" + + "\x0eGetPermissions\x121.crabs.evening_detective_server.GetPermissionsReq\x1a1.crabs.evening_detective_server.GetPermissionsRsp\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/api/ui/permissionsB\xd7\x01\x92A\xc8\x01\x12U\n" + "KДокументация сервиса \"Вечерний детектив\"2\x06v0.1.0Z]\n" + "[\n" + "\n" + @@ -1245,7 +1338,7 @@ func file_main_proto_rawDescGZIP() []byte { return file_main_proto_rawDescData } -var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 23) +var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 25) var file_main_proto_goTypes = []any{ (*PingReq)(nil), // 0: crabs.evening_detective_server.PingReq (*PingRsp)(nil), // 1: crabs.evening_detective_server.PingRsp @@ -1270,11 +1363,13 @@ var file_main_proto_goTypes = []any{ (*AddUserRoleRsp)(nil), // 20: crabs.evening_detective_server.AddUserRoleRsp (*DeleteUserRoleReq)(nil), // 21: crabs.evening_detective_server.DeleteUserRoleReq (*DeleteUserRoleRsp)(nil), // 22: crabs.evening_detective_server.DeleteUserRoleRsp - (*timestamppb.Timestamp)(nil), // 23: google.protobuf.Timestamp + (*GetPermissionsReq)(nil), // 23: crabs.evening_detective_server.GetPermissionsReq + (*GetPermissionsRsp)(nil), // 24: crabs.evening_detective_server.GetPermissionsRsp + (*timestamppb.Timestamp)(nil), // 25: google.protobuf.Timestamp } var file_main_proto_depIdxs = []int32{ 14, // 0: crabs.evening_detective_server.GetUsersRsp.users:type_name -> crabs.evening_detective_server.User - 23, // 1: crabs.evening_detective_server.User.created_at:type_name -> google.protobuf.Timestamp + 25, // 1: crabs.evening_detective_server.User.created_at:type_name -> google.protobuf.Timestamp 14, // 2: crabs.evening_detective_server.GetUserByIdRsp.user:type_name -> crabs.evening_detective_server.User 14, // 3: crabs.evening_detective_server.GetMeRsp.user:type_name -> crabs.evening_detective_server.User 0, // 4: crabs.evening_detective_server.EveningDetectiveServer.Ping:input_type -> crabs.evening_detective_server.PingReq @@ -1288,19 +1383,21 @@ var file_main_proto_depIdxs = []int32{ 17, // 12: crabs.evening_detective_server.EveningDetectiveServer.GetMe:input_type -> crabs.evening_detective_server.GetMeReq 19, // 13: crabs.evening_detective_server.EveningDetectiveServer.AddUserRole:input_type -> crabs.evening_detective_server.AddUserRoleReq 21, // 14: crabs.evening_detective_server.EveningDetectiveServer.DeleteUserRole:input_type -> crabs.evening_detective_server.DeleteUserRoleReq - 1, // 15: crabs.evening_detective_server.EveningDetectiveServer.Ping:output_type -> crabs.evening_detective_server.PingRsp - 3, // 16: crabs.evening_detective_server.EveningDetectiveServer.Echo:output_type -> crabs.evening_detective_server.EchoRsp - 5, // 17: crabs.evening_detective_server.EveningDetectiveServer.Signup:output_type -> crabs.evening_detective_server.SignupRsp - 7, // 18: crabs.evening_detective_server.EveningDetectiveServer.RefreshPassword:output_type -> crabs.evening_detective_server.RefreshPasswordRsp - 9, // 19: crabs.evening_detective_server.EveningDetectiveServer.Login:output_type -> crabs.evening_detective_server.LoginRsp - 11, // 20: crabs.evening_detective_server.EveningDetectiveServer.Refresh:output_type -> crabs.evening_detective_server.RefreshRsp - 13, // 21: crabs.evening_detective_server.EveningDetectiveServer.GetUsers:output_type -> crabs.evening_detective_server.GetUsersRsp - 16, // 22: crabs.evening_detective_server.EveningDetectiveServer.GetUserById:output_type -> crabs.evening_detective_server.GetUserByIdRsp - 18, // 23: crabs.evening_detective_server.EveningDetectiveServer.GetMe:output_type -> crabs.evening_detective_server.GetMeRsp - 20, // 24: crabs.evening_detective_server.EveningDetectiveServer.AddUserRole:output_type -> crabs.evening_detective_server.AddUserRoleRsp - 22, // 25: crabs.evening_detective_server.EveningDetectiveServer.DeleteUserRole:output_type -> crabs.evening_detective_server.DeleteUserRoleRsp - 15, // [15:26] is the sub-list for method output_type - 4, // [4:15] is the sub-list for method input_type + 23, // 15: crabs.evening_detective_server.EveningDetectiveServer.GetPermissions:input_type -> crabs.evening_detective_server.GetPermissionsReq + 1, // 16: crabs.evening_detective_server.EveningDetectiveServer.Ping:output_type -> crabs.evening_detective_server.PingRsp + 3, // 17: crabs.evening_detective_server.EveningDetectiveServer.Echo:output_type -> crabs.evening_detective_server.EchoRsp + 5, // 18: crabs.evening_detective_server.EveningDetectiveServer.Signup:output_type -> crabs.evening_detective_server.SignupRsp + 7, // 19: crabs.evening_detective_server.EveningDetectiveServer.RefreshPassword:output_type -> crabs.evening_detective_server.RefreshPasswordRsp + 9, // 20: crabs.evening_detective_server.EveningDetectiveServer.Login:output_type -> crabs.evening_detective_server.LoginRsp + 11, // 21: crabs.evening_detective_server.EveningDetectiveServer.Refresh:output_type -> crabs.evening_detective_server.RefreshRsp + 13, // 22: crabs.evening_detective_server.EveningDetectiveServer.GetUsers:output_type -> crabs.evening_detective_server.GetUsersRsp + 16, // 23: crabs.evening_detective_server.EveningDetectiveServer.GetUserById:output_type -> crabs.evening_detective_server.GetUserByIdRsp + 18, // 24: crabs.evening_detective_server.EveningDetectiveServer.GetMe:output_type -> crabs.evening_detective_server.GetMeRsp + 20, // 25: crabs.evening_detective_server.EveningDetectiveServer.AddUserRole:output_type -> crabs.evening_detective_server.AddUserRoleRsp + 22, // 26: crabs.evening_detective_server.EveningDetectiveServer.DeleteUserRole:output_type -> crabs.evening_detective_server.DeleteUserRoleRsp + 24, // 27: crabs.evening_detective_server.EveningDetectiveServer.GetPermissions:output_type -> crabs.evening_detective_server.GetPermissionsRsp + 16, // [16:28] is the sub-list for method output_type + 4, // [4:16] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name 4, // [4:4] is the sub-list for extension extendee 0, // [0:4] is the sub-list for field type_name @@ -1317,7 +1414,7 @@ func file_main_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_main_proto_rawDesc), len(file_main_proto_rawDesc)), NumEnums: 0, - NumMessages: 23, + NumMessages: 25, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/main.pb.gw.go b/proto/main.pb.gw.go index 7a9079b..8e1eae6 100644 --- a/proto/main.pb.gw.go +++ b/proto/main.pb.gw.go @@ -370,6 +370,27 @@ func local_request_EveningDetectiveServer_DeleteUserRole_0(ctx context.Context, return msg, metadata, err } +func request_EveningDetectiveServer_GetPermissions_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPermissionsReq + metadata runtime.ServerMetadata + ) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } + msg, err := client.GetPermissions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_EveningDetectiveServer_GetPermissions_0(ctx context.Context, marshaler runtime.Marshaler, server EveningDetectiveServerServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPermissionsReq + metadata runtime.ServerMetadata + ) + msg, err := server.GetPermissions(ctx, &protoReq) + return msg, metadata, err +} + // RegisterEveningDetectiveServerHandlerServer registers the http handlers for service EveningDetectiveServer to "mux". // UnaryRPC :call EveningDetectiveServerServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -596,6 +617,26 @@ func RegisterEveningDetectiveServerHandlerServer(ctx context.Context, mux *runti } forward_EveningDetectiveServer_DeleteUserRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) + mux.Handle(http.MethodGet, pattern_EveningDetectiveServer_GetPermissions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/GetPermissions", runtime.WithHTTPPathPattern("/api/ui/permissions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_EveningDetectiveServer_GetPermissions_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_GetPermissions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) return nil } @@ -823,6 +864,23 @@ func RegisterEveningDetectiveServerHandlerClient(ctx context.Context, mux *runti } forward_EveningDetectiveServer_DeleteUserRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) + mux.Handle(http.MethodGet, pattern_EveningDetectiveServer_GetPermissions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/GetPermissions", runtime.WithHTTPPathPattern("/api/ui/permissions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EveningDetectiveServer_GetPermissions_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_GetPermissions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) return nil } @@ -838,6 +896,7 @@ var ( pattern_EveningDetectiveServer_GetMe_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "users", "me"}, "")) pattern_EveningDetectiveServer_AddUserRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 4}, []string{"api", "users", "id", "role", "add"}, "")) pattern_EveningDetectiveServer_DeleteUserRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 4}, []string{"api", "users", "id", "role", "delete"}, "")) + pattern_EveningDetectiveServer_GetPermissions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "ui", "permissions"}, "")) ) var ( @@ -852,4 +911,5 @@ var ( forward_EveningDetectiveServer_GetMe_0 = runtime.ForwardResponseMessage forward_EveningDetectiveServer_AddUserRole_0 = runtime.ForwardResponseMessage forward_EveningDetectiveServer_DeleteUserRole_0 = runtime.ForwardResponseMessage + forward_EveningDetectiveServer_GetPermissions_0 = runtime.ForwardResponseMessage ) diff --git a/proto/main_grpc.pb.go b/proto/main_grpc.pb.go index 9dca1ac..6e7bfac 100644 --- a/proto/main_grpc.pb.go +++ b/proto/main_grpc.pb.go @@ -30,6 +30,7 @@ const ( EveningDetectiveServer_GetMe_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/GetMe" EveningDetectiveServer_AddUserRole_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/AddUserRole" EveningDetectiveServer_DeleteUserRole_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/DeleteUserRole" + EveningDetectiveServer_GetPermissions_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/GetPermissions" ) // EveningDetectiveServerClient is the client API for EveningDetectiveServer service. @@ -47,6 +48,7 @@ type EveningDetectiveServerClient interface { GetMe(ctx context.Context, in *GetMeReq, opts ...grpc.CallOption) (*GetMeRsp, error) AddUserRole(ctx context.Context, in *AddUserRoleReq, opts ...grpc.CallOption) (*AddUserRoleRsp, error) DeleteUserRole(ctx context.Context, in *DeleteUserRoleReq, opts ...grpc.CallOption) (*DeleteUserRoleRsp, error) + GetPermissions(ctx context.Context, in *GetPermissionsReq, opts ...grpc.CallOption) (*GetPermissionsRsp, error) } type eveningDetectiveServerClient struct { @@ -167,6 +169,16 @@ func (c *eveningDetectiveServerClient) DeleteUserRole(ctx context.Context, in *D return out, nil } +func (c *eveningDetectiveServerClient) GetPermissions(ctx context.Context, in *GetPermissionsReq, opts ...grpc.CallOption) (*GetPermissionsRsp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetPermissionsRsp) + err := c.cc.Invoke(ctx, EveningDetectiveServer_GetPermissions_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // EveningDetectiveServerServer is the server API for EveningDetectiveServer service. // All implementations must embed UnimplementedEveningDetectiveServerServer // for forward compatibility. @@ -182,6 +194,7 @@ type EveningDetectiveServerServer interface { GetMe(context.Context, *GetMeReq) (*GetMeRsp, error) AddUserRole(context.Context, *AddUserRoleReq) (*AddUserRoleRsp, error) DeleteUserRole(context.Context, *DeleteUserRoleReq) (*DeleteUserRoleRsp, error) + GetPermissions(context.Context, *GetPermissionsReq) (*GetPermissionsRsp, error) mustEmbedUnimplementedEveningDetectiveServerServer() } @@ -225,6 +238,9 @@ func (UnimplementedEveningDetectiveServerServer) AddUserRole(context.Context, *A func (UnimplementedEveningDetectiveServerServer) DeleteUserRole(context.Context, *DeleteUserRoleReq) (*DeleteUserRoleRsp, error) { return nil, status.Error(codes.Unimplemented, "method DeleteUserRole not implemented") } +func (UnimplementedEveningDetectiveServerServer) GetPermissions(context.Context, *GetPermissionsReq) (*GetPermissionsRsp, error) { + return nil, status.Error(codes.Unimplemented, "method GetPermissions not implemented") +} func (UnimplementedEveningDetectiveServerServer) mustEmbedUnimplementedEveningDetectiveServerServer() { } func (UnimplementedEveningDetectiveServerServer) testEmbeddedByValue() {} @@ -445,6 +461,24 @@ func _EveningDetectiveServer_DeleteUserRole_Handler(srv interface{}, ctx context return interceptor(ctx, in, info, handler) } +func _EveningDetectiveServer_GetPermissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPermissionsReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EveningDetectiveServerServer).GetPermissions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: EveningDetectiveServer_GetPermissions_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EveningDetectiveServerServer).GetPermissions(ctx, req.(*GetPermissionsReq)) + } + return interceptor(ctx, in, info, handler) +} + // EveningDetectiveServer_ServiceDesc is the grpc.ServiceDesc for EveningDetectiveServer service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -496,6 +530,10 @@ var EveningDetectiveServer_ServiceDesc = grpc.ServiceDesc{ MethodName: "DeleteUserRole", Handler: _EveningDetectiveServer_DeleteUserRole_Handler, }, + { + MethodName: "GetPermissions", + Handler: _EveningDetectiveServer_GetPermissions_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "main.proto",