diff --git a/api/handler/delete.go b/api/handler/delete.go index 582a907..88e9681 100644 --- a/api/handler/delete.go +++ b/api/handler/delete.go @@ -11,6 +11,7 @@ import ( "github.com/nspcc-dev/neofs-s3-gw/api/layer" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" + "github.com/nspcc-dev/neofs-sdk-go/session" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) @@ -271,7 +272,17 @@ func (h *handler) DeleteBucketHandler(w http.ResponseWriter, r *http.Request) { return } - if err = h.obj.DeleteBucket(r.Context(), &layer.DeleteBucketParams{BktInfo: bktInfo}); err != nil { + var sessionToken *session.Container + + boxData, err := layer.GetBoxData(r.Context()) + if err == nil { + sessionToken = boxData.Gate.SessionTokenForDelete() + } + + if err = h.obj.DeleteBucket(r.Context(), &layer.DeleteBucketParams{ + BktInfo: bktInfo, + SessionToken: sessionToken, + }); err != nil { h.logAndSendError(w, "couldn't delete bucket", reqInfo, err) } w.WriteHeader(http.StatusNoContent) diff --git a/api/layer/container.go b/api/layer/container.go index bf6231d..eb288ee 100644 --- a/api/layer/container.go +++ b/api/layer/container.go @@ -180,12 +180,6 @@ func (n *layer) GetContainerEACL(ctx context.Context, idCnr cid.ID) (*eacl.Table return n.neoFS.ContainerEACL(ctx, idCnr) } -func (n *layer) deleteContainer(ctx context.Context, idCnr cid.ID) error { - var sessionToken *session.Container - boxData, err := GetBoxData(ctx) - if err == nil { - sessionToken = boxData.Gate.SessionTokenForDelete() - } - +func (n *layer) deleteContainer(ctx context.Context, idCnr cid.ID, sessionToken *session.Container) error { return n.neoFS.DeleteContainer(ctx, idCnr, sessionToken) } diff --git a/api/layer/layer.go b/api/layer/layer.go index 901e0c4..e855b9b 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -151,7 +151,8 @@ type ( } // DeleteBucketParams stores delete bucket request parameters. DeleteBucketParams struct { - BktInfo *data.BucketInfo + BktInfo *data.BucketInfo + SessionToken *session.Container } // PutSystemObjectParams stores putSystemObject parameters. @@ -658,5 +659,5 @@ func (n *layer) DeleteBucket(ctx context.Context, p *DeleteBucketParams) error { } n.bucketCache.Delete(p.BktInfo.Name) - return n.deleteContainer(ctx, p.BktInfo.CID) + return n.deleteContainer(ctx, p.BktInfo.CID, p.SessionToken) }