[#xx] tree: Make check APE error get wrapped to api status
Some checks failed
Tests and linters / gopls check (pull_request) Failing after 50s
Pre-commit hooks / Pre-commit (pull_request) Failing after 1m10s
Tests and linters / Tests (pull_request) Failing after 1m11s
Vulncheck / Vulncheck (pull_request) Failing after 1m49s
Build / Build Components (pull_request) Failing after 2m4s
Tests and linters / Lint (pull_request) Failing after 2m0s
DCO action / DCO (pull_request) Failing after 2m2s
Tests and linters / Tests with -race (pull_request) Failing after 2m1s
Tests and linters / Run gofumpt (pull_request) Failing after 2m10s
Tests and linters / Staticcheck (pull_request) Failing after 2m12s

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2024-11-27 15:52:23 +03:00
parent 64582215c9
commit cba53ccdfc

View file

@ -11,6 +11,7 @@ import (
core "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/bearer"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/acl"
cidSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto"
@ -62,7 +63,16 @@ func (s *Service) verifyClient(ctx context.Context, req message, cid cidSDK.ID,
return fmt.Errorf("can't get request role: %w", err)
}
return s.checkAPE(ctx, bt, cnr, cid, op, role, pubKey)
if err = s.checkAPE(ctx, bt, cnr, cid, op, role, pubKey); err != nil {
return apeErr(err)
}
return nil
}
func apeErr(err error) error {
errAccessDenied := &apistatus.ObjectAccessDenied{}
errAccessDenied.WriteReason(err.Error())
return errAccessDenied
}
// Returns true iff the operation is read-only and request was signed