From 1332a6d3a8d936ca922f5d07dae6e33f1bbecaa5 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 14 Oct 2020 21:14:54 +0300 Subject: [PATCH] [#92] Provide session token to all produced requests If object service produces new request, the should contain session token. This is the only way for node to grant access for a private container. Signed-off-by: Alex Vanin --- pkg/services/object/delete/service.go | 4 ++-- pkg/services/object/head/relation.go | 5 +++-- pkg/services/object/head/service.go | 6 +++--- pkg/services/object/search/relation.go | 5 +++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/services/object/delete/service.go b/pkg/services/object/delete/service.go index c24fcb34..bc51aab1 100644 --- a/pkg/services/object/delete/service.go +++ b/pkg/services/object/delete/service.go @@ -20,7 +20,7 @@ type Service struct { type Option func(*cfg) type RelationHeader interface { - HeadRelation(context.Context, *objectSDK.Address) (*object.Object, error) + HeadRelation(context.Context, *objectSDK.Address, *objutil.CommonPrm) (*object.Object, error) } type cfg struct { @@ -107,7 +107,7 @@ func (s *Service) Delete(ctx context.Context, prm *Prm) (*Response, error) { func (s *Service) getRelations(ctx context.Context, prm *Prm) ([]*objectSDK.Address, error) { var res []*objectSDK.Address - if linking, err := s.hdrLinking.HeadRelation(ctx, prm.addr); err != nil { + if linking, err := s.hdrLinking.HeadRelation(ctx, prm.addr, prm.common); err != nil { cid := prm.addr.GetContainerID() for prev := prm.addr.GetObjectID(); prev != nil; { diff --git a/pkg/services/object/head/relation.go b/pkg/services/object/head/relation.go index 276d3c1f..bffe77f0 100644 --- a/pkg/services/object/head/relation.go +++ b/pkg/services/object/head/relation.go @@ -5,6 +5,7 @@ import ( objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-node/pkg/core/object" + objutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util" "github.com/pkg/errors" ) @@ -21,8 +22,8 @@ func NewRelationHeader(srch RelationSearcher, svc *Service) *RelationHeader { } } -func (h *RelationHeader) HeadRelation(ctx context.Context, addr *objectSDK.Address) (*object.Object, error) { - id, err := h.srch.SearchRelation(ctx, addr) +func (h *RelationHeader) HeadRelation(ctx context.Context, addr *objectSDK.Address, prm *objutil.CommonPrm) (*object.Object, error) { + id, err := h.srch.SearchRelation(ctx, addr, prm) if err != nil { return nil, errors.Wrapf(err, "(%T) could not find relation", h) } diff --git a/pkg/services/object/head/service.go b/pkg/services/object/head/service.go index 409ed9a2..18ac0c0f 100644 --- a/pkg/services/object/head/service.go +++ b/pkg/services/object/head/service.go @@ -14,7 +14,7 @@ import ( ) type RelationSearcher interface { - SearchRelation(context.Context, *objectSDK.Address) (*objectSDK.ID, error) + SearchRelation(context.Context, *objectSDK.Address, *objutil.CommonPrm) (*objectSDK.ID, error) } type Service struct { @@ -67,7 +67,7 @@ func (s *Service) Head(ctx context.Context, prm *Prm) (*Response, error) { } // try to find far right child that carries header of desired object - rightChildID, err := s.rightChildSearcher.SearchRelation(ctx, prm.addr) + rightChildID, err := s.rightChildSearcher.SearchRelation(ctx, prm.addr, prm.common) if err != nil { return nil, errors.Wrapf(err, "(%T) could not find right child", s) } @@ -76,7 +76,7 @@ func (s *Service) Head(ctx context.Context, prm *Prm) (*Response, error) { addr.SetContainerID(prm.addr.GetContainerID()) addr.SetObjectID(rightChildID) - r, err = s.Head(ctx, new(Prm).WithAddress(addr)) + r, err = s.Head(ctx, new(Prm).WithAddress(addr).WithCommonPrm(prm.common)) if err != nil { return nil, errors.Wrapf(err, "(%T) could not get right child header", s) } diff --git a/pkg/services/object/search/relation.go b/pkg/services/object/search/relation.go index c6eeec5a..09cb2e74 100644 --- a/pkg/services/object/search/relation.go +++ b/pkg/services/object/search/relation.go @@ -7,6 +7,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-node/pkg/services/object/search/query" queryV1 "github.com/nspcc-dev/neofs-node/pkg/services/object/search/query/v1" + "github.com/nspcc-dev/neofs-node/pkg/services/object/util" "github.com/pkg/errors" ) @@ -16,9 +17,9 @@ type RelationSearcher struct { queryGenerator func(*object.Address) query.Query } -func (s *RelationSearcher) SearchRelation(ctx context.Context, addr *object.Address) (*object.ID, error) { +func (s *RelationSearcher) SearchRelation(ctx context.Context, addr *object.Address, prm *util.CommonPrm) (*object.ID, error) { streamer, err := s.svc.Search(ctx, new(Prm). - WithContainerID(addr.GetContainerID()). + WithContainerID(addr.GetContainerID()).WithCommonPrm(prm). WithSearchQuery(s.queryGenerator(addr)), ) if err != nil {