[#303] ir: Use pub key when validate container deletion

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2023-06-01 11:55:06 +03:00 committed by Evgenii Stratonikov
parent 69df0d21c2
commit 50caa388b0
6 changed files with 31 additions and 47 deletions

View file

@ -14,14 +14,15 @@ import (
// Returns error if container ID is nil.
func Delete(c *Client, witness core.RemovalWitness) error {
binCnr := make([]byte, sha256.Size)
witness.ContainerID().Encode(binCnr)
witness.ContainerID.Encode(binCnr)
var prm DeletePrm
prm.SetCID(binCnr)
prm.SetSignature(witness.Signature())
prm.SetSignature(witness.Signature.GetSign())
prm.SetKey(witness.Signature.GetKey())
if tok := witness.SessionToken(); tok != nil {
if tok := witness.SessionToken; tok != nil {
prm.SetToken(tok.Marshal())
}
@ -33,6 +34,7 @@ type DeletePrm struct {
cnr []byte
signature []byte
token []byte
key []byte
client.InvokePrmOptional
}
@ -52,6 +54,11 @@ func (d *DeletePrm) SetToken(token []byte) {
d.token = token
}
// SetKey sets public key.
func (d *DeletePrm) SetKey(key []byte) {
d.key = key
}
// Delete removes the container from FrostFS system
// through Container contract call.
//
@ -66,7 +73,7 @@ func (c *Client) Delete(p DeletePrm) error {
prm := client.InvokePrm{}
prm.SetMethod(deleteMethod)
prm.SetArgs(p.cnr, p.signature, p.token)
prm.SetArgs(p.cnr, p.signature, p.key, p.token)
prm.InvokePrmOptional = p.InvokePrmOptional
err := c.client.Invoke(prm)