forked from TrueCloudLab/frostfs-node
[#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 <alexey@nspcc.ru>
This commit is contained in:
parent
ace2362e74
commit
1332a6d3a8
4 changed files with 11 additions and 9 deletions
|
@ -20,7 +20,7 @@ type Service struct {
|
||||||
type Option func(*cfg)
|
type Option func(*cfg)
|
||||||
|
|
||||||
type RelationHeader interface {
|
type RelationHeader interface {
|
||||||
HeadRelation(context.Context, *objectSDK.Address) (*object.Object, error)
|
HeadRelation(context.Context, *objectSDK.Address, *objutil.CommonPrm) (*object.Object, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type cfg struct {
|
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) {
|
func (s *Service) getRelations(ctx context.Context, prm *Prm) ([]*objectSDK.Address, error) {
|
||||||
var res []*objectSDK.Address
|
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()
|
cid := prm.addr.GetContainerID()
|
||||||
|
|
||||||
for prev := prm.addr.GetObjectID(); prev != nil; {
|
for prev := prm.addr.GetObjectID(); prev != nil; {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/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"
|
"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) {
|
func (h *RelationHeader) HeadRelation(ctx context.Context, addr *objectSDK.Address, prm *objutil.CommonPrm) (*object.Object, error) {
|
||||||
id, err := h.srch.SearchRelation(ctx, addr)
|
id, err := h.srch.SearchRelation(ctx, addr, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "(%T) could not find relation", h)
|
return nil, errors.Wrapf(err, "(%T) could not find relation", h)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type RelationSearcher interface {
|
type RelationSearcher interface {
|
||||||
SearchRelation(context.Context, *objectSDK.Address) (*objectSDK.ID, error)
|
SearchRelation(context.Context, *objectSDK.Address, *objutil.CommonPrm) (*objectSDK.ID, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Service struct {
|
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
|
// 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 {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "(%T) could not find right child", s)
|
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.SetContainerID(prm.addr.GetContainerID())
|
||||||
addr.SetObjectID(rightChildID)
|
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 {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "(%T) could not get right child header", s)
|
return nil, errors.Wrapf(err, "(%T) could not get right child header", s)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/object/search/query"
|
"github.com/nspcc-dev/neofs-node/pkg/services/object/search/query"
|
||||||
queryV1 "github.com/nspcc-dev/neofs-node/pkg/services/object/search/query/v1"
|
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"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,9 +17,9 @@ type RelationSearcher struct {
|
||||||
queryGenerator func(*object.Address) query.Query
|
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).
|
streamer, err := s.svc.Search(ctx, new(Prm).
|
||||||
WithContainerID(addr.GetContainerID()).
|
WithContainerID(addr.GetContainerID()).WithCommonPrm(prm).
|
||||||
WithSearchQuery(s.queryGenerator(addr)),
|
WithSearchQuery(s.queryGenerator(addr)),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue