From 937171911a1c0a5eafff9ffa10ddbea0fcacbbd8 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 28 May 2021 15:45:10 +0300 Subject: [PATCH] [#525] ir/container: Simplify the approach to verify token signature In recent change of API Go library `Token.Verify` signature was implemented. Replace previous version-casting approach with new method call in token signature check stage. Signed-off-by: Leonard Lyubich --- pkg/innerring/processors/container/common.go | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/pkg/innerring/processors/container/common.go b/pkg/innerring/processors/container/common.go index be4da01c..10769037 100644 --- a/pkg/innerring/processors/container/common.go +++ b/pkg/innerring/processors/container/common.go @@ -11,8 +11,6 @@ import ( cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" "github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/nspcc-dev/neofs-api-go/pkg/session" - "github.com/nspcc-dev/neofs-api-go/util/signature" - signature2 "github.com/nspcc-dev/neofs-api-go/v2/signature" ) var ( @@ -106,20 +104,7 @@ func (cp *Processor) checkKeyOwnershipWithToken(ownerIDSrc ownerIDSource, key *k func (cp *Processor) checkSessionToken(token *session.Token) error { // verify signature - - // TODO: need more convenient way to do this - // e.g. provide VerifySignature method from Token - - // FIXME: do all so as not to deepen in the version - tokenV2 := token.ToV2() - - signWrapper := signature2.StableMarshalerWrapper{ - SM: tokenV2.GetBody(), - } - if err := signature.VerifyDataWithSource(signWrapper, func() (key, sig []byte) { - tokenSignature := tokenV2.GetSignature() - return tokenSignature.GetKey(), tokenSignature.GetSign() - }); err != nil { + if !token.VerifySignature() { return errors.New("invalid signature") }