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")
|
|
|
|
// ErrUnknownRole is returned when role of the sender is unknown.
|
|
|
|
ErrUnknownRole = errors.New("can't classify request sender")
|
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-17 08:25:33 +00:00
|
|
|
const accessDeniedReasonFmt = "access to operation %v is denied by %s check"
|
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
|
|
|
|
errAccessDenied.WriteReason(fmt.Sprintf(accessDeniedReasonFmt, info.operation, "basic ACL"))
|
|
|
|
|
|
|
|
return errAccessDenied
|
2022-02-11 12:25:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func eACLErr(info RequestInfo) error {
|
2022-03-17 08:25:33 +00:00
|
|
|
var errAccessDenied apistatus.ObjectAccessDenied
|
|
|
|
errAccessDenied.WriteReason(fmt.Sprintf(accessDeniedReasonFmt, info.operation, "extended ACL"))
|
|
|
|
|
|
|
|
return errAccessDenied
|
2022-02-11 12:25:05 +00:00
|
|
|
}
|