2022-02-11 12:25:05 +00:00
|
|
|
package v2
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
2022-03-17 08:25:33 +00:00
|
|
|
|
|
|
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
2022-02-11 12:25:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// ErrMalformedRequest is returned when request contains
|
|
|
|
// invalid data.
|
|
|
|
ErrMalformedRequest = errors.New("malformed request")
|
2022-02-28 12:35:10 +00:00
|
|
|
// ErrInvalidVerb is returned when session token verb doesn't include necessary operation.
|
|
|
|
ErrInvalidVerb = errors.New("session token verb is invalid")
|
2022-02-11 12:25:05 +00:00
|
|
|
)
|
|
|
|
|
2022-03-18 11:04:32 +00:00
|
|
|
const accessDeniedACLReasonFmt = "access to operation %s is denied by basic ACL check"
|
|
|
|
const accessDeniedEACLReasonFmt = "access to operation %s is denied by extended ACL check: %v"
|
2022-02-11 12:25:05 +00:00
|
|
|
|
|
|
|
func basicACLErr(info RequestInfo) error {
|
2022-03-17 08:25:33 +00:00
|
|
|
var errAccessDenied apistatus.ObjectAccessDenied
|
2022-03-18 11:04:32 +00:00
|
|
|
errAccessDenied.WriteReason(fmt.Sprintf(accessDeniedACLReasonFmt, info.operation))
|
2022-03-17 08:25:33 +00:00
|
|
|
|
|
|
|
return errAccessDenied
|
2022-02-11 12:25:05 +00:00
|
|
|
}
|
|
|
|
|
2022-03-18 11:04:32 +00:00
|
|
|
func eACLErr(info RequestInfo, err error) error {
|
2022-03-17 08:25:33 +00:00
|
|
|
var errAccessDenied apistatus.ObjectAccessDenied
|
2022-03-18 11:04:32 +00:00
|
|
|
errAccessDenied.WriteReason(fmt.Sprintf(accessDeniedEACLReasonFmt, info.operation, err))
|
2022-03-17 08:25:33 +00:00
|
|
|
|
|
|
|
return errAccessDenied
|
2022-02-11 12:25:05 +00:00
|
|
|
}
|