[#943] service/object: Refactor private key fetching during execution

`CommonPrm` structure has private key for remote operations.
It obtained in the beginning of request processing. However,
not every operation triggers remote calls. Therefore, key
might not be used. It is important to avoid early key fetching
because `TokenStore` now returns error if session token does not
exist. This is valid case when container nodes receive request with
session token (for ACL pass) and they should process request locally.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-10-26 15:07:28 +03:00 committed by Alex Vanin
parent 2fbdcbdee1
commit c30aa20b04
7 changed files with 57 additions and 58 deletions

View file

@ -104,14 +104,19 @@ func (exec execCtx) isChild(obj *object.Object) bool {
return par != nil && equalAddresses(exec.address(), par.Address())
}
func (exec execCtx) key() *ecdsa.PrivateKey {
return exec.prm.common.PrivateKey()
func (exec execCtx) key() (*ecdsa.PrivateKey, error) {
return exec.prm.common.KeyStorage().GetKey(exec.prm.common.SessionToken())
}
func (exec execCtx) callOptions() []client.CallOption {
func (exec execCtx) callOptions() ([]client.CallOption, error) {
key, err := exec.key()
if err != nil {
return nil, err
}
return exec.prm.common.RemoteCallOptions(
util.WithNetmapEpoch(exec.curProcEpoch),
util.WithKey(exec.key()))
util.WithKey(key)), nil
}
func (exec execCtx) remotePrm() *client.GetObjectParams {