From 589a54805dbc0b631e5c5698473f8578df90563b Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 21 Jul 2022 16:47:42 +0300 Subject: [PATCH] [#1618] node: Use OID/CID from the request in eACL checks Also, try to fetch object header info from the local storage to find as much object info as possible for the requests which do not assume returning object header as a response. Signed-off-by: Pavel Karpy --- CHANGELOG.md | 2 ++ pkg/services/object/acl/eacl/v2/headers.go | 32 ++++++++++++++++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56310cb40..8d9c5178d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ Changelog for NeoFS Node ### Fixed +- Losing request context in eACL response checks (#1595) + ### Removed ### Updated diff --git a/pkg/services/object/acl/eacl/v2/headers.go b/pkg/services/object/acl/eacl/v2/headers.go index e5511c35a..54d3569ac 100644 --- a/pkg/services/object/acl/eacl/v2/headers.go +++ b/pkg/services/object/acl/eacl/v2/headers.go @@ -114,16 +114,10 @@ func (h *cfg) readObjectHeaders(dst *headerSource) error { return errMissingOID } - var addr oid.Address - addr.SetContainer(h.cnr) - addr.SetObject(*h.obj) + objHeaders, completed := h.localObjectHeaders(h.cnr, h.obj) - obj, err := h.storage.Head(addr) - if err == nil { - dst.objectHeaders = headersFromObject(obj, h.cnr, h.obj) - } else { - dst.incompleteObjectHeaders = true - } + dst.objectHeaders = objHeaders + dst.incompleteObjectHeaders = !completed case *objectV2.GetRangeRequest, *objectV2.GetRangeHashRequest, @@ -155,6 +149,11 @@ func (h *cfg) readObjectHeaders(dst *headerSource) error { } case responseXHeaderSource: switch resp := m.resp.(type) { + default: + objectHeaders, completed := h.localObjectHeaders(h.cnr, h.obj) + + dst.objectHeaders = objectHeaders + dst.incompleteObjectHeaders = !completed case *objectV2.GetResponse: if v, ok := resp.GetBody().GetObjectPart().(*objectV2.GetObjectPartInit); ok { oV2 := new(objectV2.Object) @@ -194,6 +193,21 @@ func (h *cfg) readObjectHeaders(dst *headerSource) error { return nil } +func (h *cfg) localObjectHeaders(cnr cid.ID, idObj *oid.ID) ([]eaclSDK.Header, bool) { + if idObj != nil { + var addr oid.Address + addr.SetContainer(cnr) + addr.SetObject(*idObj) + + obj, err := h.storage.Head(addr) + if err == nil { + return headersFromObject(obj, cnr, idObj), true + } + } + + return addressHeaders(cnr, idObj), false +} + func cidHeader(idCnr cid.ID) sysObjHdr { return sysObjHdr{ k: acl.FilterObjectContainerID,