From 8d4017f1d3ca3a10bcef21f31747eacd184753ee Mon Sep 17 00:00:00 2001 From: Pavel Korotkov Date: Thu, 6 Aug 2020 20:55:07 +0300 Subject: [PATCH] [#8] Use proper creds contructor to avoid unnatural convertions Signed-off-by: Pavel Korotkov --- auth/center.go | 10 +++++----- cmd/gate/app-settings.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/auth/center.go b/auth/center.go index 207fccf3..42c38549 100644 --- a/auth/center.go +++ b/auth/center.go @@ -18,7 +18,6 @@ import ( "github.com/nspcc-dev/neofs-authmate/credentials" "github.com/nspcc-dev/neofs-authmate/gates" manager "github.com/nspcc-dev/neofs-authmate/neofsmanager" - crypto "github.com/nspcc-dev/neofs-crypto" "github.com/pkg/errors" "go.uber.org/zap" ) @@ -50,9 +49,10 @@ func NewCenter(log *zap.Logger, neofsNodeAddress string) (*Center, error) { } func (center *Center) SetNeoFSKeys(key *ecdsa.PrivateKey) error { - // TODO: Change when credentials will start taking not just a string. - wif, _ := crypto.WIFEncode(key) - creds, _ := credentials.NewCredentials(wif) + creds, err := credentials.NewFromKey(key) + if err != nil { + return err + } center.neofsCredentials = creds return nil } @@ -65,7 +65,7 @@ func (center *Center) GetOwnerID() refs.OwnerID { return center.neofsCredentials.OwnerID() } -func (center *Center) SetUserAuthKeys(key hcs.X25519PrivateKey) error { +func (center *Center) SetAuthKeys(key hcs.X25519PrivateKey) error { keys, err := hcs.NewKeys(key) if err != nil { return err diff --git a/cmd/gate/app-settings.go b/cmd/gate/app-settings.go index 69522258..4e121e48 100644 --- a/cmd/gate/app-settings.go +++ b/cmd/gate/app-settings.go @@ -118,7 +118,7 @@ func fetchAuthCenter(l *zap.Logger, v *viper.Viper, peers []pool.Peer) (*auth.Ce if err != nil { return nil, errors.Wrap(err, "failed to create auth center") } - if err = center.SetUserAuthKeys(gateAuthPrivateKey); err != nil { + if err = center.SetAuthKeys(gateAuthPrivateKey); err != nil { return nil, errors.Wrap(err, "failed to set gate auth keys") } if err = center.SetNeoFSKeys(neofsPrivateKey); err != nil {