[#218] handler,s3-gw: Make policy configurable

Now default policy of placing containers can be set via config/env
variable.

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2021-08-23 21:39:15 +03:00
parent 6d4fe34f3d
commit 2299db4e81
4 changed files with 39 additions and 9 deletions

View file

@ -7,7 +7,6 @@ import (
"strings"
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
"github.com/nspcc-dev/neofs-node/pkg/policy"
"github.com/nspcc-dev/neofs-s3-gw/api"
"github.com/nspcc-dev/neofs-s3-gw/api/errors"
"github.com/nspcc-dev/neofs-s3-gw/api/layer"
@ -20,7 +19,6 @@ const (
basicACLReadOnly = "public-read"
basicACLPublic = "public-read-write"
cannedACLAuthRead = "authenticated-read"
defaultPolicy = "REP 3"
publicBasicRule = 0x0FFFFFFF
)
@ -181,11 +179,7 @@ func (h *handler) CreateBucketHandler(w http.ResponseWriter, r *http.Request) {
}
}
if p.Policy == nil {
p.Policy, err = policy.Parse(defaultPolicy)
if err != nil {
h.logAndSendError(w, "could not parse policy", reqInfo, err)
return
}
p.Policy = h.cfg.DefaultPolicy
}
cid, err := h.obj.CreateBucket(r.Context(), &p)