diff --git a/cmd/gate/app-new-auth.go b/cmd/gate/app-new-auth.go index 012c8a21..9dd6aa93 100644 --- a/cmd/gate/app-new-auth.go +++ b/cmd/gate/app-new-auth.go @@ -6,13 +6,10 @@ import ( "github.com/gorilla/mux" "github.com/minio/minio/auth" + s3http "github.com/minio/minio/http" "go.uber.org/zap" ) -type ContextKey string - -const BearerTokenContextKey ContextKey = "bearer-token" - func attachNewUserAuth(router *mux.Router, center *auth.Center, log *zap.Logger) { uamw := func(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -21,7 +18,7 @@ func attachNewUserAuth(router *mux.Router, center *auth.Center, log *zap.Logger) log.Error("failed to pass authentication", zap.Error(err)) // TODO: Handle any auth error by rejecting request. } - h.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), BearerTokenContextKey, bearerToken))) + h.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), s3http.BearerTokenContextKey, bearerToken))) }) } diff --git a/neofs/layer/neofs-container.go b/neofs/layer/neofs-container.go index fb43031f..2f15e5e1 100644 --- a/neofs/layer/neofs-container.go +++ b/neofs/layer/neofs-container.go @@ -6,6 +6,7 @@ import ( "go.uber.org/zap" + s3http "github.com/minio/minio/http" "github.com/nspcc-dev/neofs-api-go/container" "github.com/nspcc-dev/neofs-api-go/refs" "github.com/nspcc-dev/neofs-api-go/service" @@ -16,7 +17,8 @@ func (n *neofsObject) containerList(ctx context.Context) ([]refs.CID, error) { req.OwnerID = n.owner req.SetTTL(service.SingleForwardingTTL) req.SetVersion(APIVersion) - req.SetBearer(nil) + bearerToken := ctx.Value(s3http.BearerTokenContextKey).(*service.BearerTokenMsg) + req.SetBearer(bearerToken) err := service.SignRequestData(n.key, req) if err != nil {