[#155] search-service: Fix search with ST

Search should return only objects allowed in static session

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-03-21 15:41:58 +03:00 committed by Gitea
parent 1637a3edce
commit 49234b915e

View file

@ -119,6 +119,7 @@ func (exec *execCtx) generateTraverser(cnr cid.ID) (*placement.Traverser, bool)
} }
func (exec *execCtx) writeIDList(ids []oid.ID) { func (exec *execCtx) writeIDList(ids []oid.ID) {
ids = exec.filterAllowedObjectIDs(ids)
err := exec.prm.writer.WriteIDs(ids) err := exec.prm.writer.WriteIDs(ids)
switch { switch {
@ -134,3 +135,17 @@ func (exec *execCtx) writeIDList(ids []oid.ID) {
exec.err = nil exec.err = nil
} }
} }
func (exec *execCtx) filterAllowedObjectIDs(objIDs []oid.ID) []oid.ID {
sessionToken := exec.prm.common.SessionToken()
if sessionToken == nil {
return objIDs
}
result := make([]oid.ID, 0, len(objIDs))
for _, objID := range objIDs {
if sessionToken.AssertObject(objID) {
result = append(result, objID)
}
}
return result
}