Fix 'message not signed by the satellite' problem (#560)
* Fix 'message not signed by the satellite' problem * fixed build * fix errors
This commit is contained in:
parent
c765dd98de
commit
1129ead6ef
@ -45,11 +45,7 @@ func TestBasic(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
message, err := client.SignedMessage()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
message := client.SignedMessage()
|
||||
t.Log(message)
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,11 @@ func TestAuditSegment(t *testing.T) {
|
||||
count int
|
||||
}
|
||||
|
||||
ca, err := provider.NewTestCA(ctx)
|
||||
assert.NoError(t, err)
|
||||
identity, err := ca.NewIdentity()
|
||||
assert.NoError(t, err)
|
||||
|
||||
// note: to simulate better,
|
||||
// change limit in library to 5 in
|
||||
// list api call, default is 0 == 1000 listing
|
||||
@ -132,7 +137,6 @@ func TestAuditSegment(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, cache)
|
||||
|
||||
identity := &provider.FullIdentity{ID: ""}
|
||||
pdbw := newPointerDBWrapper(pointerdb.NewServer(db, cache, zap.NewNop(), c, identity))
|
||||
pointers := pdbclient.New(pdbw)
|
||||
|
||||
|
@ -88,11 +88,7 @@ func (service *Service) process(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
authorization, err := service.Cursor.pointers.SignedMessage()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
authorization := service.Cursor.pointers.SignedMessage()
|
||||
verifiedNodes, err := service.Verifier.verify(ctx, stripe.Index, stripe.Segment, authorization)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -31,7 +31,7 @@ func GenerateSignature(data []byte, identity *provider.FullIdentity) ([]byte, er
|
||||
}
|
||||
|
||||
// NewSignedMessage creates instance of signed message
|
||||
func NewSignedMessage(signature []byte, identity *provider.PeerIdentity) (*pb.SignedMessage, error) {
|
||||
func NewSignedMessage(signature []byte, identity *provider.FullIdentity) (*pb.SignedMessage, error) {
|
||||
k, ok := identity.Leaf.PublicKey.(*ecdsa.PublicKey)
|
||||
if !ok {
|
||||
return nil, peertls.ErrUnsupportedKey.New("%T", identity.Leaf.PublicKey)
|
||||
|
@ -49,8 +49,7 @@ func TestSignedMessageVerifier(t *testing.T) {
|
||||
signature, err := GenerateSignature(identity.ID.Bytes(), identity)
|
||||
assert.NoError(t, err)
|
||||
|
||||
peerIdentity := &provider.PeerIdentity{ID: identity.ID, Leaf: identity.Leaf}
|
||||
signedMessage, err := NewSignedMessage(signature, peerIdentity)
|
||||
signedMessage, err := NewSignedMessage(signature, identity)
|
||||
assert.NoError(t, err)
|
||||
|
||||
for _, tt := range []struct {
|
||||
|
@ -41,7 +41,7 @@ func (x RedundancyScheme_SchemeType) String() string {
|
||||
return proto.EnumName(RedundancyScheme_SchemeType_name, int32(x))
|
||||
}
|
||||
func (RedundancyScheme_SchemeType) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{0, 0}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{0, 0}
|
||||
}
|
||||
|
||||
type Pointer_DataType int32
|
||||
@ -64,7 +64,7 @@ func (x Pointer_DataType) String() string {
|
||||
return proto.EnumName(Pointer_DataType_name, int32(x))
|
||||
}
|
||||
func (Pointer_DataType) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{3, 0}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{3, 0}
|
||||
}
|
||||
|
||||
type RedundancyScheme struct {
|
||||
@ -84,7 +84,7 @@ func (m *RedundancyScheme) Reset() { *m = RedundancyScheme{} }
|
||||
func (m *RedundancyScheme) String() string { return proto.CompactTextString(m) }
|
||||
func (*RedundancyScheme) ProtoMessage() {}
|
||||
func (*RedundancyScheme) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{0}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{0}
|
||||
}
|
||||
func (m *RedundancyScheme) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_RedundancyScheme.Unmarshal(m, b)
|
||||
@ -158,7 +158,7 @@ func (m *RemotePiece) Reset() { *m = RemotePiece{} }
|
||||
func (m *RemotePiece) String() string { return proto.CompactTextString(m) }
|
||||
func (*RemotePiece) ProtoMessage() {}
|
||||
func (*RemotePiece) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{1}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{1}
|
||||
}
|
||||
func (m *RemotePiece) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_RemotePiece.Unmarshal(m, b)
|
||||
@ -206,7 +206,7 @@ func (m *RemoteSegment) Reset() { *m = RemoteSegment{} }
|
||||
func (m *RemoteSegment) String() string { return proto.CompactTextString(m) }
|
||||
func (*RemoteSegment) ProtoMessage() {}
|
||||
func (*RemoteSegment) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{2}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{2}
|
||||
}
|
||||
func (m *RemoteSegment) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_RemoteSegment.Unmarshal(m, b)
|
||||
@ -271,7 +271,7 @@ func (m *Pointer) Reset() { *m = Pointer{} }
|
||||
func (m *Pointer) String() string { return proto.CompactTextString(m) }
|
||||
func (*Pointer) ProtoMessage() {}
|
||||
func (*Pointer) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{3}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{3}
|
||||
}
|
||||
func (m *Pointer) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Pointer.Unmarshal(m, b)
|
||||
@ -353,7 +353,7 @@ func (m *PutRequest) Reset() { *m = PutRequest{} }
|
||||
func (m *PutRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*PutRequest) ProtoMessage() {}
|
||||
func (*PutRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{4}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{4}
|
||||
}
|
||||
func (m *PutRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PutRequest.Unmarshal(m, b)
|
||||
@ -399,7 +399,7 @@ func (m *GetRequest) Reset() { *m = GetRequest{} }
|
||||
func (m *GetRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetRequest) ProtoMessage() {}
|
||||
func (*GetRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{5}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{5}
|
||||
}
|
||||
func (m *GetRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetRequest.Unmarshal(m, b)
|
||||
@ -443,7 +443,7 @@ func (m *ListRequest) Reset() { *m = ListRequest{} }
|
||||
func (m *ListRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*ListRequest) ProtoMessage() {}
|
||||
func (*ListRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{6}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{6}
|
||||
}
|
||||
func (m *ListRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ListRequest.Unmarshal(m, b)
|
||||
@ -516,7 +516,7 @@ func (m *PutResponse) Reset() { *m = PutResponse{} }
|
||||
func (m *PutResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*PutResponse) ProtoMessage() {}
|
||||
func (*PutResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{7}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{7}
|
||||
}
|
||||
func (m *PutResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PutResponse.Unmarshal(m, b)
|
||||
@ -541,6 +541,7 @@ type GetResponse struct {
|
||||
Pointer *Pointer `protobuf:"bytes,1,opt,name=pointer,proto3" json:"pointer,omitempty"`
|
||||
Nodes []*Node `protobuf:"bytes,2,rep,name=nodes,proto3" json:"nodes,omitempty"`
|
||||
Pba *PayerBandwidthAllocation `protobuf:"bytes,3,opt,name=pba,proto3" json:"pba,omitempty"`
|
||||
Authorization *SignedMessage `protobuf:"bytes,4,opt,name=authorization,proto3" json:"authorization,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
@ -550,7 +551,7 @@ func (m *GetResponse) Reset() { *m = GetResponse{} }
|
||||
func (m *GetResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetResponse) ProtoMessage() {}
|
||||
func (*GetResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{8}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{8}
|
||||
}
|
||||
func (m *GetResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetResponse.Unmarshal(m, b)
|
||||
@ -591,6 +592,13 @@ func (m *GetResponse) GetPba() *PayerBandwidthAllocation {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetResponse) GetAuthorization() *SignedMessage {
|
||||
if m != nil {
|
||||
return m.Authorization
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListResponse is a response message for the List rpc call
|
||||
type ListResponse struct {
|
||||
Items []*ListResponse_Item `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
|
||||
@ -604,7 +612,7 @@ func (m *ListResponse) Reset() { *m = ListResponse{} }
|
||||
func (m *ListResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*ListResponse) ProtoMessage() {}
|
||||
func (*ListResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{9}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{9}
|
||||
}
|
||||
func (m *ListResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ListResponse.Unmarshal(m, b)
|
||||
@ -651,7 +659,7 @@ func (m *ListResponse_Item) Reset() { *m = ListResponse_Item{} }
|
||||
func (m *ListResponse_Item) String() string { return proto.CompactTextString(m) }
|
||||
func (*ListResponse_Item) ProtoMessage() {}
|
||||
func (*ListResponse_Item) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{9, 0}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{9, 0}
|
||||
}
|
||||
func (m *ListResponse_Item) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ListResponse_Item.Unmarshal(m, b)
|
||||
@ -703,7 +711,7 @@ func (m *DeleteRequest) Reset() { *m = DeleteRequest{} }
|
||||
func (m *DeleteRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteRequest) ProtoMessage() {}
|
||||
func (*DeleteRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{10}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{10}
|
||||
}
|
||||
func (m *DeleteRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeleteRequest.Unmarshal(m, b)
|
||||
@ -741,7 +749,7 @@ func (m *DeleteResponse) Reset() { *m = DeleteResponse{} }
|
||||
func (m *DeleteResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteResponse) ProtoMessage() {}
|
||||
func (*DeleteResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{11}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{11}
|
||||
}
|
||||
func (m *DeleteResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeleteResponse.Unmarshal(m, b)
|
||||
@ -776,7 +784,7 @@ func (m *IterateRequest) Reset() { *m = IterateRequest{} }
|
||||
func (m *IterateRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*IterateRequest) ProtoMessage() {}
|
||||
func (*IterateRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_pointerdb_c06a8fdf5756a947, []int{12}
|
||||
return fileDescriptor_pointerdb_a8e1675f0e1f1a65, []int{12}
|
||||
}
|
||||
func (m *IterateRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_IterateRequest.Unmarshal(m, b)
|
||||
@ -1022,69 +1030,71 @@ var _PointerDB_serviceDesc = grpc.ServiceDesc{
|
||||
Metadata: "pointerdb.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("pointerdb.proto", fileDescriptor_pointerdb_c06a8fdf5756a947) }
|
||||
func init() { proto.RegisterFile("pointerdb.proto", fileDescriptor_pointerdb_a8e1675f0e1f1a65) }
|
||||
|
||||
var fileDescriptor_pointerdb_c06a8fdf5756a947 = []byte{
|
||||
// 976 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcf, 0x6e, 0xdb, 0xc6,
|
||||
0x13, 0x8e, 0xfe, 0x4b, 0x43, 0xcb, 0xd6, 0x6f, 0xe1, 0x9f, 0xc3, 0x28, 0x29, 0x62, 0x30, 0x68,
|
||||
0xe1, 0xb6, 0x01, 0x5d, 0xa8, 0x01, 0x0a, 0x34, 0x2d, 0x8a, 0x38, 0x76, 0x03, 0x01, 0xa9, 0x2b,
|
||||
0xac, 0x7d, 0xea, 0x85, 0x58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 0x95, 0x55, 0x7c,
|
||||
0x40, 0xed, 0x37, 0x79, 0x0a, 0xbd, 0x52, 0x1e, 0x3b, 0x09, 0xde, 0x84, 0xdc, 0x6e, 0x04, 0xad,
|
||||
0x28, 0xc1, 0x3e, 0xc0, 0x2b, 0xbc, 0x2b, 0x5f, 0xf0, 0x7b, 0x03, 0xbc, 0xd7, 0x5c, 0xad, 0x39,
|
||||
0x7b, 0xd0, 0xcd, 0x25, 0x2e, 0xf9, 0x9b, 0x92, 0x55, 0x5a, 0x66, 0x54, 0x94, 0x66, 0x52, 0x47,
|
||||
0x6c, 0x59, 0x9d, 0x3d, 0xa0, 0x60, 0xa1, 0x17, 0x06, 0x21, 0x1f, 0x01, 0x60, 0x16, 0x47, 0x73,
|
||||
0x5c, 0x0a, 0x89, 0xb6, 0xd3, 0x03, 0x3a, 0xc0, 0x2c, 0x3e, 0xb2, 0x00, 0x79, 0x04, 0x03, 0x89,
|
||||
0x8b, 0x42, 0x2a, 0x7e, 0xe5, 0x1a, 0xdd, 0xa7, 0x1b, 0xc0, 0x3c, 0x13, 0x09, 0x4f, 0xb9, 0x2e,
|
||||
0x37, 0xdb, 0x19, 0x26, 0xa5, 0x51, 0x2f, 0x5a, 0x26, 0xec, 0x42, 0xd9, 0x86, 0xf6, 0xe8, 0xc0,
|
||||
0x20, 0xdf, 0x1b, 0x20, 0x18, 0x82, 0x67, 0xc5, 0x52, 0xb9, 0xc8, 0x14, 0x06, 0xbf, 0x35, 0xc0,
|
||||
0xb3, 0xc5, 0x3a, 0xbb, 0xae, 0x54, 0xe3, 0x83, 0x4a, 0x91, 0x27, 0xd0, 0x31, 0xbb, 0xab, 0xfc,
|
||||
0xa6, 0xdd, 0x9f, 0x61, 0x58, 0xbd, 0xa1, 0xa7, 0x22, 0x46, 0xea, 0x7c, 0xe4, 0x1b, 0x68, 0xe5,
|
||||
0x73, 0x66, 0x8b, 0xf3, 0x26, 0x9f, 0x85, 0x9b, 0x77, 0x55, 0x8a, 0x42, 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, 0x7a, 0x47, 0xf6, 0x6e, 0x35,
|
||||
0xd3, 0xc5, 0xdd, 0x7f, 0x4f, 0x93, 0xc9, 0xb7, 0xd0, 0x75, 0xc2, 0x91, 0xfa, 0x03, 0x78, 0x43,
|
||||
0xf0, 0xf1, 0x83, 0x7f, 0xf1, 0xb8, 0xf0, 0xa3, 0xf6, 0x4f, 0xcd, 0x7c, 0x3e, 0xef, 0xda, 0x37,
|
||||
0xea, 0xcb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x95, 0x96, 0x58, 0x93, 0x3f, 0x08, 0x00, 0x00,
|
||||
var fileDescriptor_pointerdb_a8e1675f0e1f1a65 = []byte{
|
||||
// 1003 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x5f, 0x6f, 0x1b, 0x45,
|
||||
0x10, 0xaf, 0xff, 0xdb, 0xe3, 0x38, 0x35, 0xab, 0x90, 0xba, 0x6e, 0x51, 0xa2, 0xab, 0x40, 0x01,
|
||||
0xaa, 0x0b, 0x32, 0x95, 0x90, 0x28, 0x08, 0x35, 0x4d, 0xa8, 0x2c, 0xb5, 0xc1, 0x5a, 0xe7, 0x89,
|
||||
0x97, 0xd3, 0xda, 0x37, 0xb6, 0x57, 0xdc, 0xdd, 0x5e, 0x76, 0xf7, 0x42, 0x93, 0x6f, 0xc2, 0x37,
|
||||
0xe1, 0x85, 0x47, 0x3e, 0x0a, 0x8f, 0x88, 0xaf, 0x80, 0x76, 0xf7, 0xce, 0x3e, 0x37, 0x34, 0x7d,
|
||||
0xe0, 0xc5, 0xbe, 0x99, 0xf9, 0xcd, 0xec, 0xce, 0xfc, 0x7e, 0xb3, 0x70, 0x3f, 0x15, 0x3c, 0xd1,
|
||||
0x28, 0xc3, 0x99, 0x9f, 0x4a, 0xa1, 0x05, 0xe9, 0xac, 0x1d, 0xc3, 0x83, 0xa5, 0x10, 0xcb, 0x08,
|
||||
0x8f, 0x6d, 0x60, 0x96, 0x2d, 0x8e, 0x35, 0x8f, 0x51, 0x69, 0x16, 0xa7, 0x0e, 0x3b, 0xec, 0x89,
|
||||
0x2b, 0x94, 0x11, 0xbb, 0xce, 0xcd, 0x7e, 0xca, 0x71, 0x8e, 0x4a, 0x0b, 0x89, 0xce, 0xe3, 0xfd,
|
||||
0x56, 0x85, 0x3e, 0xc5, 0x30, 0x4b, 0x42, 0x96, 0xcc, 0xaf, 0xa7, 0xf3, 0x15, 0xc6, 0x48, 0xbe,
|
||||
0x85, 0xba, 0xbe, 0x4e, 0x71, 0x50, 0x39, 0xac, 0x1c, 0xed, 0x8e, 0x3e, 0xf3, 0x37, 0x37, 0x78,
|
||||
0x17, 0xea, 0xbb, 0xbf, 0x8b, 0xeb, 0x14, 0xa9, 0xcd, 0x21, 0x0f, 0xa0, 0x15, 0xf3, 0x24, 0x90,
|
||||
0x78, 0x39, 0xa8, 0x1e, 0x56, 0x8e, 0x1a, 0xb4, 0x19, 0xf3, 0x84, 0xe2, 0x25, 0xd9, 0x83, 0x86,
|
||||
0x16, 0x9a, 0x45, 0x83, 0x9a, 0x75, 0x3b, 0x83, 0x7c, 0x0e, 0x7d, 0x89, 0x29, 0xe3, 0x32, 0xd0,
|
||||
0x2b, 0x89, 0x6a, 0x25, 0xa2, 0x70, 0x50, 0xb7, 0x80, 0xfb, 0xce, 0x7f, 0x51, 0xb8, 0xc9, 0x97,
|
||||
0xf0, 0x91, 0xca, 0xe6, 0x73, 0x54, 0xaa, 0x84, 0x6d, 0x58, 0x6c, 0x3f, 0x0f, 0x6c, 0xc0, 0x4f,
|
||||
0x81, 0xa0, 0x64, 0x2a, 0x93, 0x18, 0xa8, 0x15, 0x33, 0xbf, 0xfc, 0x06, 0x07, 0x4d, 0x87, 0xce,
|
||||
0x23, 0x53, 0x13, 0x98, 0xf2, 0x1b, 0xf4, 0xf6, 0x00, 0x36, 0x8d, 0x90, 0x26, 0x54, 0xe9, 0xb4,
|
||||
0x7f, 0xcf, 0x7b, 0x09, 0x5d, 0x8a, 0xb1, 0xd0, 0x38, 0x31, 0x53, 0x23, 0x8f, 0xa0, 0x63, 0xc7,
|
||||
0x17, 0x24, 0x59, 0x6c, 0x47, 0xd3, 0xa0, 0x6d, 0xeb, 0x38, 0xcf, 0x62, 0xd3, 0x76, 0x22, 0x42,
|
||||
0x0c, 0x78, 0x68, 0xdb, 0xee, 0xd0, 0xa6, 0x31, 0xc7, 0xa1, 0xf7, 0x67, 0x05, 0x7a, 0xae, 0xca,
|
||||
0x14, 0x97, 0x31, 0x26, 0x9a, 0x3c, 0x07, 0x90, 0xeb, 0x31, 0xda, 0x42, 0xdd, 0xd1, 0xa3, 0x3b,
|
||||
0x66, 0x4c, 0x4b, 0x70, 0xf2, 0x10, 0xdc, 0x99, 0x9b, 0x83, 0x5a, 0xd6, 0x1e, 0x87, 0xe4, 0x39,
|
||||
0xf4, 0xa4, 0x3d, 0x28, 0x70, 0x2c, 0x0f, 0x6a, 0x87, 0xb5, 0xa3, 0xee, 0x68, 0x7f, 0xab, 0xf4,
|
||||
0xba, 0x1d, 0xba, 0x23, 0x37, 0x86, 0x22, 0x07, 0xd0, 0x8d, 0x51, 0xfe, 0x12, 0x61, 0x20, 0x85,
|
||||
0xd0, 0x96, 0x82, 0x1d, 0x0a, 0xce, 0x45, 0x85, 0xd0, 0xde, 0xdf, 0x55, 0x68, 0x4d, 0x5c, 0x21,
|
||||
0x72, 0xbc, 0xa5, 0x8f, 0xf2, 0xdd, 0x73, 0x84, 0x7f, 0xca, 0x34, 0x2b, 0x89, 0xe2, 0x53, 0xd8,
|
||||
0xe5, 0x49, 0xc4, 0x13, 0x0c, 0x94, 0x1b, 0x82, 0x15, 0xc1, 0x0e, 0xed, 0x39, 0x6f, 0x31, 0x99,
|
||||
0xaf, 0xa0, 0xe9, 0x2e, 0x65, 0xcf, 0xef, 0x8e, 0x06, 0xb7, 0xae, 0x9e, 0x23, 0x69, 0x8e, 0x23,
|
||||
0x04, 0xea, 0x96, 0x58, 0x23, 0x83, 0x1a, 0xb5, 0xdf, 0xe4, 0x07, 0xe8, 0xcd, 0x25, 0x32, 0xcd,
|
||||
0x45, 0x12, 0x84, 0x4c, 0x3b, 0xd6, 0xbb, 0xa3, 0xa1, 0xef, 0x96, 0xc5, 0x2f, 0x96, 0xc5, 0xbf,
|
||||
0x28, 0x96, 0x85, 0xee, 0x14, 0x09, 0xa7, 0x4c, 0x23, 0x79, 0x09, 0xf7, 0xf1, 0x6d, 0xca, 0x65,
|
||||
0xa9, 0x44, 0xeb, 0x83, 0x25, 0x76, 0x37, 0x29, 0xb6, 0xc8, 0x10, 0xda, 0x31, 0x6a, 0x16, 0x32,
|
||||
0xcd, 0x06, 0x6d, 0xdb, 0xec, 0xda, 0xf6, 0x3c, 0x68, 0x17, 0x03, 0x22, 0x00, 0xcd, 0xf1, 0xf9,
|
||||
0xeb, 0xf1, 0xf9, 0x59, 0xff, 0x9e, 0xf9, 0xa6, 0x67, 0x6f, 0x7e, 0xba, 0x38, 0xeb, 0x57, 0xbc,
|
||||
0x73, 0x80, 0x49, 0xa6, 0x29, 0x5e, 0x66, 0xa8, 0xb4, 0xe9, 0x33, 0x65, 0x7a, 0x65, 0x27, 0xde,
|
||||
0xa1, 0xf6, 0x9b, 0x3c, 0x85, 0x56, 0x3e, 0x1e, 0xab, 0x84, 0xee, 0x88, 0xdc, 0x26, 0x82, 0x16,
|
||||
0x10, 0xef, 0x10, 0xe0, 0x15, 0xde, 0x55, 0xcf, 0xfb, 0xbd, 0x02, 0xdd, 0xd7, 0x5c, 0xad, 0x31,
|
||||
0xfb, 0xd0, 0x4c, 0x25, 0x2e, 0xf8, 0xdb, 0x1c, 0x95, 0x5b, 0x46, 0x2a, 0x4a, 0x33, 0xa9, 0x03,
|
||||
0xb6, 0x28, 0xce, 0xee, 0x50, 0xb0, 0xae, 0x17, 0xc6, 0x43, 0x3e, 0x01, 0xc0, 0x24, 0x0c, 0x66,
|
||||
0xb8, 0x10, 0x12, 0x2d, 0xd3, 0x1d, 0xda, 0xc1, 0x24, 0x3c, 0xb1, 0x0e, 0xf2, 0x18, 0x3a, 0x12,
|
||||
0xe7, 0x99, 0x54, 0xfc, 0xca, 0x11, 0xdd, 0xa6, 0x1b, 0x87, 0x79, 0x26, 0x22, 0x1e, 0x73, 0x9d,
|
||||
0x6f, 0xb6, 0x33, 0x4c, 0x49, 0x33, 0xbd, 0x60, 0x11, 0xb1, 0xa5, 0xb2, 0x84, 0xb6, 0x68, 0xc7,
|
||||
0x78, 0x7e, 0x34, 0x0e, 0xaf, 0x07, 0x5d, 0x3b, 0x2c, 0x95, 0x8a, 0x44, 0xa1, 0xf7, 0x57, 0x05,
|
||||
0xba, 0xb6, 0x59, 0x67, 0x97, 0x27, 0x55, 0xf9, 0xe0, 0xa4, 0xc8, 0x13, 0x68, 0x98, 0xdd, 0x55,
|
||||
0x83, 0xaa, 0xdd, 0x9f, 0x9e, 0x5f, 0xbc, 0xa1, 0xe7, 0x22, 0x44, 0xea, 0x62, 0xe4, 0x3b, 0xa8,
|
||||
0xa5, 0x33, 0x66, 0x9b, 0xeb, 0x8e, 0xbe, 0xf0, 0x37, 0xef, 0xaa, 0x14, 0x99, 0x46, 0xe5, 0x4f,
|
||||
0xd8, 0x35, 0xca, 0x13, 0x96, 0x84, 0xbf, 0xf2, 0x50, 0xaf, 0x5e, 0x44, 0x91, 0x98, 0x5b, 0x6d,
|
||||
0x50, 0x93, 0x46, 0xce, 0xa0, 0xc7, 0x32, 0xbd, 0x12, 0x92, 0xdf, 0x58, 0x6f, 0xae, 0xf7, 0x83,
|
||||
0xdb, 0x75, 0xa6, 0x7c, 0x99, 0x60, 0xf8, 0x06, 0x95, 0x62, 0x4b, 0xa4, 0xdb, 0x59, 0xde, 0x1f,
|
||||
0x15, 0xd8, 0x71, 0x8c, 0xe5, 0x8d, 0x8e, 0xa0, 0xc1, 0x35, 0xc6, 0x6a, 0x50, 0xb1, 0x57, 0x7f,
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x03, 0x00,
|
||||
0x00, 0xff, 0xff, 0xa1, 0x60, 0x9c, 0x3f, 0x86, 0x08, 0x00, 0x00,
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ message GetResponse {
|
||||
Pointer pointer = 1;
|
||||
repeated overlay.Node nodes = 2;
|
||||
piecestoreroutes.PayerBandwidthAllocation pba = 3;
|
||||
piecestoreroutes.SignedMessage authorization = 4;
|
||||
}
|
||||
|
||||
// ListResponse is a response message for the List rpc call
|
||||
|
@ -5,17 +5,12 @@ package pdbclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/peer"
|
||||
"google.golang.org/grpc/status"
|
||||
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
||||
|
||||
"storj.io/storj/pkg/auth"
|
||||
"storj.io/storj/pkg/auth/grpcauth"
|
||||
"storj.io/storj/pkg/pb"
|
||||
"storj.io/storj/pkg/provider"
|
||||
@ -29,10 +24,9 @@ var (
|
||||
|
||||
// PointerDB creates a grpcClient
|
||||
type PointerDB struct {
|
||||
grpcClient pb.PointerDBClient
|
||||
signatureHeader *metadata.MD
|
||||
peer *peer.Peer
|
||||
pba *pb.PayerBandwidthAllocation
|
||||
grpcClient pb.PointerDBClient
|
||||
pba *pb.PayerBandwidthAllocation
|
||||
authorization *pb.SignedMessage
|
||||
}
|
||||
|
||||
// New Used as a public function
|
||||
@ -57,7 +51,7 @@ type Client interface {
|
||||
List(ctx context.Context, prefix, startAfter, endBefore storj.Path, recursive bool, limit int, metaFlags uint32) (items []ListItem, more bool, err error)
|
||||
Delete(ctx context.Context, path storj.Path) error
|
||||
|
||||
SignedMessage() (*pb.SignedMessage, error)
|
||||
SignedMessage() *pb.SignedMessage
|
||||
PayerBandwidthAllocation() *pb.PayerBandwidthAllocation
|
||||
|
||||
// Disconnect() error // TODO: implement
|
||||
@ -70,15 +64,13 @@ func NewClient(identity *provider.FullIdentity, address string, APIKey string) (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
signatureHeader := &metadata.MD{}
|
||||
peer := &peer.Peer{}
|
||||
apiKeyInjector := grpcauth.NewAPIKeyInjector(APIKey, grpc.Header(signatureHeader), grpc.Peer(peer))
|
||||
apiKeyInjector := grpcauth.NewAPIKeyInjector(APIKey)
|
||||
c, err := clientConnection(address, dialOpt, grpc.WithUnaryInterceptor(apiKeyInjector))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &PointerDB{grpcClient: c, signatureHeader: signatureHeader, peer: peer}, nil
|
||||
return &PointerDB{grpcClient: c}, nil
|
||||
}
|
||||
|
||||
// a compiler trick to make sure *PointerDB implements Client
|
||||
@ -116,6 +108,7 @@ func (pdb *PointerDB) Get(ctx context.Context, path storj.Path) (pointer *pb.Poi
|
||||
}
|
||||
|
||||
pdb.pba = res.GetPba()
|
||||
pdb.authorization = res.GetAuthorization()
|
||||
|
||||
return res.GetPointer(), nil
|
||||
}
|
||||
@ -159,23 +152,8 @@ func (pdb *PointerDB) Delete(ctx context.Context, path storj.Path) (err error) {
|
||||
}
|
||||
|
||||
// SignedMessage gets signed message from last request
|
||||
func (pdb *PointerDB) SignedMessage() (*pb.SignedMessage, error) {
|
||||
signature := pdb.signatureHeader.Get("signature")
|
||||
if signature == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
base64 := base64.StdEncoding
|
||||
decodedSignature, err := base64.DecodeString(strings.Join(signature, ""))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
identity, err := provider.PeerIdentityFromPeer(pdb.peer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return auth.NewSignedMessage(decodedSignature, identity)
|
||||
func (pdb *PointerDB) SignedMessage() *pb.SignedMessage {
|
||||
return pdb.authorization
|
||||
}
|
||||
|
||||
// PayerBandwidthAllocation gets payer bandwidth allocation message from last get request
|
||||
|
@ -5,10 +5,6 @@ package pdbclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
@ -18,15 +14,10 @@ import (
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/gtank/cryptopasta"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/peer"
|
||||
|
||||
"storj.io/storj/pkg/auth"
|
||||
"storj.io/storj/pkg/pb"
|
||||
"storj.io/storj/pkg/provider"
|
||||
"storj.io/storj/pkg/storage/meta"
|
||||
"storj.io/storj/pkg/storj"
|
||||
)
|
||||
@ -297,39 +288,3 @@ func TestDelete(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSignedMessage(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ca, err := provider.NewTestCA(ctx)
|
||||
assert.NoError(t, err)
|
||||
identity, err := ca.NewIdentity()
|
||||
assert.NoError(t, err)
|
||||
|
||||
peerCertificates := make([]*x509.Certificate, 2)
|
||||
peerCertificates[0] = identity.Leaf
|
||||
peerCertificates[1] = identity.CA
|
||||
|
||||
info := credentials.TLSInfo{State: tls.ConnectionState{PeerCertificates: peerCertificates}}
|
||||
|
||||
signature := base64.StdEncoding.EncodeToString([]byte("some value"))
|
||||
|
||||
header := metadata.Pairs("signature", signature)
|
||||
peer := &peer.Peer{AuthInfo: info}
|
||||
pointerdb := &PointerDB{
|
||||
signatureHeader: &header,
|
||||
peer: peer,
|
||||
}
|
||||
|
||||
auth, err := pointerdb.SignedMessage()
|
||||
assert.NoError(t, err)
|
||||
|
||||
pk, ok := identity.Leaf.PublicKey.(*ecdsa.PublicKey)
|
||||
assert.Equal(t, true, ok)
|
||||
|
||||
expectedKey, err := cryptopasta.EncodePublicKey(pk)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, expectedKey, auth.GetPublicKey())
|
||||
assert.Equal(t, identity.ID.Bytes(), auth.GetData())
|
||||
assert.Equal(t, "some value", string(auth.GetSignature()))
|
||||
}
|
||||
|
@ -99,11 +99,10 @@ func (mr *MockClientMockRecorder) Put(arg0, arg1, arg2 interface{}) *gomock.Call
|
||||
}
|
||||
|
||||
// SignedMessage mocks base method
|
||||
func (m *MockClient) SignedMessage() (*pb.SignedMessage, error) {
|
||||
func (m *MockClient) SignedMessage() *pb.SignedMessage {
|
||||
ret := m.ctrl.Call(m, "SignedMessage")
|
||||
ret0, _ := ret[0].(*pb.SignedMessage)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SignedMessage indicates an expected call of SignedMessage
|
||||
|
@ -5,15 +5,12 @@ package pointerdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
||||
|
||||
@ -60,21 +57,6 @@ func (s *Server) validateAuth(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) appendSignature(ctx context.Context) error {
|
||||
signature, err := auth.GenerateSignature(s.identity.ID.Bytes(), s.identity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if signature == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
base64 := base64.StdEncoding
|
||||
encodedSignature := base64.EncodeToString(signature)
|
||||
return grpc.SetHeader(ctx, metadata.Pairs("signature", encodedSignature))
|
||||
}
|
||||
|
||||
func (s *Server) validateSegment(req *pb.PutRequest) error {
|
||||
min := s.config.MinRemoteSegmentSize
|
||||
remote := req.GetPointer().Remote
|
||||
@ -137,10 +119,6 @@ func (s *Server) Get(ctx context.Context, req *pb.GetRequest) (resp *pb.GetRespo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = s.appendSignature(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pointerBytes, err := s.DB.Get([]byte(req.GetPath()))
|
||||
if err != nil {
|
||||
if storage.ErrKeyNotFound.Has(err) {
|
||||
@ -163,12 +141,19 @@ func (s *Server) Get(ctx context.Context, req *pb.GetRequest) (resp *pb.GetRespo
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
authorization, err := s.getSignedMessage()
|
||||
if err != nil {
|
||||
s.logger.Error("err getting signed message", zap.Error(err))
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
nodes := []*pb.Node{}
|
||||
|
||||
var r = &pb.GetResponse{
|
||||
Pointer: pointer,
|
||||
Nodes: nil,
|
||||
Pba: pba,
|
||||
Pointer: pointer,
|
||||
Nodes: nil,
|
||||
Pba: pba,
|
||||
Authorization: authorization,
|
||||
}
|
||||
|
||||
if !s.config.Overlay || pointer.Remote == nil {
|
||||
@ -184,9 +169,10 @@ func (s *Server) Get(ctx context.Context, req *pb.GetRequest) (resp *pb.GetRespo
|
||||
}
|
||||
|
||||
r = &pb.GetResponse{
|
||||
Pointer: pointer,
|
||||
Nodes: nodes,
|
||||
Pba: pba,
|
||||
Pointer: pointer,
|
||||
Nodes: nodes,
|
||||
Pba: pba,
|
||||
Authorization: authorization,
|
||||
}
|
||||
|
||||
return r, nil
|
||||
@ -331,3 +317,12 @@ func (s *Server) getPayerBandwidthAllocation(ctx context.Context) (*pb.PayerBand
|
||||
}
|
||||
return &pb.PayerBandwidthAllocation{Signature: signature, Data: data}, nil
|
||||
}
|
||||
|
||||
func (s *Server) getSignedMessage() (*pb.SignedMessage, error) {
|
||||
signature, err := auth.GenerateSignature(s.identity.ID.Bytes(), s.identity)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return auth.NewSignedMessage(signature, s.identity)
|
||||
}
|
||||
|
@ -90,9 +90,6 @@ func TestServiceGet(t *testing.T) {
|
||||
ctx = auth.WithAPIKey(ctx, tt.apiKey)
|
||||
ctx = peer.NewContext(ctx, &peer.Peer{AuthInfo: info})
|
||||
|
||||
// TODO(michal) workaround avoid problems with lack of grpc context
|
||||
identity.ID = ""
|
||||
|
||||
errTag := fmt.Sprintf("Test case #%d", i)
|
||||
|
||||
db := teststore.New()
|
||||
@ -119,6 +116,9 @@ func TestServiceGet(t *testing.T) {
|
||||
assert.NoError(t, err, errTag)
|
||||
assert.NoError(t, err, errTag)
|
||||
assert.True(t, proto.Equal(pr, resp.Pointer), errTag)
|
||||
|
||||
assert.NotNil(t, resp.GetAuthorization())
|
||||
assert.NotNil(t, resp.GetPba())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,13 +122,10 @@ func (s *segmentStore) Put(ctx context.Context, data io.Reader, expiration time.
|
||||
pieceID := client.NewPieceID()
|
||||
sizedReader := SizeReader(peekReader)
|
||||
|
||||
signedMessage, err := s.pdb.SignedMessage()
|
||||
if err != nil {
|
||||
return Meta{}, Error.Wrap(err)
|
||||
}
|
||||
authorization := s.pdb.SignedMessage()
|
||||
pba := s.pdb.PayerBandwidthAllocation()
|
||||
// puts file to ecclient
|
||||
successfulNodes, err := s.ec.Put(ctx, nodes, s.rs, pieceID, sizedReader, expiration, pba, signedMessage)
|
||||
successfulNodes, err := s.ec.Put(ctx, nodes, s.rs, pieceID, sizedReader, expiration, pba, authorization)
|
||||
if err != nil {
|
||||
return Meta{}, Error.Wrap(err)
|
||||
}
|
||||
@ -231,12 +228,9 @@ func (s *segmentStore) Get(ctx context.Context, path storj.Path) (
|
||||
}
|
||||
}
|
||||
|
||||
signedMessage, err := s.pdb.SignedMessage()
|
||||
if err != nil {
|
||||
return nil, Meta{}, Error.Wrap(err)
|
||||
}
|
||||
authorization := s.pdb.SignedMessage()
|
||||
pba := s.pdb.PayerBandwidthAllocation()
|
||||
rr, err = s.ec.Get(ctx, nodes, es, pid, pr.GetSize(), pba, signedMessage)
|
||||
rr, err = s.ec.Get(ctx, nodes, es, pid, pr.GetSize(), pba, authorization)
|
||||
if err != nil {
|
||||
return nil, Meta{}, Error.Wrap(err)
|
||||
}
|
||||
@ -273,12 +267,9 @@ func (s *segmentStore) Delete(ctx context.Context, path storj.Path) (err error)
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
|
||||
signedMessage, err := s.pdb.SignedMessage()
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
authorization := s.pdb.SignedMessage()
|
||||
// ecclient sends delete request
|
||||
err = s.ec.Delete(ctx, nodes, pid, signedMessage)
|
||||
err = s.ec.Delete(ctx, nodes, pid, authorization)
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
@ -356,10 +347,7 @@ func (s *segmentStore) Repair(ctx context.Context, path storj.Path, lostPieces [
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
|
||||
signedMessage, err := s.pdb.SignedMessage()
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
signedMessage := s.pdb.SignedMessage()
|
||||
pba := s.pdb.PayerBandwidthAllocation()
|
||||
|
||||
// download the segment using the nodes just with healthy nodes
|
||||
|
Loading…
Reference in New Issue
Block a user