From 959610080a28e87d6db66f05c2c1dc25ca77e8c4 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 25 May 2021 19:16:57 +0300 Subject: [PATCH] [#525] morph/container: Accept container session token in PutEACL `SetEACL` method of latest `Container` contract accepts binary session token as an argument. Provide `SetEACLArgs.SetSessionToken` method. Accept session token as a `[]byte` in `Wrapper.PutEACL` method and attach it to `SetEACLArgs`. Marshal session token from container in `wrapper.PutEACL` function and pass it to the method. Signed-off-by: Leonard Lyubich --- pkg/innerring/processors/container/process_eacl.go | 2 +- pkg/morph/client/container/eacl_set.go | 7 +++++++ pkg/morph/client/container/wrapper/eacl.go | 12 +++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pkg/innerring/processors/container/process_eacl.go b/pkg/innerring/processors/container/process_eacl.go index 4f113167d..b56f08caa 100644 --- a/pkg/innerring/processors/container/process_eacl.go +++ b/pkg/innerring/processors/container/process_eacl.go @@ -69,7 +69,7 @@ func (cp *Processor) checkEACLOwnership(binTable []byte, key *keys.PublicKey) er } func (cp *Processor) approveSetEACL(e container.SetEACL) { - err := cp.cnrClient.PutEACL(e.Table(), e.PublicKey(), e.Signature()) + err := cp.cnrClient.PutEACL(e.Table(), e.PublicKey(), e.Signature(), nil) if err != nil { cp.log.Error("could not approve set EACL", zap.String("error", err.Error()), diff --git a/pkg/morph/client/container/eacl_set.go b/pkg/morph/client/container/eacl_set.go index 1dcf53f08..cb90e7cf9 100644 --- a/pkg/morph/client/container/eacl_set.go +++ b/pkg/morph/client/container/eacl_set.go @@ -34,6 +34,13 @@ func (p *SetEACLArgs) SetPublicKey(v []byte) { p.pubkey = v } +// SetSessionToken sets token of the session +// within which the eACL table was set +// in a binary format. +func (p *SetEACLArgs) SetSessionToken(v []byte) { + p.token = v +} + // SetEACL invokes the call of set eACL method // of NeoFS Container contract. func (c *Client) SetEACL(args SetEACLArgs) error { diff --git a/pkg/morph/client/container/wrapper/eacl.go b/pkg/morph/client/container/wrapper/eacl.go index 84c817f5b..95446173d 100644 --- a/pkg/morph/client/container/wrapper/eacl.go +++ b/pkg/morph/client/container/wrapper/eacl.go @@ -70,16 +70,21 @@ func PutEACL(w *Wrapper, table *eacl.Table) error { return fmt.Errorf("can't marshal eacl table: %w", err) } + binToken, err := table.SessionToken().Marshal() + if err != nil { + return fmt.Errorf("could not marshal session token: %w", err) + } + sig := table.Signature() - return w.PutEACL(data, sig.Key(), sig.Sign()) + return w.PutEACL(data, sig.Key(), sig.Sign(), binToken) } -// PutEACL saves binary eACL table with its key and signature +// PutEACL saves binary eACL table with its session token, key and signature // in NeoFS system through Container contract call. // // Returns any error encountered that caused the saving to interrupt. -func (w *Wrapper) PutEACL(table, key, sig []byte) error { +func (w *Wrapper) PutEACL(table, key, sig, token []byte) error { if len(sig) == 0 || len(key) == 0 { return errNilArgument } @@ -88,6 +93,7 @@ func (w *Wrapper) PutEACL(table, key, sig []byte) error { args.SetSignature(sig) args.SetPublicKey(key) args.SetEACL(table) + args.SetSessionToken(token) return w.client.SetEACL(args) }