From 29cb755d49f18a32fd25376b3b8fd7e7be25a20c Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Tue, 24 Nov 2020 10:02:10 +0300 Subject: [PATCH] Fixes of usage auth package Signed-off-by: Evgeniy Kulikov --- api/handler/list.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/api/handler/list.go b/api/handler/list.go index de0e5ec7a..e10603009 100644 --- a/api/handler/list.go +++ b/api/handler/list.go @@ -5,11 +5,11 @@ import ( "strconv" "time" + sdk "github.com/nspcc-dev/cdn-neofs-sdk" "github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/nspcc-dev/neofs-api-go/pkg/token" "github.com/nspcc-dev/neofs-s3-gate/api" "github.com/nspcc-dev/neofs-s3-gate/api/layer" - "github.com/nspcc-dev/neofs-s3-gate/auth" "go.uber.org/zap" ) @@ -34,7 +34,7 @@ func (h *handler) ListBucketsHandler(w http.ResponseWriter, r *http.Request) { rid = api.GetRequestID(r.Context()) ) - if tkn, err = auth.GetBearerToken(r.Context()); err != nil { + if tkn, err = sdk.BearerToken(r.Context()); err != nil { h.log.Error("something went wrong", zap.String("request_id", rid), zap.Error(err)) @@ -45,21 +45,11 @@ func (h *handler) ListBucketsHandler(w http.ResponseWriter, r *http.Request) { HTTPStatusCode: http.StatusInternalServerError, }, r.URL) - return - } else if own, err = layer.GetOwnerID(tkn); err != nil { - h.log.Error("something went wrong", - zap.String("request_id", rid), - zap.Error(err)) - - api.WriteErrorResponse(r.Context(), w, api.Error{ - Code: api.GetAPIError(api.ErrBadRequest).Code, - Description: err.Error(), - HTTPStatusCode: http.StatusBadRequest, - }, r.URL) - return } + own = tkn.Issuer() + list, err := h.obj.ListBuckets(r.Context()) if err != nil { h.log.Error("something went wrong",