ape: Add container source to object policy checker
Some checks failed
DCO action / DCO (pull_request) Failing after 3m8s
Vulncheck / Vulncheck (pull_request) Failing after 3m47s
Tests and linters / Staticcheck (pull_request) Failing after 4m22s
Build / Build Components (1.21) (pull_request) Successful in 4m25s
Build / Build Components (1.20) (pull_request) Successful in 4m32s
Tests and linters / gopls check (pull_request) Failing after 5m7s
Tests and linters / Lint (pull_request) Successful in 7m14s
Tests and linters / Tests (1.20) (pull_request) Failing after 7m13s
Tests and linters / Tests (1.21) (pull_request) Failing after 7m19s
Tests and linters / Tests with -race (pull_request) Failing after 7m21s

Signed-off-by: Alex Vanin <a.vanin@yadro.com>
This commit is contained in:
Alexey Vanin 2024-03-14 21:10:31 +03:00
parent c6f0545298
commit f41d743203
3 changed files with 20 additions and 2 deletions

View file

@ -444,6 +444,7 @@ func createAPEService(c *cfg, splitSvc *objectService.TransportSplitter) *object
objectAPE.NewChecker(
c.cfgObject.cfgAccessPolicyEngine.accessPolicyEngine.chainRouter,
objectAPE.NewStorageEngineHeaderProvider(c.cfgObject.cfgLocalStorage.localStorage),
c.cfgObject.cnrSource,
),
splitSvc,
)

View file

@ -5,23 +5,32 @@ import (
"fmt"
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
containercore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
apechain "git.frostfs.info/TrueCloudLab/policy-engine/pkg/chain"
policyengine "git.frostfs.info/TrueCloudLab/policy-engine/pkg/engine"
)
type containers interface {
Get(cid.ID) (*containercore.Container, error)
}
type checkerImpl struct {
chainRouter policyengine.ChainRouter
headerProvider HeaderProvider
reader containers
}
func NewChecker(chainRouter policyengine.ChainRouter, headerProvider HeaderProvider) Checker {
func NewChecker(chainRouter policyengine.ChainRouter, headerProvider HeaderProvider, reader containers) Checker {
return &checkerImpl{
chainRouter: chainRouter,
headerProvider: headerProvider,
reader: reader,
}
}

View file

@ -145,11 +145,19 @@ func (c *checkerImpl) newAPERequest(ctx context.Context, prm Prm) (*request, err
}
}
cont, err := c.reader.Get(prm.Container)
if err != nil {
return nil, fmt.Errorf("get container: %s", err)
}
props := objectProperties(prm.Container, prm.Object, header)
props[nativeschema.PropertyKeyContainerOwnerID] = cont.Value.Owner().EncodeToString()
return &request{
operation: prm.Method,
resource: &resource{
name: resourceName(prm.Container, prm.Object, prm.Namespace),
properties: objectProperties(prm.Container, prm.Object, header),
properties: props,
},
properties: map[string]string{
nativeschema.PropertyKeyActorPublicKey: prm.SenderKey,