From cfa209d74eb5d662a757f7993a9a072a24657960 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 25 May 2021 19:38:49 +0300 Subject: [PATCH] [#525] morph/container: Attach parsed session token to table in GetEACL Unmarshal session token from `EACLValues` and write it to resulting `eacl.Table` structure in `Wrapper.GetEACL` method. Signed-off-by: Leonard Lyubich --- pkg/morph/client/container/wrapper/eacl.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/pkg/morph/client/container/wrapper/eacl.go b/pkg/morph/client/container/wrapper/eacl.go index 95446173..6f3f9f63 100644 --- a/pkg/morph/client/container/wrapper/eacl.go +++ b/pkg/morph/client/container/wrapper/eacl.go @@ -6,6 +6,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl" cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" + "github.com/nspcc-dev/neofs-api-go/pkg/session" "github.com/nspcc-dev/neofs-node/pkg/core/container" client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" ) @@ -39,16 +40,28 @@ func (w *Wrapper) GetEACL(cid *cid.ID) (*eacl.Table, error) { return nil, container.ErrEACLNotFound } - tableSignature := pkg.NewSignature() - tableSignature.SetKey(rpcAnswer.PublicKey()) - tableSignature.SetSign(sig) - table := eacl.NewTable() if err = table.Unmarshal(rpcAnswer.EACL()); err != nil { // use other major version if there any return nil, err } + binToken := rpcAnswer.SessionToken() + if len(binToken) > 0 { + tok := session.NewToken() + + err = tok.Unmarshal(binToken) + if err != nil { + return nil, fmt.Errorf("could not unmarshal session token: %w", err) + } + + table.SetSessionToken(tok) + } + + tableSignature := pkg.NewSignature() + tableSignature.SetKey(rpcAnswer.PublicKey()) + tableSignature.SetSign(sig) + table.SetSignature(tableSignature) return table, nil