Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion code/go/0chain.net/blobbercore/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,11 @@ func RevokeShare(ctx context.Context, r *http.Request) (interface{}, error) {
func InsertShare(ctx context.Context, r *http.Request) (interface{}, error) {
ctx = setupHandlerContext(ctx, r)

allocationID := ctx.Value(constants.ContextKeyAllocation).(string)
var (
allocationID = ctx.Value(constants.ContextKeyAllocation).(string)
clientID = ctx.Value(constants.ContextKeyClient).(string)
)

allocationObj, err := storageHandler.verifyAllocation(ctx, allocationID, true)
if err != nil {
return nil, common.NewError("invalid_parameters", "Invalid allocation id passed."+err.Error())
Expand All @@ -463,6 +467,10 @@ func InsertShare(ctx context.Context, r *http.Request) (interface{}, error) {
return nil, common.NewError("invalid_signature", "Invalid signature")
}

if clientID != allocationObj.OwnerID {
return nil, common.NewError("invalid_client", "Client has no access to share file")
}

encryptionPublicKey := r.FormValue("encryption_public_key")
authTicketString := r.FormValue("auth_ticket")
authTicket := &readmarker.AuthTicket{}
Expand Down
2 changes: 2 additions & 0 deletions code/go/0chain.net/blobbercore/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,7 @@ func TestHandlers_Requiring_Signature(t *testing.T) {
r.Header.Set("Content-Type", formWriter.FormDataContentType())
r.Header.Set(common.ClientSignatureHeader, sign)
r.Header.Set(common.ClientHeader, alloc.OwnerID)
r.Header.Set(common.ClientKeyHeader, alloc.OwnerPublicKey)

return r
}(),
Expand Down Expand Up @@ -1236,6 +1237,7 @@ func TestHandlers_Requiring_Signature(t *testing.T) {
r.Header.Set("Content-Type", formWriter.FormDataContentType())
r.Header.Set(common.ClientSignatureHeader, sign)
r.Header.Set(common.ClientHeader, alloc.OwnerID)
r.Header.Set(common.ClientKeyHeader, alloc.OwnerPublicKey)

return r
}(),
Expand Down