forked from TrueCloudLab/frostfs-node
[#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 <leonard@nspcc.ru>
This commit is contained in:
parent
7ca6f601ef
commit
cfa209d74e
1 changed files with 17 additions and 4 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
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"
|
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/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
|
return nil, container.ErrEACLNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
tableSignature := pkg.NewSignature()
|
|
||||||
tableSignature.SetKey(rpcAnswer.PublicKey())
|
|
||||||
tableSignature.SetSign(sig)
|
|
||||||
|
|
||||||
table := eacl.NewTable()
|
table := eacl.NewTable()
|
||||||
if err = table.Unmarshal(rpcAnswer.EACL()); err != nil {
|
if err = table.Unmarshal(rpcAnswer.EACL()); err != nil {
|
||||||
// use other major version if there any
|
// use other major version if there any
|
||||||
return nil, err
|
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)
|
table.SetSignature(tableSignature)
|
||||||
|
|
||||||
return table, nil
|
return table, nil
|
||||||
|
|
Loading…
Reference in a new issue