diff --git a/pkg/services/object/head/remote.go b/pkg/services/object/head/remote.go index 8898c9f2..324e7b88 100644 --- a/pkg/services/object/head/remote.go +++ b/pkg/services/object/head/remote.go @@ -44,6 +44,7 @@ func (h *remoteHeader) head(ctx context.Context, prm *Prm, handler func(*object. hdr, err := c.GetObjectHeader(ctx, p, client.WithTTL(1), // FIXME: use constant client.WithSession(prm.common.SessionToken()), + client.WithBearer(prm.common.BearerToken()), ) if err != nil { return errors.Wrapf(err, "(%T) could not head object in %s", h, addr) diff --git a/pkg/services/object/put/remote.go b/pkg/services/object/put/remote.go index e4489a0a..21e82e25 100644 --- a/pkg/services/object/put/remote.go +++ b/pkg/services/object/put/remote.go @@ -21,6 +21,8 @@ type remoteTarget struct { token *token.SessionToken + bearer *token.BearerToken + addr *network.Address obj *object.Object @@ -55,6 +57,7 @@ func (t *remoteTarget) Close() (*transformer.AccessIdentifiers, error) { t.obj.SDK(), ), client.WithTTL(1), // FIXME: use constant + client.WithBearer(t.bearer), ) if err != nil { return nil, errors.Wrapf(err, "(%T) could not put object to %s", t, addr) diff --git a/pkg/services/object/put/streamer.go b/pkg/services/object/put/streamer.go index 2c271bb9..a8c26d53 100644 --- a/pkg/services/object/put/streamer.go +++ b/pkg/services/object/put/streamer.go @@ -131,6 +131,7 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget { ctx: p.ctx, keyStorage: p.keyStorage, token: prm.common.SessionToken(), + bearer: prm.common.BearerToken(), addr: addr, } } diff --git a/pkg/services/object/range/remote.go b/pkg/services/object/range/remote.go index 9e82932a..1ad9389a 100644 --- a/pkg/services/object/range/remote.go +++ b/pkg/services/object/range/remote.go @@ -21,6 +21,8 @@ type remoteRangeWriter struct { token *token.SessionToken + bearer *token.BearerToken + addr *object.Address rng *object.Range @@ -50,6 +52,7 @@ func (r *remoteRangeWriter) WriteTo(w io.Writer) (int64, error) { WithAddress(r.addr), client.WithTTL(1), // FIXME: use constant client.WithSession(r.token), + client.WithBearer(r.bearer), ) if err != nil { return 0, errors.Wrapf(err, "(%T) could not read object payload range from %s", r, addr) diff --git a/pkg/services/object/range/streamer.go b/pkg/services/object/range/streamer.go index 7d22826c..e5a1cef8 100644 --- a/pkg/services/object/range/streamer.go +++ b/pkg/services/object/range/streamer.go @@ -182,6 +182,7 @@ loop: keyStorage: p.keyStorage, node: addr, token: p.prm.common.SessionToken(), + bearer: p.prm.common.BearerToken(), addr: objAddr, rng: nextRange, } diff --git a/pkg/services/object/rangehash/remote.go b/pkg/services/object/rangehash/remote.go index f873b4eb..4635c872 100644 --- a/pkg/services/object/rangehash/remote.go +++ b/pkg/services/object/rangehash/remote.go @@ -45,6 +45,7 @@ func (h *remoteHasher) hashRange(ctx context.Context, prm *Prm, handler func([][ opts := []client.CallOption{ client.WithTTL(1), // FIXME: use constant client.WithSession(prm.common.SessionToken()), + client.WithBearer(prm.common.BearerToken()), } switch prm.typ { diff --git a/pkg/services/object/search/remote.go b/pkg/services/object/search/remote.go index f70f41f7..6dbfaab5 100644 --- a/pkg/services/object/search/remote.go +++ b/pkg/services/object/search/remote.go @@ -42,6 +42,7 @@ func (s *remoteStream) stream(ctx context.Context, ch chan<- []*object.ID) error WithSearchFilters(s.prm.query.ToSearchFilters()), client.WithTTL(1), // FIXME: use constant client.WithSession(s.prm.common.SessionToken()), + client.WithBearer(s.prm.common.BearerToken()), ) if err != nil { return errors.Wrapf(err, "(%T) could not search objects in %s", s, addr) diff --git a/pkg/services/object/util/prm.go b/pkg/services/object/util/prm.go index d6ca4fa5..14c957d0 100644 --- a/pkg/services/object/util/prm.go +++ b/pkg/services/object/util/prm.go @@ -8,7 +8,8 @@ import ( type CommonPrm struct { local bool - token *token.SessionToken + token *token.SessionToken + bearer *token.BearerToken } func (p *CommonPrm) WithLocalOnly(v bool) *CommonPrm { @@ -35,6 +36,14 @@ func (p *CommonPrm) WithSessionToken(token *token.SessionToken) *CommonPrm { return p } +func (p *CommonPrm) WithBearerToken(token *token.BearerToken) *CommonPrm { + if p != nil { + p.bearer = token + } + + return p +} + func (p *CommonPrm) SessionToken() *token.SessionToken { if p != nil { return p.token @@ -43,13 +52,22 @@ func (p *CommonPrm) SessionToken() *token.SessionToken { return nil } +func (p *CommonPrm) BearerToken() *token.BearerToken { + if p != nil { + return p.bearer + } + + return nil +} + func CommonPrmFromV2(req interface { GetMetaHeader() *session.RequestMetaHeader }) *CommonPrm { meta := req.GetMetaHeader() return &CommonPrm{ - local: meta.GetTTL() <= 1, // FIXME: use constant - token: token.NewSessionTokenFromV2(meta.GetSessionToken()), + local: meta.GetTTL() <= 1, // FIXME: use constant + token: token.NewSessionTokenFromV2(meta.GetSessionToken()), + bearer: token.NewBearerTokenFromV2(meta.GetBearerToken()), } }