forked from TrueCloudLab/frostfs-node
[#525] morph/container: Parse session token, key and signature in EACL
`EACL` method of `Container` contract returns binary session token, key and signature along with eACL table. Provide `Signature`, `PublicKey` and `SessionToken` getters from `EACLValues` structure. Parse and set all values in `Client.EACL` methods. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
4ef369732a
commit
7ca6f601ef
1 changed files with 14 additions and 0 deletions
|
@ -20,6 +20,8 @@ type EACLValues struct {
|
||||||
signature []byte // RFC-6979 signature of extended ACL table
|
signature []byte // RFC-6979 signature of extended ACL table
|
||||||
|
|
||||||
publicKey []byte // public key of the extended ACL table signer
|
publicKey []byte // public key of the extended ACL table signer
|
||||||
|
|
||||||
|
token []byte // token of the session within which the eACL table was set
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetCID sets the container identifier
|
// SetCID sets the container identifier
|
||||||
|
@ -44,6 +46,12 @@ func (g *EACLValues) PublicKey() []byte {
|
||||||
return g.publicKey
|
return g.publicKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SessionToken returns token of the session within which
|
||||||
|
// the eACl table was set in a NeoFS API binary format.
|
||||||
|
func (g *EACLValues) SessionToken() []byte {
|
||||||
|
return g.token
|
||||||
|
}
|
||||||
|
|
||||||
// EACL performs the test invoke of get eACL
|
// EACL performs the test invoke of get eACL
|
||||||
// method of NeoFS Container contract.
|
// method of NeoFS Container contract.
|
||||||
func (c *Client) EACL(args EACLArgs) (*EACLValues, error) {
|
func (c *Client) EACL(args EACLArgs) (*EACLValues, error) {
|
||||||
|
@ -81,9 +89,15 @@ func (c *Client) EACL(args EACLArgs) (*EACLValues, error) {
|
||||||
return nil, fmt.Errorf("could not get byte array of eACL public key (%s): %w", c.eaclMethod, err)
|
return nil, fmt.Errorf("could not get byte array of eACL public key (%s): %w", c.eaclMethod, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tok, err := client.BytesFromStackItem(arr[3])
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("could not get byte array of eACL session token (%s): %w", c.eaclMethod, err)
|
||||||
|
}
|
||||||
|
|
||||||
return &EACLValues{
|
return &EACLValues{
|
||||||
eacl: eacl,
|
eacl: eacl,
|
||||||
signature: sig,
|
signature: sig,
|
||||||
publicKey: pub,
|
publicKey: pub,
|
||||||
|
token: tok,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue