From 10b3d450e9991e4c8e2948575453aece1d41f810 Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Mon, 27 Jul 2026 22:13:19 +0700 Subject: [PATCH] add security --- api/main.proto | 8 +++-- .../main.swagger.json | 9 ++++++ proto/main.pb.go | 30 +++++++++++++++---- proto/main.pb.gw.go | 14 +++++++++ 4 files changed, 52 insertions(+), 9 deletions(-) diff --git a/api/main.proto b/api/main.proto index ea84871..b341a00 100644 --- a/api/main.proto +++ b/api/main.proto @@ -805,7 +805,8 @@ message GiveTeamApplicationsRsp { } message GetTeamActionsReq { - int64 id = 1; + int64 id = 1; + string password = 2; } message GetTeamActionsRsp { @@ -814,8 +815,9 @@ message GetTeamActionsRsp { } message AddTeamActionReq { - int64 id = 1; - string code = 2; + int64 id = 1; + string password = 2; + string code = 3; } message AddTeamActionRsp { diff --git a/cmd/evening_detective_server/main.swagger.json b/cmd/evening_detective_server/main.swagger.json index 23c12c5..c52933b 100644 --- a/cmd/evening_detective_server/main.swagger.json +++ b/cmd/evening_detective_server/main.swagger.json @@ -927,6 +927,12 @@ "required": true, "type": "string", "format": "int64" + }, + { + "name": "password", + "in": "query", + "required": false, + "type": "string" } ], "tags": [ @@ -1280,6 +1286,9 @@ "EveningDetectiveServerAddTeamActionBody": { "type": "object", "properties": { + "password": { + "type": "string" + }, "code": { "type": "string" } diff --git a/proto/main.pb.go b/proto/main.pb.go index 6685ae6..fbc3424 100644 --- a/proto/main.pb.go +++ b/proto/main.pb.go @@ -3860,6 +3860,7 @@ func (x *GiveTeamApplicationsRsp) GetError() string { type GetTeamActionsReq struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -3901,6 +3902,13 @@ func (x *GetTeamActionsReq) GetId() int64 { return 0 } +func (x *GetTeamActionsReq) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + type GetTeamActionsRsp struct { state protoimpl.MessageState `protogen:"open.v1"` Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` @@ -3956,7 +3964,8 @@ func (x *GetTeamActionsRsp) GetPlaces() []*Place { type AddTeamActionReq struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + Code string `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -3998,6 +4007,13 @@ func (x *AddTeamActionReq) GetId() int64 { return 0 } +func (x *AddTeamActionReq) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + func (x *AddTeamActionReq) GetCode() string { if x != nil { return x.Code @@ -4284,15 +4300,17 @@ const file_main_proto_rawDesc = "" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\"/\n" + "\x17GiveTeamApplicationsRsp\x12\x14\n" + - "\x05error\x18\x01 \x01(\tR\x05error\"#\n" + + "\x05error\x18\x01 \x01(\tR\x05error\"?\n" + "\x11GetTeamActionsReq\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"h\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1a\n" + + "\bpassword\x18\x02 \x01(\tR\bpassword\"h\n" + "\x11GetTeamActionsRsp\x12\x14\n" + "\x05error\x18\x01 \x01(\tR\x05error\x12=\n" + - "\x06places\x18\x02 \x03(\v2%.crabs.evening_detective_server.PlaceR\x06places\"6\n" + + "\x06places\x18\x02 \x03(\v2%.crabs.evening_detective_server.PlaceR\x06places\"R\n" + "\x10AddTeamActionReq\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + - "\x04code\x18\x02 \x01(\tR\x04code\"(\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1a\n" + + "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x12\n" + + "\x04code\x18\x03 \x01(\tR\x04code\"(\n" + "\x10AddTeamActionRsp\x12\x14\n" + "\x05error\x18\x01 \x01(\tR\x05error2\x98<\n" + "\x16EveningDetectiveServer\x12\xa6\x01\n" + diff --git a/proto/main.pb.gw.go b/proto/main.pb.gw.go index ac531d5..2ff271c 100644 --- a/proto/main.pb.gw.go +++ b/proto/main.pb.gw.go @@ -1266,6 +1266,8 @@ func local_request_EveningDetectiveServer_GiveTeamApplications_0(ctx context.Con return msg, metadata, err } +var filter_EveningDetectiveServer_GetTeamActions_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + func request_EveningDetectiveServer_GetTeamActions_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetTeamActionsReq @@ -1283,6 +1285,12 @@ func request_EveningDetectiveServer_GetTeamActions_0(ctx context.Context, marsha if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EveningDetectiveServer_GetTeamActions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } msg, err := client.GetTeamActions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -1301,6 +1309,12 @@ func local_request_EveningDetectiveServer_GetTeamActions_0(ctx context.Context, if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EveningDetectiveServer_GetTeamActions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } msg, err := server.GetTeamActions(ctx, &protoReq) return msg, metadata, err }