forked from TrueCloudLab/frostfs-node
[#505] morph/container: Add key argument to client wrapper's SetEACL
In recent changes argument list of set eACL call of Container contract client was extended with binary public key. In the future there will be a need to pass the table in binary format. Replace `PutEACL` method with `PutEACLBinary` one which accepts three binary parameters: eACL table, key and signature. Create `PutEACL` function similar to the removed method, but accepting `Signature` structure instead of just a signature. Use this function in Container service server in the place where `PutEACL` was used. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
02079a4f89
commit
395fd187ac
2 changed files with 24 additions and 10 deletions
|
@ -52,24 +52,36 @@ func (w *Wrapper) GetEACL(cid *containerSDK.ID) (*eacl.Table, *pkg.Signature, er
|
|||
return table, tableSignature, nil
|
||||
}
|
||||
|
||||
// PutEACL saves the extended ACL table in NeoFS system
|
||||
// through Container contract call.
|
||||
// PutEACL marshals table, and passes it to Wrapper's PutEACLBinary method
|
||||
// along with sig.Key() and sig.Sign().
|
||||
//
|
||||
// Returns any error encountered that caused the saving to interrupt.
|
||||
func (w *Wrapper) PutEACL(table *eacl.Table, signature []byte) error {
|
||||
if table == nil || len(signature) == 0 {
|
||||
// Returns error if table is nil.
|
||||
func PutEACL(w *Wrapper, table *eacl.Table, sig *pkg.Signature) error {
|
||||
if table == nil {
|
||||
return errNilArgument
|
||||
}
|
||||
|
||||
args := client.SetEACLArgs{}
|
||||
args.SetSignature(signature)
|
||||
|
||||
data, err := table.Marshal()
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't marshal eacl table: %w", err)
|
||||
}
|
||||
|
||||
args.SetEACL(data)
|
||||
return w.PutEACLBinary(data, sig.Key(), sig.Sign())
|
||||
}
|
||||
|
||||
// PutEACLBinary save binary eACL table with its key and signature
|
||||
// in NeoFS system through Container contract call.
|
||||
//
|
||||
// Returns any error encountered that caused the saving to interrupt.
|
||||
func (w *Wrapper) PutEACLBinary(table, key, sig []byte) error {
|
||||
if len(sig) == 0 || len(key) == 0 {
|
||||
return errNilArgument
|
||||
}
|
||||
|
||||
args := client.SetEACLArgs{}
|
||||
args.SetSignature(table)
|
||||
args.SetPublicKey(key)
|
||||
args.SetEACL(sig)
|
||||
|
||||
return w.client.SetEACL(args)
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||
eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||
containerSDK "github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||
|
@ -88,8 +89,9 @@ func (s *morphExecutor) List(ctx context.Context, body *container.ListRequestBod
|
|||
|
||||
func (s *morphExecutor) SetExtendedACL(ctx context.Context, body *container.SetExtendedACLRequestBody) (*container.SetExtendedACLResponseBody, error) {
|
||||
table := eaclSDK.NewTableFromV2(body.GetEACL())
|
||||
sign := pkg.NewSignatureFromV2(body.GetSignature())
|
||||
|
||||
err := s.wrapper.PutEACL(table, body.GetSignature().GetSign())
|
||||
err := wrapper.PutEACL(s.wrapper, table, sign)
|
||||
|
||||
return new(container.SetExtendedACLResponseBody), err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue