2897e83fb2
In previous implementation of eACL service v2 the response X-headers were validated at the stage of re-checking eACL. This provoked a mismatch of records in the eACL table with requests. Fix this behavior by checking the headers from the request, not the response. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
65 lines
1.1 KiB
Go
65 lines
1.1 KiB
Go
package v2
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
|
)
|
|
|
|
type xHeaderSource interface {
|
|
GetXHeaders() []*session.XHeader
|
|
}
|
|
|
|
type requestXHeaderSource struct {
|
|
req Request
|
|
}
|
|
|
|
type responseXHeaderSource struct {
|
|
resp Response
|
|
|
|
req Request
|
|
}
|
|
|
|
func (s *requestXHeaderSource) GetXHeaders() []*session.XHeader {
|
|
ln := 0
|
|
xHdrs := make([][]*session.XHeader, 0)
|
|
|
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
|
x := meta.GetXHeaders()
|
|
|
|
ln += len(x)
|
|
|
|
xHdrs = append(xHdrs, x)
|
|
}
|
|
|
|
res := make([]*session.XHeader, 0, ln)
|
|
|
|
for i := range xHdrs {
|
|
for j := range xHdrs[i] {
|
|
res = append(res, xHdrs[i][j])
|
|
}
|
|
}
|
|
|
|
return res
|
|
}
|
|
|
|
func (s *responseXHeaderSource) GetXHeaders() []*session.XHeader {
|
|
ln := 0
|
|
xHdrs := make([][]*session.XHeader, 0)
|
|
|
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
|
x := meta.GetXHeaders()
|
|
|
|
ln += len(x)
|
|
|
|
xHdrs = append(xHdrs, x)
|
|
}
|
|
|
|
res := make([]*session.XHeader, 0, ln)
|
|
|
|
for i := range xHdrs {
|
|
for j := range xHdrs[i] {
|
|
res = append(res, xHdrs[i][j])
|
|
}
|
|
}
|
|
|
|
return res
|
|
}
|