From 364257c5fdf7445067114bf8926b070c0e9a5c9d Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Mon, 14 Jun 2021 16:20:49 +0300 Subject: [PATCH] [#48] creda: Add accessbox in protobuf format Signed-off-by: Angira Kekteeva --- Makefile | 9 ++ creds/accessbox/accessbox.pb.go | 250 ++++++++++++++++++++++++++++++++ creds/accessbox/accessbox.proto | 19 +++ go.mod | 2 + 4 files changed, 280 insertions(+) create mode 100644 creds/accessbox/accessbox.pb.go create mode 100644 creds/accessbox/accessbox.proto diff --git a/Makefile b/Makefile index 6609e486..ed43e588 100644 --- a/Makefile +++ b/Makefile @@ -109,3 +109,12 @@ help: # Clean up clean: rm -rf $(BINDIR) + +protoc: + # Protoc generate + @for f in `find . -type f -name '*.proto' -not -path './vendor/*'`; do \ + echo "⇒ Processing $$f "; \ + protoc \ + --go_out=paths=source_relative:. $$f; \ + done + rm -rf vendor diff --git a/creds/accessbox/accessbox.pb.go b/creds/accessbox/accessbox.pb.go new file mode 100644 index 00000000..b457d8ee --- /dev/null +++ b/creds/accessbox/accessbox.pb.go @@ -0,0 +1,250 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.15.8 +// source: creds/accessbox/accessbox.proto + +package accessbox + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +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) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type AccessBox struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + OwnerPublicKey []byte `protobuf:"bytes,1,opt,name=ownerPublicKey,json=oownerPublicKey,proto3" json:"ownerPublicKey,omitempty"` + BearerTokens []*AccessBox_Token `protobuf:"bytes,2,rep,name=bearerTokens,proto3" json:"bearerTokens,omitempty"` + SessionTokens []*AccessBox_Token `protobuf:"bytes,3,rep,name=sessionTokens,proto3" json:"sessionTokens,omitempty"` +} + +func (x *AccessBox) Reset() { + *x = AccessBox{} + if protoimpl.UnsafeEnabled { + mi := &file_creds_accessbox_accessbox_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AccessBox) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AccessBox) ProtoMessage() {} + +func (x *AccessBox) ProtoReflect() protoreflect.Message { + mi := &file_creds_accessbox_accessbox_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AccessBox.ProtoReflect.Descriptor instead. +func (*AccessBox) Descriptor() ([]byte, []int) { + return file_creds_accessbox_accessbox_proto_rawDescGZIP(), []int{0} +} + +func (x *AccessBox) GetOwnerPublicKey() []byte { + if x != nil { + return x.OwnerPublicKey + } + return nil +} + +func (x *AccessBox) GetBearerTokens() []*AccessBox_Token { + if x != nil { + return x.BearerTokens + } + return nil +} + +func (x *AccessBox) GetSessionTokens() []*AccessBox_Token { + if x != nil { + return x.SessionTokens + } + return nil +} + +type AccessBox_Token struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Token []byte `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + GatePublicKey []byte `protobuf:"bytes,2,opt,name=gatePublicKey,proto3" json:"gatePublicKey,omitempty"` +} + +func (x *AccessBox_Token) Reset() { + *x = AccessBox_Token{} + if protoimpl.UnsafeEnabled { + mi := &file_creds_accessbox_accessbox_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AccessBox_Token) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AccessBox_Token) ProtoMessage() {} + +func (x *AccessBox_Token) ProtoReflect() protoreflect.Message { + mi := &file_creds_accessbox_accessbox_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AccessBox_Token.ProtoReflect.Descriptor instead. +func (*AccessBox_Token) Descriptor() ([]byte, []int) { + return file_creds_accessbox_accessbox_proto_rawDescGZIP(), []int{0, 0} +} + +func (x *AccessBox_Token) GetToken() []byte { + if x != nil { + return x.Token + } + return nil +} + +func (x *AccessBox_Token) GetGatePublicKey() []byte { + if x != nil { + return x.GatePublicKey + } + return nil +} + +var File_creds_accessbox_accessbox_proto protoreflect.FileDescriptor + +var file_creds_accessbox_accessbox_proto_rawDesc = []byte{ + 0x0a, 0x1f, 0x63, 0x72, 0x65, 0x64, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x62, 0x6f, + 0x78, 0x2f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x62, 0x6f, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x09, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x62, 0x6f, 0x78, 0x22, 0xfb, 0x01, 0x0a, + 0x09, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x42, 0x6f, 0x78, 0x12, 0x27, 0x0a, 0x0e, 0x6f, 0x77, + 0x6e, 0x65, 0x72, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x0f, 0x6f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, + 0x4b, 0x65, 0x79, 0x12, 0x3e, 0x0a, 0x0c, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x61, 0x63, 0x63, 0x65, + 0x73, 0x73, 0x62, 0x6f, 0x78, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x42, 0x6f, 0x78, 0x2e, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x0c, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x73, 0x12, 0x40, 0x0a, 0x0d, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x61, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x62, 0x6f, 0x78, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x42, 0x6f, 0x78, + 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x0d, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x1a, 0x43, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, + 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x24, 0x0a, 0x0d, 0x67, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x67, 0x61, 0x74, + 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x73, 0x70, 0x63, 0x63, 0x2d, 0x64, + 0x65, 0x76, 0x2f, 0x6e, 0x65, 0x6f, 0x66, 0x73, 0x2d, 0x73, 0x33, 0x2d, 0x67, 0x77, 0x2f, 0x63, + 0x72, 0x65, 0x64, 0x73, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x62, 0x6f, 0x78, 0x3b, 0x61, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x62, 0x6f, 0x78, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_creds_accessbox_accessbox_proto_rawDescOnce sync.Once + file_creds_accessbox_accessbox_proto_rawDescData = file_creds_accessbox_accessbox_proto_rawDesc +) + +func file_creds_accessbox_accessbox_proto_rawDescGZIP() []byte { + file_creds_accessbox_accessbox_proto_rawDescOnce.Do(func() { + file_creds_accessbox_accessbox_proto_rawDescData = protoimpl.X.CompressGZIP(file_creds_accessbox_accessbox_proto_rawDescData) + }) + return file_creds_accessbox_accessbox_proto_rawDescData +} + +var file_creds_accessbox_accessbox_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_creds_accessbox_accessbox_proto_goTypes = []interface{}{ + (*AccessBox)(nil), // 0: accessbox.AccessBox + (*AccessBox_Token)(nil), // 1: accessbox.AccessBox.Token +} +var file_creds_accessbox_accessbox_proto_depIdxs = []int32{ + 1, // 0: accessbox.AccessBox.bearerTokens:type_name -> accessbox.AccessBox.Token + 1, // 1: accessbox.AccessBox.sessionTokens:type_name -> accessbox.AccessBox.Token + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_creds_accessbox_accessbox_proto_init() } +func file_creds_accessbox_accessbox_proto_init() { + if File_creds_accessbox_accessbox_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_creds_accessbox_accessbox_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AccessBox); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_creds_accessbox_accessbox_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AccessBox_Token); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_creds_accessbox_accessbox_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_creds_accessbox_accessbox_proto_goTypes, + DependencyIndexes: file_creds_accessbox_accessbox_proto_depIdxs, + MessageInfos: file_creds_accessbox_accessbox_proto_msgTypes, + }.Build() + File_creds_accessbox_accessbox_proto = out.File + file_creds_accessbox_accessbox_proto_rawDesc = nil + file_creds_accessbox_accessbox_proto_goTypes = nil + file_creds_accessbox_accessbox_proto_depIdxs = nil +} diff --git a/creds/accessbox/accessbox.proto b/creds/accessbox/accessbox.proto new file mode 100644 index 00000000..8906c926 --- /dev/null +++ b/creds/accessbox/accessbox.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package accessbox; + +option go_package = "github.com/nspcc-dev/neofs-s3-gw/creds/tokenbox;accessbox"; + + + +message AccessBox { + message Token { + bytes token = 1 [json_name = "token"]; + bytes gatePublicKey = 2 [json_name = "gatePublicKey"]; + } + + bytes ownerPublicKey = 1 [json_name = "oownerPublicKey"]; + repeated Token bearerTokens = 2 [json_name = "bearerTokens"]; + repeated Token sessionTokens = 3 [json_name = "sessionTokens"]; +} + diff --git a/go.mod b/go.mod index 2f1ee8eb..7896b055 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.16 require ( github.com/aws/aws-sdk-go v1.37.9 + github.com/golang/protobuf v1.4.3 github.com/google/uuid v1.2.0 github.com/gorilla/mux v1.8.0 github.com/nspcc-dev/neofs-api-go v1.27.0 @@ -21,4 +22,5 @@ require ( golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073 // indirect golang.org/x/text v0.3.5 // indirect google.golang.org/grpc v1.36.1 + google.golang.org/protobuf v1.25.0 )