Satellite verification on storage node (#469)

* Satellite verification on storage node

* fix formatting

* fix formatting

* rename SignatureAuth to SignedMessage

* fixes after review

* fix linter errors

* improve errors handling

* remove SignedMessageProvider

* fix liter errors

* params changed to authorization, signed message in audit, minor fixes

* fix formatting
This commit is contained in:
Michal Niewrzal 2018-10-17 13:40:11 +02:00 committed by GitHub
parent 92a8a825c4
commit f9248c21d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 382 additions and 212 deletions

View File

@ -91,7 +91,7 @@ func main() {
id := client.NewPieceID()
if err := psClient.Put(context.Background(), id, dataSection, ttl, &pb.PayerBandwidthAllocation{}); err != nil {
if err := psClient.Put(context.Background(), id, dataSection, ttl, &pb.PayerBandwidthAllocation{}, nil); err != nil {
fmt.Printf("Failed to Store data of id: %s\n", id)
return err
}
@ -140,7 +140,7 @@ func main() {
return err
}
rr, err := psClient.Get(ctx, client.PieceID(id), pieceInfo.Size, &pb.PayerBandwidthAllocation{})
rr, err := psClient.Get(ctx, client.PieceID(id), pieceInfo.Size, &pb.PayerBandwidthAllocation{}, nil)
if err != nil {
fmt.Printf("Failed to retrieve file of id: %s\n", id)
errRemove := os.Remove(outputDir)
@ -182,7 +182,7 @@ func main() {
Aliases: []string{"x"},
RunE: func(cmd *cobra.Command, args []string) error {
id := args[0]
return psClient.Delete(context.Background(), client.PieceID(id))
return psClient.Delete(context.Background(), client.PieceID(id), nil)
},
})

View File

@ -82,7 +82,14 @@ func (service *Service) Run(ctx context.Context, interval time.Duration) (err er
service.errs = append(service.errs, err)
cancel()
}
verifiedNodes, err := service.Verifier.verify(ctx, stripe.Index, stripe.Segment)
authorization, err := service.Cursor.pointers.SignedMessage()
if err != nil {
service.errs = append(service.errs, err)
cancel()
}
verifiedNodes, err := service.Verifier.verify(ctx, stripe.Index, stripe.Segment, authorization)
if err != nil {
service.errs = append(service.errs, err)
cancel()

View File

@ -35,7 +35,7 @@ type Verifier struct {
}
type downloader interface {
DownloadShares(ctx context.Context, pointer *pb.Pointer, stripeIndex int) (shares []share, nodes []*pb.Node, err error)
DownloadShares(ctx context.Context, pointer *pb.Pointer, stripeIndex int, authorization *pb.SignedMessage) (shares []share, nodes []*pb.Node, err error)
}
// defaultDownloader downloads shares from networked storage nodes
@ -67,7 +67,7 @@ func (d *defaultDownloader) dial(ctx context.Context, node *pb.Node) (ps client.
// getShare use piece store clients to download shares from a given node
func (d *defaultDownloader) getShare(ctx context.Context, stripeIndex, shareSize, pieceNumber int,
id client.PieceID, pieceSize int64, node *pb.Node) (s share, err error) {
id client.PieceID, pieceSize int64, node *pb.Node, authorization *pb.SignedMessage) (s share, err error) {
defer mon.Task()(&ctx)(&err)
ps, err := d.dial(ctx, node)
@ -80,7 +80,7 @@ func (d *defaultDownloader) getShare(ctx context.Context, stripeIndex, shareSize
return s, err
}
rr, err := ps.Get(ctx, derivedPieceID, pieceSize, &pb.PayerBandwidthAllocation{})
rr, err := ps.Get(ctx, derivedPieceID, pieceSize, &pb.PayerBandwidthAllocation{}, authorization)
if err != nil {
return s, err
}
@ -108,7 +108,7 @@ func (d *defaultDownloader) getShare(ctx context.Context, stripeIndex, shareSize
// Download Shares downloads shares from the nodes where remote pieces are located
func (d *defaultDownloader) DownloadShares(ctx context.Context, pointer *pb.Pointer,
stripeIndex int) (shares []share, nodes []*pb.Node, err error) {
stripeIndex int, authorization *pb.SignedMessage) (shares []share, nodes []*pb.Node, err error) {
defer mon.Task()(&ctx)(&err)
var nodeIds []dht.NodeID
pieces := pointer.Remote.GetRemotePieces()
@ -129,7 +129,7 @@ func (d *defaultDownloader) DownloadShares(ctx context.Context, pointer *pb.Poin
paddedSize := calcPadded(pointer.GetSize(), shareSize)
pieceSize := paddedSize / int64(pointer.Remote.Redundancy.GetMinReq())
s, err := d.getShare(ctx, stripeIndex, shareSize, i, pieceID, pieceSize, node)
s, err := d.getShare(ctx, stripeIndex, shareSize, i, pieceID, pieceSize, node, authorization)
if err != nil {
s = share{
Error: err,
@ -197,10 +197,10 @@ func calcPadded(size int64, blockSize int) int64 {
}
// verify downloads shares then verifies the data correctness at the given stripe
func (verifier *Verifier) verify(ctx context.Context, stripeIndex int, pointer *pb.Pointer) (verifiedNodes []*proto.Node, err error) {
func (verifier *Verifier) verify(ctx context.Context, stripeIndex int, pointer *pb.Pointer, authorization *pb.SignedMessage) (verifiedNodes []*proto.Node, err error) {
defer mon.Task()(&ctx)(&err)
shares, nodes, err := verifier.downloader.DownloadShares(ctx, pointer, stripeIndex)
shares, nodes, err := verifier.downloader.DownloadShares(ctx, pointer, stripeIndex, authorization)
if err != nil {
return nil, err
}

View File

@ -43,7 +43,7 @@ func TestPassingAudit(t *testing.T) {
md := mockDownloader{shares: mockShares}
verifier := &Verifier{downloader: &md}
pointer := makePointer(tt.nodeAmt)
verifiedNodes, err := verifier.verify(ctx, 6, pointer)
verifiedNodes, err := verifier.verify(ctx, 6, pointer, nil)
if err != nil {
t.Fatal(err)
}
@ -86,7 +86,7 @@ func TestSomeNodesPassAudit(t *testing.T) {
md := mockDownloader{shares: mockShares}
verifier := &Verifier{downloader: &md}
pointer := makePointer(tt.nodeAmt)
verifiedNodes, err := verifier.verify(ctx, 6, pointer)
verifiedNodes, err := verifier.verify(ctx, 6, pointer, nil)
if err != nil {
t.Fatal(err)
}
@ -202,7 +202,7 @@ func TestCalcPadded(t *testing.T) {
}
func (m *mockDownloader) DownloadShares(ctx context.Context, pointer *pb.Pointer,
stripeIndex int) (shares []share, nodes []*pb.Node, err error) {
stripeIndex int, authorization *pb.SignedMessage) (shares []share, nodes []*pb.Node, err error) {
for _, share := range m.shares {
shares = append(shares, share)
}

11
pkg/auth/auth.go Normal file
View File

@ -0,0 +1,11 @@
// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package auth
import (
"github.com/zeebo/errs"
)
// Error is the default auth error class
var Error = errs.Class("auth error")

View File

@ -13,11 +13,6 @@ import (
"storj.io/storj/pkg/provider"
)
// SignatureAuthProvider interface provides access to last signature auth data
type SignatureAuthProvider interface {
Auth() (*pb.SignatureAuth, error)
}
// GenerateSignature creates signature from identity id
func GenerateSignature(identity *provider.FullIdentity) ([]byte, error) {
if identity == nil {
@ -35,8 +30,8 @@ func GenerateSignature(identity *provider.FullIdentity) ([]byte, error) {
return signature, nil
}
// NewSignatureAuth creates instance of signature auth data
func NewSignatureAuth(signature []byte, identity *provider.PeerIdentity) (*pb.SignatureAuth, error) {
// NewSignedMessage creates instance of signed message
func NewSignedMessage(signature []byte, identity *provider.PeerIdentity) (*pb.SignedMessage, error) {
k, ok := identity.Leaf.PublicKey.(*ecdsa.PublicKey)
if !ok {
return nil, peertls.ErrUnsupportedKey.New("%T", identity.Leaf.PublicKey)
@ -46,9 +41,39 @@ func NewSignatureAuth(signature []byte, identity *provider.PeerIdentity) (*pb.Si
if err != nil {
return nil, err
}
return &pb.SignatureAuth{
return &pb.SignedMessage{
Data: identity.ID.Bytes(),
Signature: signature,
PublicKey: encodedKey,
}, nil
}
// SignedMessageVerifier checks if provided signed message can be verified
type SignedMessageVerifier func(signature *pb.SignedMessage) error
// NewSignedMessageVerifier creates default implementation of SignedMessageVerifier
func NewSignedMessageVerifier() SignedMessageVerifier {
return func(signedMessage *pb.SignedMessage) error {
if signedMessage == nil {
return Error.New("no message to verify")
}
if signedMessage.Signature == nil {
return Error.New("missing signature for verification")
}
if signedMessage.Data == nil {
return Error.New("missing data for verification")
}
if signedMessage.PublicKey == nil {
return Error.New("missing public key for verification")
}
k, err := cryptopasta.DecodePublicKey(signedMessage.GetPublicKey())
if err != nil {
return Error.Wrap(err)
}
if ok := cryptopasta.Verify(signedMessage.GetData(), signedMessage.GetSignature(), k); !ok {
return Error.New("failed to verify message")
}
return nil
}
}

View File

@ -38,3 +38,43 @@ func TestGenerateSignature(t *testing.T) {
assert.Equal(t, tt.verified, verified)
}
}
func TestSignedMessageVerifier(t *testing.T) {
ctx := context.Background()
ca, err := provider.NewCA(ctx, 12, 4)
assert.NoError(t, err)
identity, err := ca.NewIdentity()
assert.NoError(t, err)
signature, err := GenerateSignature(identity)
assert.NoError(t, err)
peerIdentity := &provider.PeerIdentity{ID: identity.ID, Leaf: identity.Leaf}
signedMessage, err := NewSignedMessage(signature, peerIdentity)
assert.NoError(t, err)
for _, tt := range []struct {
signature []byte
data []byte
publicKey []byte
errString string
}{
{signedMessage.Signature, signedMessage.Data, signedMessage.PublicKey, ""},
{nil, signedMessage.Data, signedMessage.PublicKey, "auth error: missing signature for verification"},
{signedMessage.Signature, nil, signedMessage.PublicKey, "auth error: missing data for verification"},
{signedMessage.Signature, signedMessage.Data, nil, "auth error: missing public key for verification"},
{signedMessage.Signature, []byte("malformed data"), signedMessage.PublicKey, "auth error: failed to verify message"},
} {
signedMessage.Signature = tt.signature
signedMessage.Data = tt.data
signedMessage.PublicKey = tt.publicKey
err := NewSignedMessageVerifier()(signedMessage)
if tt.errString != "" {
assert.EqualError(t, err, tt.errString)
} else {
assert.NoError(t, err)
}
}
}

View File

@ -35,7 +35,7 @@ func (m *PayerBandwidthAllocation) Reset() { *m = PayerBandwidthAllocati
func (m *PayerBandwidthAllocation) String() string { return proto.CompactTextString(m) }
func (*PayerBandwidthAllocation) ProtoMessage() {}
func (*PayerBandwidthAllocation) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{0}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{0}
}
func (m *PayerBandwidthAllocation) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PayerBandwidthAllocation.Unmarshal(m, b)
@ -84,7 +84,7 @@ func (m *PayerBandwidthAllocation_Data) Reset() { *m = PayerBandwidthAll
func (m *PayerBandwidthAllocation_Data) String() string { return proto.CompactTextString(m) }
func (*PayerBandwidthAllocation_Data) ProtoMessage() {}
func (*PayerBandwidthAllocation_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{0, 0}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{0, 0}
}
func (m *PayerBandwidthAllocation_Data) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PayerBandwidthAllocation_Data.Unmarshal(m, b)
@ -151,7 +151,7 @@ func (m *RenterBandwidthAllocation) Reset() { *m = RenterBandwidthAlloca
func (m *RenterBandwidthAllocation) String() string { return proto.CompactTextString(m) }
func (*RenterBandwidthAllocation) ProtoMessage() {}
func (*RenterBandwidthAllocation) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{1}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{1}
}
func (m *RenterBandwidthAllocation) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RenterBandwidthAllocation.Unmarshal(m, b)
@ -197,7 +197,7 @@ func (m *RenterBandwidthAllocation_Data) Reset() { *m = RenterBandwidthA
func (m *RenterBandwidthAllocation_Data) String() string { return proto.CompactTextString(m) }
func (*RenterBandwidthAllocation_Data) ProtoMessage() {}
func (*RenterBandwidthAllocation_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{1, 0}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{1, 0}
}
func (m *RenterBandwidthAllocation_Data) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RenterBandwidthAllocation_Data.Unmarshal(m, b)
@ -234,6 +234,7 @@ func (m *RenterBandwidthAllocation_Data) GetTotal() int64 {
type PieceStore struct {
Bandwidthallocation *RenterBandwidthAllocation `protobuf:"bytes,1,opt,name=bandwidthallocation,proto3" json:"bandwidthallocation,omitempty"`
Piecedata *PieceStore_PieceData `protobuf:"bytes,2,opt,name=piecedata,proto3" json:"piecedata,omitempty"`
Authorization *SignedMessage `protobuf:"bytes,3,opt,name=authorization,proto3" json:"authorization,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -243,7 +244,7 @@ func (m *PieceStore) Reset() { *m = PieceStore{} }
func (m *PieceStore) String() string { return proto.CompactTextString(m) }
func (*PieceStore) ProtoMessage() {}
func (*PieceStore) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{2}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{2}
}
func (m *PieceStore) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceStore.Unmarshal(m, b)
@ -277,6 +278,13 @@ func (m *PieceStore) GetPiecedata() *PieceStore_PieceData {
return nil
}
func (m *PieceStore) GetAuthorization() *SignedMessage {
if m != nil {
return m.Authorization
}
return nil
}
type PieceStore_PieceData struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
ExpirationUnixSec int64 `protobuf:"varint,2,opt,name=expiration_unix_sec,json=expirationUnixSec,proto3" json:"expiration_unix_sec,omitempty"`
@ -290,7 +298,7 @@ func (m *PieceStore_PieceData) Reset() { *m = PieceStore_PieceData{} }
func (m *PieceStore_PieceData) String() string { return proto.CompactTextString(m) }
func (*PieceStore_PieceData) ProtoMessage() {}
func (*PieceStore_PieceData) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{2, 0}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{2, 0}
}
func (m *PieceStore_PieceData) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceStore_PieceData.Unmarshal(m, b)
@ -342,7 +350,7 @@ func (m *PieceId) Reset() { *m = PieceId{} }
func (m *PieceId) String() string { return proto.CompactTextString(m) }
func (*PieceId) ProtoMessage() {}
func (*PieceId) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{3}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{3}
}
func (m *PieceId) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceId.Unmarshal(m, b)
@ -382,7 +390,7 @@ func (m *PieceSummary) Reset() { *m = PieceSummary{} }
func (m *PieceSummary) String() string { return proto.CompactTextString(m) }
func (*PieceSummary) ProtoMessage() {}
func (*PieceSummary) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{4}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{4}
}
func (m *PieceSummary) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceSummary.Unmarshal(m, b)
@ -426,6 +434,7 @@ func (m *PieceSummary) GetExpirationUnixSec() int64 {
type PieceRetrieval struct {
Bandwidthallocation *RenterBandwidthAllocation `protobuf:"bytes,1,opt,name=bandwidthallocation,proto3" json:"bandwidthallocation,omitempty"`
PieceData *PieceRetrieval_PieceData `protobuf:"bytes,2,opt,name=pieceData,proto3" json:"pieceData,omitempty"`
Authorization *SignedMessage `protobuf:"bytes,3,opt,name=authorization,proto3" json:"authorization,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -435,7 +444,7 @@ func (m *PieceRetrieval) Reset() { *m = PieceRetrieval{} }
func (m *PieceRetrieval) String() string { return proto.CompactTextString(m) }
func (*PieceRetrieval) ProtoMessage() {}
func (*PieceRetrieval) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{5}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{5}
}
func (m *PieceRetrieval) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceRetrieval.Unmarshal(m, b)
@ -469,6 +478,13 @@ func (m *PieceRetrieval) GetPieceData() *PieceRetrieval_PieceData {
return nil
}
func (m *PieceRetrieval) GetAuthorization() *SignedMessage {
if m != nil {
return m.Authorization
}
return nil
}
type PieceRetrieval_PieceData struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"`
@ -482,7 +498,7 @@ func (m *PieceRetrieval_PieceData) Reset() { *m = PieceRetrieval_PieceDa
func (m *PieceRetrieval_PieceData) String() string { return proto.CompactTextString(m) }
func (*PieceRetrieval_PieceData) ProtoMessage() {}
func (*PieceRetrieval_PieceData) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{5, 0}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{5, 0}
}
func (m *PieceRetrieval_PieceData) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceRetrieval_PieceData.Unmarshal(m, b)
@ -535,7 +551,7 @@ func (m *PieceRetrievalStream) Reset() { *m = PieceRetrievalStream{} }
func (m *PieceRetrievalStream) String() string { return proto.CompactTextString(m) }
func (*PieceRetrievalStream) ProtoMessage() {}
func (*PieceRetrievalStream) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{6}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{6}
}
func (m *PieceRetrievalStream) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceRetrievalStream.Unmarshal(m, b)
@ -570,17 +586,18 @@ func (m *PieceRetrievalStream) GetContent() []byte {
}
type PieceDelete struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Authorization *SignedMessage `protobuf:"bytes,3,opt,name=authorization,proto3" json:"authorization,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PieceDelete) Reset() { *m = PieceDelete{} }
func (m *PieceDelete) String() string { return proto.CompactTextString(m) }
func (*PieceDelete) ProtoMessage() {}
func (*PieceDelete) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{7}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{7}
}
func (m *PieceDelete) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceDelete.Unmarshal(m, b)
@ -607,6 +624,13 @@ func (m *PieceDelete) GetId() string {
return ""
}
func (m *PieceDelete) GetAuthorization() *SignedMessage {
if m != nil {
return m.Authorization
}
return nil
}
type PieceDeleteSummary struct {
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
@ -618,7 +642,7 @@ func (m *PieceDeleteSummary) Reset() { *m = PieceDeleteSummary{} }
func (m *PieceDeleteSummary) String() string { return proto.CompactTextString(m) }
func (*PieceDeleteSummary) ProtoMessage() {}
func (*PieceDeleteSummary) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{8}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{8}
}
func (m *PieceDeleteSummary) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceDeleteSummary.Unmarshal(m, b)
@ -657,7 +681,7 @@ func (m *PieceStoreSummary) Reset() { *m = PieceStoreSummary{} }
func (m *PieceStoreSummary) String() string { return proto.CompactTextString(m) }
func (*PieceStoreSummary) ProtoMessage() {}
func (*PieceStoreSummary) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{9}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{9}
}
func (m *PieceStoreSummary) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceStoreSummary.Unmarshal(m, b)
@ -701,7 +725,7 @@ func (m *StatsReq) Reset() { *m = StatsReq{} }
func (m *StatsReq) String() string { return proto.CompactTextString(m) }
func (*StatsReq) ProtoMessage() {}
func (*StatsReq) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{10}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{10}
}
func (m *StatsReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StatsReq.Unmarshal(m, b)
@ -735,7 +759,7 @@ func (m *StatSummary) Reset() { *m = StatSummary{} }
func (m *StatSummary) String() string { return proto.CompactTextString(m) }
func (*StatSummary) ProtoMessage() {}
func (*StatSummary) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{11}
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{11}
}
func (m *StatSummary) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StatSummary.Unmarshal(m, b)
@ -783,7 +807,7 @@ func (m *StatSummary) GetAvailableBandwidth() int64 {
return 0
}
type SignatureAuth struct {
type SignedMessage struct {
Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
PublicKey []byte `protobuf:"bytes,3,opt,name=publicKey,proto3" json:"publicKey,omitempty"`
@ -792,45 +816,45 @@ type SignatureAuth struct {
XXX_sizecache int32 `json:"-"`
}
func (m *SignatureAuth) Reset() { *m = SignatureAuth{} }
func (m *SignatureAuth) String() string { return proto.CompactTextString(m) }
func (*SignatureAuth) ProtoMessage() {}
func (*SignatureAuth) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{12}
func (m *SignedMessage) Reset() { *m = SignedMessage{} }
func (m *SignedMessage) String() string { return proto.CompactTextString(m) }
func (*SignedMessage) ProtoMessage() {}
func (*SignedMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_83d494dbeb442cfc, []int{12}
}
func (m *SignatureAuth) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SignatureAuth.Unmarshal(m, b)
func (m *SignedMessage) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SignedMessage.Unmarshal(m, b)
}
func (m *SignatureAuth) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SignatureAuth.Marshal(b, m, deterministic)
func (m *SignedMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SignedMessage.Marshal(b, m, deterministic)
}
func (dst *SignatureAuth) XXX_Merge(src proto.Message) {
xxx_messageInfo_SignatureAuth.Merge(dst, src)
func (dst *SignedMessage) XXX_Merge(src proto.Message) {
xxx_messageInfo_SignedMessage.Merge(dst, src)
}
func (m *SignatureAuth) XXX_Size() int {
return xxx_messageInfo_SignatureAuth.Size(m)
func (m *SignedMessage) XXX_Size() int {
return xxx_messageInfo_SignedMessage.Size(m)
}
func (m *SignatureAuth) XXX_DiscardUnknown() {
xxx_messageInfo_SignatureAuth.DiscardUnknown(m)
func (m *SignedMessage) XXX_DiscardUnknown() {
xxx_messageInfo_SignedMessage.DiscardUnknown(m)
}
var xxx_messageInfo_SignatureAuth proto.InternalMessageInfo
var xxx_messageInfo_SignedMessage proto.InternalMessageInfo
func (m *SignatureAuth) GetData() []byte {
func (m *SignedMessage) GetData() []byte {
if m != nil {
return m.Data
}
return nil
}
func (m *SignatureAuth) GetSignature() []byte {
func (m *SignedMessage) GetSignature() []byte {
if m != nil {
return m.Signature
}
return nil
}
func (m *SignatureAuth) GetPublicKey() []byte {
func (m *SignedMessage) GetPublicKey() []byte {
if m != nil {
return m.PublicKey
}
@ -854,7 +878,7 @@ func init() {
proto.RegisterType((*PieceStoreSummary)(nil), "piecestoreroutes.PieceStoreSummary")
proto.RegisterType((*StatsReq)(nil), "piecestoreroutes.StatsReq")
proto.RegisterType((*StatSummary)(nil), "piecestoreroutes.StatSummary")
proto.RegisterType((*SignatureAuth)(nil), "piecestoreroutes.SignatureAuth")
proto.RegisterType((*SignedMessage)(nil), "piecestoreroutes.SignedMessage")
}
// Reference imports to suppress errors if they are not otherwise used.
@ -1128,55 +1152,57 @@ var _PieceStoreRoutes_serviceDesc = grpc.ServiceDesc{
Metadata: "piecestore.proto",
}
func init() { proto.RegisterFile("piecestore.proto", fileDescriptor_piecestore_b29c3a3a1a7e53a5) }
func init() { proto.RegisterFile("piecestore.proto", fileDescriptor_piecestore_83d494dbeb442cfc) }
var fileDescriptor_piecestore_b29c3a3a1a7e53a5 = []byte{
// 737 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xdd, 0x4a, 0xdc, 0x40,
0x14, 0x36, 0xd9, 0x3f, 0xf7, 0xec, 0x6a, 0x75, 0x14, 0xc9, 0x86, 0xb5, 0x2c, 0x51, 0x64, 0xb1,
0xb0, 0x14, 0xfb, 0x04, 0xca, 0x42, 0x2b, 0x05, 0x2b, 0x09, 0xde, 0x08, 0x65, 0x99, 0x4d, 0x8e,
0x3a, 0x90, 0x4d, 0xd2, 0x64, 0x62, 0x57, 0x2f, 0xfb, 0x14, 0x85, 0xde, 0xf6, 0xa6, 0xaf, 0xd1,
0x57, 0xea, 0x0b, 0x94, 0xcc, 0xe4, 0x67, 0xff, 0xb2, 0xde, 0xb4, 0x77, 0x73, 0xfe, 0xbe, 0xf3,
0x9d, 0x9f, 0x1c, 0x02, 0x3b, 0x01, 0x43, 0x1b, 0x23, 0xee, 0x87, 0x38, 0x08, 0x42, 0x9f, 0xfb,
0x64, 0x46, 0x13, 0xfa, 0x31, 0xc7, 0xc8, 0xf8, 0xa3, 0x80, 0x76, 0x4d, 0x9f, 0x30, 0xbc, 0xa0,
0x9e, 0xf3, 0x95, 0x39, 0xfc, 0xe1, 0xdc, 0x75, 0x7d, 0x9b, 0x72, 0xe6, 0x7b, 0xa4, 0x0b, 0xcd,
0x88, 0xdd, 0x7b, 0x94, 0xc7, 0x21, 0x6a, 0x4a, 0x4f, 0xe9, 0xb7, 0xcd, 0x42, 0x41, 0x08, 0x54,
0x1d, 0xca, 0xa9, 0xa6, 0x0a, 0x83, 0x78, 0xeb, 0x3f, 0x15, 0xa8, 0x0e, 0x29, 0xa7, 0x64, 0x1f,
0x6a, 0x41, 0x02, 0x9b, 0x86, 0x49, 0x81, 0x1c, 0x40, 0x3d, 0x44, 0x8f, 0x63, 0x98, 0x06, 0xa5,
0x12, 0xe9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, 0x84, 0x2d, 0x08, 0x00,
0x00,
var fileDescriptor_piecestore_83d494dbeb442cfc = []byte{
// 772 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xdd, 0x4e, 0xdb, 0x48,
0x14, 0xc6, 0xce, 0x1f, 0x39, 0x49, 0x58, 0x18, 0x10, 0x72, 0xac, 0xb0, 0x1b, 0x19, 0x84, 0x22,
0x56, 0x8a, 0x56, 0xec, 0x13, 0x2c, 0xca, 0x6a, 0x17, 0x55, 0xa5, 0x68, 0x2c, 0x6e, 0x90, 0xaa,
0x68, 0x62, 0x1f, 0x60, 0x24, 0xc7, 0x4e, 0xed, 0x31, 0x0d, 0xbc, 0x4a, 0x6f, 0x7b, 0xd3, 0xd7,
0xe8, 0x5d, 0x9f, 0xa2, 0x0f, 0xd1, 0x17, 0xa8, 0x3c, 0xe3, 0xd8, 0xf9, 0x73, 0xb8, 0xa1, 0x77,
0x3e, 0x7f, 0xdf, 0xf9, 0xce, 0xcf, 0x9c, 0x04, 0x76, 0x27, 0x1c, 0x1d, 0x8c, 0x44, 0x10, 0x62,
0x7f, 0x12, 0x06, 0x22, 0x20, 0x73, 0x9a, 0x30, 0x88, 0x05, 0x46, 0xd6, 0x0f, 0x0d, 0x8c, 0x6b,
0xf6, 0x84, 0xe1, 0x05, 0xf3, 0xdd, 0x8f, 0xdc, 0x15, 0x0f, 0xff, 0x78, 0x5e, 0xe0, 0x30, 0xc1,
0x03, 0x9f, 0x74, 0xa0, 0x1e, 0xf1, 0x7b, 0x9f, 0x89, 0x38, 0x44, 0x43, 0xeb, 0x6a, 0xbd, 0x26,
0xcd, 0x15, 0x84, 0x40, 0xd9, 0x65, 0x82, 0x19, 0xba, 0x34, 0xc8, 0x6f, 0xf3, 0xb3, 0x06, 0xe5,
0x01, 0x13, 0x8c, 0x1c, 0x40, 0x65, 0x92, 0xc0, 0xa6, 0x61, 0x4a, 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36, 0x4f, 0x36, 0x9a, 0xf3, 0xe2, 0x07, 0x09, 0x41, 0x26, 0x22, 0x62,
0xae, 0x79, 0x2e, 0xe9, 0x26, 0x9a, 0x47, 0xeb, 0x6d, 0x19, 0xca, 0x45, 0xf9, 0x56, 0x9f, 0x8c,
0x46, 0x55, 0xf9, 0x77, 0xe7, 0xef, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd5, 0x30, 0x0c, 0x12,
0x02, 0x09, 0x00, 0x00,
}

View File

@ -49,6 +49,7 @@ message PieceStore {
RenterBandwidthAllocation bandwidthallocation = 1;
PieceData piecedata = 2;
SignedMessage authorization = 3;
}
message PieceId {
@ -70,6 +71,7 @@ message PieceRetrieval {
RenterBandwidthAllocation bandwidthallocation = 1;
PieceData pieceData = 2;
SignedMessage authorization = 3;
}
message PieceRetrievalStream {
@ -79,6 +81,7 @@ message PieceRetrievalStream {
message PieceDelete {
string id = 1;
SignedMessage authorization = 3;
}
message PieceDeleteSummary {
@ -99,7 +102,7 @@ message StatSummary {
int64 availableBandwidth = 4;
}
message SignatureAuth {
message SignedMessage {
bytes data = 1;
bytes signature = 2;
bytes publicKey = 3;

View File

@ -38,9 +38,9 @@ var (
// PSClient is an interface describing the functions for interacting with piecestore nodes
type PSClient interface {
Meta(ctx context.Context, id PieceID) (*pb.PieceSummary, error)
Put(ctx context.Context, id PieceID, data io.Reader, ttl time.Time, ba *pb.PayerBandwidthAllocation) error
Get(ctx context.Context, id PieceID, size int64, ba *pb.PayerBandwidthAllocation) (ranger.Ranger, error)
Delete(ctx context.Context, pieceID PieceID) error
Put(ctx context.Context, id PieceID, data io.Reader, ttl time.Time, ba *pb.PayerBandwidthAllocation, authorization *pb.SignedMessage) error
Get(ctx context.Context, id PieceID, size int64, ba *pb.PayerBandwidthAllocation, authorization *pb.SignedMessage) (ranger.Ranger, error)
Delete(ctx context.Context, pieceID PieceID, authorization *pb.SignedMessage) error
Stats(ctx context.Context) (*pb.StatSummary, error)
io.Closer
}
@ -99,13 +99,16 @@ func (client *Client) Meta(ctx context.Context, id PieceID) (*pb.PieceSummary, e
}
// Put uploads a Piece to a piece store Server
func (client *Client) Put(ctx context.Context, id PieceID, data io.Reader, ttl time.Time, ba *pb.PayerBandwidthAllocation) error {
func (client *Client) Put(ctx context.Context, id PieceID, data io.Reader, ttl time.Time, ba *pb.PayerBandwidthAllocation, authorization *pb.SignedMessage) error {
stream, err := client.route.Store(ctx)
if err != nil {
return err
}
msg := &pb.PieceStore{Piecedata: &pb.PieceStore_PieceData{Id: id.String(), ExpirationUnixSec: ttl.Unix()}}
msg := &pb.PieceStore{
Piecedata: &pb.PieceStore_PieceData{Id: id.String(), ExpirationUnixSec: ttl.Unix()},
Authorization: authorization,
}
if err = stream.Send(msg); err != nil {
if _, closeErr := stream.CloseAndRecv(); closeErr != nil {
zap.S().Errorf("error closing stream %s :: %v.Send() = %v", closeErr, stream, closeErr)
@ -128,7 +131,7 @@ func (client *Client) Put(ctx context.Context, id PieceID, data io.Reader, ttl t
if err == io.ErrUnexpectedEOF {
_ = writer.Close()
zap.S().Infof("Node cut from upload due to slow connection. Deleting piece %s...", id)
deleteErr := client.Delete(ctx, id)
deleteErr := client.Delete(ctx, id, authorization)
if deleteErr != nil {
return deleteErr
}
@ -141,18 +144,18 @@ func (client *Client) Put(ctx context.Context, id PieceID, data io.Reader, ttl t
}
// Get begins downloading a Piece from a piece store Server
func (client *Client) Get(ctx context.Context, id PieceID, size int64, ba *pb.PayerBandwidthAllocation) (ranger.Ranger, error) {
func (client *Client) Get(ctx context.Context, id PieceID, size int64, ba *pb.PayerBandwidthAllocation, authorization *pb.SignedMessage) (ranger.Ranger, error) {
stream, err := client.route.Retrieve(ctx)
if err != nil {
return nil, err
}
return PieceRangerSize(client, stream, id, size, ba), nil
return PieceRangerSize(client, stream, id, size, ba, authorization), nil
}
// Delete a Piece from a piece store Server
func (client *Client) Delete(ctx context.Context, id PieceID) error {
reply, err := client.route.Delete(ctx, &pb.PieceDelete{Id: id.String()})
func (client *Client) Delete(ctx context.Context, id PieceID, authorization *pb.SignedMessage) error {
reply, err := client.route.Delete(ctx, &pb.PieceDelete{Id: id.String(), Authorization: authorization})
if err != nil {
return err
}

View File

@ -19,27 +19,28 @@ import (
var Error = errs.Class("pieceRanger error")
type pieceRanger struct {
c *Client
id PieceID
size int64
stream pb.PieceStoreRoutes_RetrieveClient
pba *pb.PayerBandwidthAllocation
c *Client
id PieceID
size int64
stream pb.PieceStoreRoutes_RetrieveClient
pba *pb.PayerBandwidthAllocation
authorization *pb.SignedMessage
}
// PieceRanger PieceRanger returns a Ranger from a PieceID.
func PieceRanger(ctx context.Context, c *Client, stream pb.PieceStoreRoutes_RetrieveClient, id PieceID, pba *pb.PayerBandwidthAllocation) (ranger.Ranger, error) {
func PieceRanger(ctx context.Context, c *Client, stream pb.PieceStoreRoutes_RetrieveClient, id PieceID, pba *pb.PayerBandwidthAllocation, authorization *pb.SignedMessage) (ranger.Ranger, error) {
piece, err := c.Meta(ctx, id)
if err != nil {
return nil, err
}
return &pieceRanger{c: c, id: id, size: piece.Size, stream: stream, pba: pba}, nil
return &pieceRanger{c: c, id: id, size: piece.Size, stream: stream, pba: pba, authorization: authorization}, nil
}
// PieceRangerSize creates a PieceRanger with known size.
// Use it if you know the piece size. This will safe the extra request for
// retrieving the piece size from the piece storage.
func PieceRangerSize(c *Client, stream pb.PieceStoreRoutes_RetrieveClient, id PieceID, size int64, pba *pb.PayerBandwidthAllocation) ranger.Ranger {
return &pieceRanger{c: c, id: id, size: size, stream: stream, pba: pba}
func PieceRangerSize(c *Client, stream pb.PieceStoreRoutes_RetrieveClient, id PieceID, size int64, pba *pb.PayerBandwidthAllocation, authorization *pb.SignedMessage) ranger.Ranger {
return &pieceRanger{c: c, id: id, size: size, stream: stream, pba: pba, authorization: authorization}
}
// Size implements Ranger.Size
@ -63,7 +64,7 @@ func (r *pieceRanger) Range(ctx context.Context, offset, length int64) (io.ReadC
}
// send piece data
if err := r.stream.Send(&pb.PieceRetrieval{PieceData: &pb.PieceRetrieval_PieceData{Id: r.id.String(), Size: length, Offset: offset}}); err != nil {
if err := r.stream.Send(&pb.PieceRetrieval{PieceData: &pb.PieceRetrieval_PieceData{Id: r.id.String(), Size: length, Offset: offset}, Authorization: r.authorization}); err != nil {
return nil, err
}

View File

@ -77,7 +77,7 @@ func TestPieceRanger(t *testing.T) {
c, err := NewCustomRoute(route, 32*1024, priv)
assert.NoError(t, err)
rr, err := PieceRanger(ctx, c, stream, pid, &pb.PayerBandwidthAllocation{})
rr, err := PieceRanger(ctx, c, stream, pid, &pb.PayerBandwidthAllocation{}, nil)
if assert.NoError(t, err, errTag) {
assert.Equal(t, tt.size, rr.Size(), errTag)
}
@ -148,7 +148,7 @@ func TestPieceRangerSize(t *testing.T) {
c, err := NewCustomRoute(route, 32*1024, priv)
assert.NoError(t, err)
rr := PieceRangerSize(c, stream, pid, tt.size, &pb.PayerBandwidthAllocation{})
rr := PieceRangerSize(c, stream, pid, tt.size, &pb.PayerBandwidthAllocation{}, nil)
assert.Equal(t, tt.size, rr.Size(), errTag)
r, err := rr.Range(ctx, tt.offset, tt.length)
if tt.errString != "" {

View File

@ -37,6 +37,11 @@ func (s *Server) Retrieve(stream pb.PieceStoreRoutes_RetrieveServer) (err error)
return RetrieveError.New("error receiving piece data")
}
authorization := recv.GetAuthorization()
if err := s.verifier(authorization); err != nil {
return err
}
pd := recv.GetPieceData()
if pd == nil {
return RetrieveError.New("PieceStore message is nil")

View File

@ -20,6 +20,7 @@ import (
"golang.org/x/net/context"
monkit "gopkg.in/spacemonkeygo/monkit.v2"
"storj.io/storj/pkg/auth"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/peertls"
pstore "storj.io/storj/pkg/piecestore"
@ -84,6 +85,7 @@ type Server struct {
pkey crypto.PrivateKey
totalAllocated int64
totalBwAllocated int64
verifier auth.SignedMessageVerifier
}
// Initialize -- initializes a server struct
@ -151,7 +153,8 @@ func Initialize(ctx context.Context, config Config, pkey crypto.PrivateKey) (*Se
return &Server{DataDir: dataDir, DB: db, pkey: pkey, totalAllocated: allocatedDiskSpace, totalBwAllocated: allocatedBandwidth}, nil
}
return &Server{DataDir: dataDir, DB: db, pkey: pkey, totalAllocated: allocatedDiskSpace, totalBwAllocated: allocatedBandwidth}, nil
signatureVerifier := auth.NewSignedMessageVerifier()
return &Server{DataDir: dataDir, DB: db, pkey: pkey, totalAllocated: allocatedDiskSpace, totalBwAllocated: allocatedBandwidth, verifier: signatureVerifier}, nil
}
// Stop the piececstore node
@ -213,6 +216,11 @@ func (s *Server) Stats(ctx context.Context, in *pb.StatsReq) (*pb.StatSummary, e
func (s *Server) Delete(ctx context.Context, in *pb.PieceDelete) (*pb.PieceDeleteSummary, error) {
log.Printf("Deleting %s...", in.GetId())
authorization := in.GetAuthorization()
if err := s.verifier(authorization); err != nil {
return nil, err
}
if err := s.deleteByID(in.GetId()); err != nil {
return nil, err
}

View File

@ -492,7 +492,10 @@ func newTestServerStruct(t *testing.T) (*Server, func()) {
t.Fatalf("failed open psdb: %v", err)
}
server := &Server{DataDir: tempDir, DB: psDB}
verifier := func(authorization *pb.SignedMessage) error {
return nil
}
server := &Server{DataDir: tempDir, DB: psDB, verifier: verifier}
return server, func() {
if serr := server.Stop(ctx); serr != nil {
t.Fatal(serr)

View File

@ -34,6 +34,11 @@ func (s *Server) Store(reqStream pb.PieceStoreRoutes_StoreServer) (err error) {
return StoreError.New("Error receiving Piece metadata")
}
authorization := recv.GetAuthorization()
if err := s.verifier(authorization); err != nil {
return err
}
pd := recv.GetPiecedata()
if pd == nil {
return StoreError.New("PieceStore message is nil")

View File

@ -57,6 +57,8 @@ type Client interface {
recursive bool, limit int, metaFlags uint32) (
items []ListItem, more bool, err error)
Delete(ctx context.Context, path p.Path) error
SignedMessage() (*pb.SignedMessage, error)
}
// NewClient initializes a new pointerdb client
@ -154,8 +156,8 @@ func (pdb *PointerDB) Delete(ctx context.Context, path p.Path) (err error) {
return err
}
// Auth gets signature auth data from last request
func (pdb *PointerDB) Auth() (*pb.SignatureAuth, 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
@ -171,5 +173,5 @@ func (pdb *PointerDB) Auth() (*pb.SignatureAuth, error) {
return nil, err
}
return auth.NewSignatureAuth(decodedSignature, identity)
return auth.NewSignedMessage(decodedSignature, identity)
}

View File

@ -302,7 +302,7 @@ func TestDelete(t *testing.T) {
}
}
func TestAuth(t *testing.T) {
func TestSignedMessage(t *testing.T) {
ctx := context.Background()
ca, err := provider.NewCA(ctx, 12, 4)
assert.NoError(t, err)
@ -324,10 +324,14 @@ func TestAuth(t *testing.T) {
peer: peer,
}
auth, _ := pointerdb.Auth()
auth, err := pointerdb.SignedMessage()
assert.NoError(t, err)
pk, _ := identity.Leaf.PublicKey.(*ecdsa.PublicKey)
expectedKey, _ := cryptopasta.EncodePublicKey(pk)
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())

View File

@ -1,18 +1,18 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: storj.io/storj/pkg/pb/pdbclient (interfaces: Client)
// Source: storj.io/storj/pkg/pointerdb/pdbclient (interfaces: Client)
// Package mock_pointerdb is a generated GoMock package.
package mock_pointerdb
import (
context "context"
reflect "reflect"
"reflect"
gomock "github.com/golang/mock/gomock"
paths "storj.io/storj/pkg/paths"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/pointerdb/pdbclient"
pb "storj.io/storj/pkg/pb"
pdbclient "storj.io/storj/pkg/pointerdb/pdbclient"
)
// MockClient is a mock of Client interface
@ -88,3 +88,16 @@ func (m *MockClient) Put(arg0 context.Context, arg1 paths.Path, arg2 *pb.Pointer
func (mr *MockClientMockRecorder) Put(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Put", reflect.TypeOf((*MockClient)(nil).Put), arg0, arg1, arg2)
}
// SignedMessage mocks base method
func (m *MockClient) SignedMessage() (*pb.SignedMessage, error) {
ret := m.ctrl.Call(m, "SignedMessage")
ret0, _ := ret[0].(*pb.SignedMessage)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SignedMessage indicates an expected call of SignedMessage
func (mr *MockClientMockRecorder) SignedMessage() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SignedMessage", reflect.TypeOf((*MockClient)(nil).SignedMessage))
}

View File

@ -27,10 +27,10 @@ var mon = monkit.Package()
// Client defines an interface for storing erasure coded data to piece store nodes
type Client interface {
Put(ctx context.Context, nodes []*pb.Node, rs eestream.RedundancyStrategy,
pieceID client.PieceID, data io.Reader, expiration time.Time) (successfulNodes []*pb.Node, err error)
pieceID client.PieceID, data io.Reader, expiration time.Time, authorization *pb.SignedMessage) (successfulNodes []*pb.Node, err error)
Get(ctx context.Context, nodes []*pb.Node, es eestream.ErasureScheme,
pieceID client.PieceID, size int64) (ranger.Ranger, error)
Delete(ctx context.Context, nodes []*pb.Node, pieceID client.PieceID) error
pieceID client.PieceID, size int64, authorization *pb.SignedMessage) (ranger.Ranger, error)
Delete(ctx context.Context, nodes []*pb.Node, pieceID client.PieceID, authorization *pb.SignedMessage) error
}
type dialer interface {
@ -65,7 +65,7 @@ func NewClient(identity *provider.FullIdentity, transport transport.Client, mbm
}
func (ec *ecClient) Put(ctx context.Context, nodes []*pb.Node, rs eestream.RedundancyStrategy,
pieceID client.PieceID, data io.Reader, expiration time.Time) (successfulNodes []*pb.Node, err error) {
pieceID client.PieceID, data io.Reader, expiration time.Time, authorization *pb.SignedMessage) (successfulNodes []*pb.Node, err error) {
defer mon.Task()(&ctx)(&err)
if len(nodes) != rs.TotalCount() {
@ -109,8 +109,7 @@ func (ec *ecClient) Put(ctx context.Context, nodes []*pb.Node, rs eestream.Redun
infos <- info{i: i, err: err}
return
}
err = ps.Put(ctx, derivedPieceID, readers[i], expiration, &pb.PayerBandwidthAllocation{})
err = ps.Put(ctx, derivedPieceID, readers[i], expiration, &pb.PayerBandwidthAllocation{}, authorization)
// normally the bellow call should be deferred, but doing so fails
// randomly the unit tests
utils.LogClose(ps)
@ -140,7 +139,7 @@ func (ec *ecClient) Put(ctx context.Context, nodes []*pb.Node, rs eestream.Redun
case <-ctx.Done():
err = utils.CombineErrors(
Error.New("upload cancelled by user"),
ec.Delete(context.Background(), nodes, pieceID),
ec.Delete(context.Background(), nodes, pieceID, authorization),
)
default:
}
@ -154,7 +153,7 @@ func (ec *ecClient) Put(ctx context.Context, nodes []*pb.Node, rs eestream.Redun
}
func (ec *ecClient) Get(ctx context.Context, nodes []*pb.Node, es eestream.ErasureScheme,
pieceID client.PieceID, size int64) (rr ranger.Ranger, err error) {
pieceID client.PieceID, size int64, authorization *pb.SignedMessage) (rr ranger.Ranger, err error) {
defer mon.Task()(&ctx)(&err)
if len(nodes) != es.TotalCount() {
@ -187,11 +186,12 @@ func (ec *ecClient) Get(ctx context.Context, nodes []*pb.Node, es eestream.Erasu
}
rr := &lazyPieceRanger{
dialer: ec.d,
node: n,
id: derivedPieceID,
size: pieceSize,
pba: &pb.PayerBandwidthAllocation{},
dialer: ec.d,
node: n,
id: derivedPieceID,
size: pieceSize,
pba: &pb.PayerBandwidthAllocation{},
authorization: authorization,
}
ch <- rangerInfo{i: i, rr: rr, err: nil}
@ -213,7 +213,7 @@ func (ec *ecClient) Get(ctx context.Context, nodes []*pb.Node, es eestream.Erasu
return eestream.Unpad(rr, int(paddedSize-size))
}
func (ec *ecClient) Delete(ctx context.Context, nodes []*pb.Node, pieceID client.PieceID) (err error) {
func (ec *ecClient) Delete(ctx context.Context, nodes []*pb.Node, pieceID client.PieceID, authorization *pb.SignedMessage) (err error) {
defer mon.Task()(&ctx)(&err)
errs := make(chan error, len(nodes))
@ -238,7 +238,7 @@ func (ec *ecClient) Delete(ctx context.Context, nodes []*pb.Node, pieceID client
errs <- err
return
}
err = ps.Delete(ctx, derivedPieceID)
err = ps.Delete(ctx, derivedPieceID, authorization)
// normally the bellow call should be deferred, but doing so fails
// randomly the unit tests
utils.LogClose(ps)
@ -300,12 +300,13 @@ func calcPadded(size int64, blockSize int) int64 {
}
type lazyPieceRanger struct {
ranger ranger.Ranger
dialer dialer
node *pb.Node
id client.PieceID
size int64
pba *pb.PayerBandwidthAllocation
ranger ranger.Ranger
dialer dialer
node *pb.Node
id client.PieceID
size int64
pba *pb.PayerBandwidthAllocation
authorization *pb.SignedMessage
}
// Size implements Ranger.Size
@ -320,7 +321,7 @@ func (lr *lazyPieceRanger) Range(ctx context.Context, offset, length int64) (io.
if err != nil {
return nil, err
}
ranger, err := ps.Get(ctx, lr.id, lr.size, lr.pba)
ranger, err := ps.Get(ctx, lr.id, lr.size, lr.pba, lr.authorization)
if err != nil {
return nil, err
}

View File

@ -178,8 +178,8 @@ TestLoop:
}
ps := NewMockPSClient(ctrl)
gomock.InOrder(
ps.EXPECT().Put(gomock.Any(), derivedID, gomock.Any(), ttl, gomock.Any()).Return(errs[n]).
Do(func(ctx context.Context, id client.PieceID, data io.Reader, ttl time.Time, ba *pb.PayerBandwidthAllocation) {
ps.EXPECT().Put(gomock.Any(), derivedID, gomock.Any(), ttl, gomock.Any(), gomock.Any()).Return(errs[n]).
Do(func(ctx context.Context, id client.PieceID, data io.Reader, ttl time.Time, ba *pb.PayerBandwidthAllocation, authorization *pb.SignedMessage) {
// simulate that the mocked piece store client is reading the data
_, err := io.Copy(ioutil.Discard, data)
assert.NoError(t, err, errTag)
@ -195,7 +195,7 @@ TestLoop:
r := io.LimitReader(rand.Reader, int64(size))
ec := ecClient{d: &mockDialer{m: m}, mbm: tt.mbm}
successfulNodes, err := ec.Put(ctx, tt.nodes, rs, id, r, ttl)
successfulNodes, err := ec.Put(ctx, tt.nodes, rs, id, r, ttl, nil)
if tt.errString != "" {
assert.EqualError(t, err, tt.errString, errTag)
@ -269,12 +269,12 @@ TestLoop:
continue TestLoop
}
ps := NewMockPSClient(ctrl)
ps.EXPECT().Get(gomock.Any(), derivedID, int64(size/k), gomock.Any()).Return(ranger.ByteRanger(nil), errs[n])
ps.EXPECT().Get(gomock.Any(), derivedID, int64(size/k), gomock.Any(), gomock.Any()).Return(ranger.ByteRanger(nil), errs[n])
m[n] = ps
}
}
ec := ecClient{d: &mockDialer{m: m}, mbm: tt.mbm}
rr, err := ec.Get(ctx, tt.nodes, es, id, int64(size))
rr, err := ec.Get(ctx, tt.nodes, es, id, int64(size), nil)
if err == nil {
_, err := rr.Range(ctx, 0, 0)
assert.NoError(t, err, errTag)
@ -329,7 +329,7 @@ TestLoop:
}
ps := NewMockPSClient(ctrl)
gomock.InOrder(
ps.EXPECT().Delete(gomock.Any(), derivedID).Return(errs[n]),
ps.EXPECT().Delete(gomock.Any(), derivedID, gomock.Any()).Return(errs[n]),
ps.EXPECT().Close().Return(nil),
)
m[n] = ps
@ -337,7 +337,7 @@ TestLoop:
}
ec := ecClient{d: &mockDialer{m: m}}
err := ec.Delete(ctx, tt.nodes, id)
err := ec.Delete(ctx, tt.nodes, id, nil)
if tt.errString != "" {
assert.EqualError(t, err, tt.errString, errTag)

View File

@ -6,16 +6,14 @@ package mock_ecclient
import (
context "context"
gomock "github.com/golang/mock/gomock"
io "io"
reflect "reflect"
time "time"
gomock "github.com/golang/mock/gomock"
eestream "storj.io/storj/pkg/eestream"
pb "storj.io/storj/pkg/pb"
client "storj.io/storj/pkg/piecestore/rpc/client"
ranger "storj.io/storj/pkg/ranger"
time "time"
)
// MockClient is a mock of Client interface
@ -42,39 +40,39 @@ func (m *MockClient) EXPECT() *MockClientMockRecorder {
}
// Delete mocks base method
func (m *MockClient) Delete(arg0 context.Context, arg1 []*pb.Node, arg2 client.PieceID) error {
ret := m.ctrl.Call(m, "Delete", arg0, arg1, arg2)
func (m *MockClient) Delete(arg0 context.Context, arg1 []*pb.Node, arg2 client.PieceID, arg3 *pb.SignedMessage) error {
ret := m.ctrl.Call(m, "Delete", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(error)
return ret0
}
// Delete indicates an expected call of Delete
func (mr *MockClientMockRecorder) Delete(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockClient)(nil).Delete), arg0, arg1, arg2)
func (mr *MockClientMockRecorder) Delete(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockClient)(nil).Delete), arg0, arg1, arg2, arg3)
}
// Get mocks base method
func (m *MockClient) Get(arg0 context.Context, arg1 []*pb.Node, arg2 eestream.ErasureScheme, arg3 client.PieceID, arg4 int64) (ranger.Ranger, error) {
ret := m.ctrl.Call(m, "Get", arg0, arg1, arg2, arg3, arg4)
func (m *MockClient) Get(arg0 context.Context, arg1 []*pb.Node, arg2 eestream.ErasureScheme, arg3 client.PieceID, arg4 int64, arg5 *pb.SignedMessage) (ranger.Ranger, error) {
ret := m.ctrl.Call(m, "Get", arg0, arg1, arg2, arg3, arg4, arg5)
ret0, _ := ret[0].(ranger.Ranger)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Get indicates an expected call of Get
func (mr *MockClientMockRecorder) Get(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockClient)(nil).Get), arg0, arg1, arg2, arg3, arg4)
func (mr *MockClientMockRecorder) Get(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockClient)(nil).Get), arg0, arg1, arg2, arg3, arg4, arg5)
}
// Put mocks base method
func (m *MockClient) Put(arg0 context.Context, arg1 []*pb.Node, arg2 eestream.RedundancyStrategy, arg3 client.PieceID, arg4 io.Reader, arg5 time.Time) ([]*pb.Node, error) {
ret := m.ctrl.Call(m, "Put", arg0, arg1, arg2, arg3, arg4, arg5)
func (m *MockClient) Put(arg0 context.Context, arg1 []*pb.Node, arg2 eestream.RedundancyStrategy, arg3 client.PieceID, arg4 io.Reader, arg5 time.Time, arg6 *pb.SignedMessage) ([]*pb.Node, error) {
ret := m.ctrl.Call(m, "Put", arg0, arg1, arg2, arg3, arg4, arg5, arg6)
ret0, _ := ret[0].([]*pb.Node)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Put indicates an expected call of Put
func (mr *MockClientMockRecorder) Put(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Put", reflect.TypeOf((*MockClient)(nil).Put), arg0, arg1, arg2, arg3, arg4, arg5)
func (mr *MockClientMockRecorder) Put(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Put", reflect.TypeOf((*MockClient)(nil).Put), arg0, arg1, arg2, arg3, arg4, arg5, arg6)
}

View File

@ -58,28 +58,28 @@ func (mr *MockPSClientMockRecorder) Close() *gomock.Call {
}
// Delete mocks base method
func (m *MockPSClient) Delete(arg0 context.Context, arg1 client.PieceID) error {
ret := m.ctrl.Call(m, "Delete", arg0, arg1)
func (m *MockPSClient) Delete(arg0 context.Context, arg1 client.PieceID, arg2 *pb.SignedMessage) error {
ret := m.ctrl.Call(m, "Delete", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
}
// Delete indicates an expected call of Delete
func (mr *MockPSClientMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockPSClient)(nil).Delete), arg0, arg1)
func (mr *MockPSClientMockRecorder) Delete(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockPSClient)(nil).Delete), arg0, arg1, arg2)
}
// Get mocks base method
func (m *MockPSClient) Get(arg0 context.Context, arg1 client.PieceID, arg2 int64, arg3 *pb.PayerBandwidthAllocation) (ranger.Ranger, error) {
ret := m.ctrl.Call(m, "Get", arg0, arg1, arg2, arg3)
func (m *MockPSClient) Get(arg0 context.Context, arg1 client.PieceID, arg2 int64, arg3 *pb.PayerBandwidthAllocation, arg4 *pb.SignedMessage) (ranger.Ranger, error) {
ret := m.ctrl.Call(m, "Get", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].(ranger.Ranger)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Get indicates an expected call of Get
func (mr *MockPSClientMockRecorder) Get(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockPSClient)(nil).Get), arg0, arg1, arg2, arg3)
func (mr *MockPSClientMockRecorder) Get(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockPSClient)(nil).Get), arg0, arg1, arg2, arg3, arg4)
}
// Meta mocks base method
@ -96,15 +96,15 @@ func (mr *MockPSClientMockRecorder) Meta(arg0, arg1 interface{}) *gomock.Call {
}
// Put mocks base method
func (m *MockPSClient) Put(arg0 context.Context, arg1 client.PieceID, arg2 io.Reader, arg3 time.Time, arg4 *pb.PayerBandwidthAllocation) error {
ret := m.ctrl.Call(m, "Put", arg0, arg1, arg2, arg3, arg4)
func (m *MockPSClient) Put(arg0 context.Context, arg1 client.PieceID, arg2 io.Reader, arg3 time.Time, arg4 *pb.PayerBandwidthAllocation, arg5 *pb.SignedMessage) error {
ret := m.ctrl.Call(m, "Put", arg0, arg1, arg2, arg3, arg4, arg5)
ret0, _ := ret[0].(error)
return ret0
}
// Put indicates an expected call of Put
func (mr *MockPSClientMockRecorder) Put(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Put", reflect.TypeOf((*MockPSClient)(nil).Put), arg0, arg1, arg2, arg3, arg4)
func (mr *MockPSClientMockRecorder) Put(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Put", reflect.TypeOf((*MockPSClient)(nil).Put), arg0, arg1, arg2, arg3, arg4, arg5)
}
// Stats mocks base method

View File

@ -121,8 +121,12 @@ 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)
}
// puts file to ecclient
successfulNodes, err := s.ec.Put(ctx, nodes, s.rs, pieceID, sizedReader, expiration)
successfulNodes, err := s.ec.Put(ctx, nodes, s.rs, pieceID, sizedReader, expiration, signedMessage)
if err != nil {
return Meta{}, Error.Wrap(err)
}
@ -211,7 +215,11 @@ func (s *segmentStore) Get(ctx context.Context, path paths.Path) (
return nil, Meta{}, err
}
rr, err = s.ec.Get(ctx, nodes, es, pid, pr.GetSize())
signedMessage, err := s.pdb.SignedMessage()
if err != nil {
return nil, Meta{}, Error.Wrap(err)
}
rr, err = s.ec.Get(ctx, nodes, es, pid, pr.GetSize(), signedMessage)
if err != nil {
return nil, Meta{}, Error.Wrap(err)
}
@ -248,8 +256,12 @@ func (s *segmentStore) Delete(ctx context.Context, path paths.Path) (err error)
return Error.Wrap(err)
}
signedMessage, err := s.pdb.SignedMessage()
if err != nil {
return Error.Wrap(err)
}
// ecclient sends delete request
err = s.ec.Delete(ctx, nodes, pid)
err = s.ec.Delete(ctx, nodes, pid, signedMessage)
if err != nil {
return Error.Wrap(err)
}

View File

@ -117,8 +117,9 @@ func TestSegmentStorePutRemote(t *testing.T) {
).Return([]*pb.Node{
{Id: "im-a-node"},
}, nil),
mockPDB.EXPECT().SignedMessage(),
mockEC.EXPECT().Put(
gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(),
gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(),
),
mockES.EXPECT().RequiredCount().Return(1),
mockES.EXPECT().TotalCount().Return(1),
@ -286,8 +287,9 @@ func TestSegmentStoreGetRemote(t *testing.T) {
Metadata: tt.metadata,
}, nil),
mockOC.EXPECT().BulkLookup(gomock.Any(), gomock.Any()),
mockPDB.EXPECT().SignedMessage(),
mockEC.EXPECT().Get(
gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(),
gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(),
),
}
gomock.InOrder(calls...)
@ -402,8 +404,9 @@ func TestSegmentStoreDeleteRemote(t *testing.T) {
Metadata: tt.metadata,
}, nil),
mockOC.EXPECT().BulkLookup(gomock.Any(), gomock.Any()),
mockPDB.EXPECT().SignedMessage(),
mockEC.EXPECT().Delete(
gomock.Any(), gomock.Any(), gomock.Any(),
gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(),
),
mockPDB.EXPECT().Delete(
gomock.Any(), gomock.Any(),