[#1697] services/object: Return proper error if session token is missing

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-09-28 15:05:19 +03:00 committed by fyrchik
parent 5284ac53f9
commit 1edc048870
5 changed files with 25 additions and 11 deletions

View file

@ -18,6 +18,7 @@ Changelog for NeoFS Node
### Fixed
- Description of command `netmap nodeinfo` (#1821)
- Proper status for object.Delete if session token is missing (#1697)
### Removed
- Remove WIF and NEP2 support in `neofs-cli`'s --wallet flag (#1128)

View file

@ -338,11 +338,11 @@ func initObjectService(c *cfg) {
cfg: c,
}),
deletesvc.WithKeyStorage(keyStorage),
)
sDeleteV2 := deletesvcV2.NewService(
deletesvcV2.WithInternalService(sDelete),
deletesvcV2.WithKeyStorage(keyStorage),
)
// build service pipeline

View file

@ -3,11 +3,24 @@ package deletesvc
import (
"context"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"go.uber.org/zap"
)
// Delete serves requests to remote the objects.
func (s *Service) Delete(ctx context.Context, prm Prm) error {
// If session token is not found we will fail during tombstone PUT.
// Here we fail immediately to ensure no unnecessary network communication is done.
if tok := prm.common.SessionToken(); tok != nil {
_, err := s.keyStorage.GetKey(&util.SessionInfo{
ID: tok.ID(),
Owner: tok.Issuer(),
})
if err != nil {
return err
}
}
exec := &execCtx{
svc: s,
ctx: ctx,

View file

@ -5,6 +5,7 @@ import (
getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get"
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
searchsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/search"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
@ -55,6 +56,8 @@ type cfg struct {
}
netInfo NetworkInfo
keyStorage *util.KeyStorage
}
func defaultCfg() *cfg {
@ -112,3 +115,10 @@ func WithNetworkInfo(netInfo NetworkInfo) Option {
c.netInfo = netInfo
}
}
// WithKeyStorage returns option to set local private key storage.
func WithKeyStorage(ks *util.KeyStorage) Option {
return func(c *cfg) {
c.keyStorage = ks
}
}

View file

@ -5,7 +5,6 @@ import (
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
deletesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/delete"
objutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util"
)
// Service implements Delete operation of Object service v2.
@ -18,8 +17,6 @@ type Option func(*cfg)
type cfg struct {
svc *deletesvc.Service
keyStorage *objutil.KeyStorage
}
// NewService constructs Service instance from provided options.
@ -60,10 +57,3 @@ func WithInternalService(v *deletesvc.Service) Option {
c.svc = v
}
}
// WithKeyStorage returns option to set local private key storage.
func WithKeyStorage(ks *objutil.KeyStorage) Option {
return func(c *cfg) {
c.keyStorage = ks
}
}