forked from TrueCloudLab/frostfs-node
[#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 <carpawell@nspcc.ru>
This commit is contained in:
parent
6049022f7e
commit
589a54805d
2 changed files with 25 additions and 9 deletions
|
@ -17,6 +17,8 @@ Changelog for NeoFS Node
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Losing request context in eACL response checks (#1595)
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
|
@ -114,16 +114,10 @@ func (h *cfg) readObjectHeaders(dst *headerSource) error {
|
||||||
return errMissingOID
|
return errMissingOID
|
||||||
}
|
}
|
||||||
|
|
||||||
var addr oid.Address
|
objHeaders, completed := h.localObjectHeaders(h.cnr, h.obj)
|
||||||
addr.SetContainer(h.cnr)
|
|
||||||
addr.SetObject(*h.obj)
|
|
||||||
|
|
||||||
obj, err := h.storage.Head(addr)
|
dst.objectHeaders = objHeaders
|
||||||
if err == nil {
|
dst.incompleteObjectHeaders = !completed
|
||||||
dst.objectHeaders = headersFromObject(obj, h.cnr, h.obj)
|
|
||||||
} else {
|
|
||||||
dst.incompleteObjectHeaders = true
|
|
||||||
}
|
|
||||||
case
|
case
|
||||||
*objectV2.GetRangeRequest,
|
*objectV2.GetRangeRequest,
|
||||||
*objectV2.GetRangeHashRequest,
|
*objectV2.GetRangeHashRequest,
|
||||||
|
@ -155,6 +149,11 @@ func (h *cfg) readObjectHeaders(dst *headerSource) error {
|
||||||
}
|
}
|
||||||
case responseXHeaderSource:
|
case responseXHeaderSource:
|
||||||
switch resp := m.resp.(type) {
|
switch resp := m.resp.(type) {
|
||||||
|
default:
|
||||||
|
objectHeaders, completed := h.localObjectHeaders(h.cnr, h.obj)
|
||||||
|
|
||||||
|
dst.objectHeaders = objectHeaders
|
||||||
|
dst.incompleteObjectHeaders = !completed
|
||||||
case *objectV2.GetResponse:
|
case *objectV2.GetResponse:
|
||||||
if v, ok := resp.GetBody().GetObjectPart().(*objectV2.GetObjectPartInit); ok {
|
if v, ok := resp.GetBody().GetObjectPart().(*objectV2.GetObjectPartInit); ok {
|
||||||
oV2 := new(objectV2.Object)
|
oV2 := new(objectV2.Object)
|
||||||
|
@ -194,6 +193,21 @@ func (h *cfg) readObjectHeaders(dst *headerSource) error {
|
||||||
return nil
|
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 {
|
func cidHeader(idCnr cid.ID) sysObjHdr {
|
||||||
return sysObjHdr{
|
return sysObjHdr{
|
||||||
k: acl.FilterObjectContainerID,
|
k: acl.FilterObjectContainerID,
|
||||||
|
|
Loading…
Reference in a new issue