diff --git a/auth/center.go b/auth/center.go index 83bfc6f44..5400ec469 100644 --- a/auth/center.go +++ b/auth/center.go @@ -45,15 +45,21 @@ type Center struct { } // NewCenter creates an instance of AuthCenter. -func NewCenter(log *zap.Logger) *Center { - zstdEncoder, _ := zstd.NewWriter(nil) - zstdDecoder, _ := zstd.NewReader(nil) +func NewCenter(log *zap.Logger) (*Center, error) { + zstdEncoder, err := zstd.NewWriter(nil) + if err != nil { + return nil, errors.Wrap(err, "failed to create zstd encoder") + } + zstdDecoder, err := zstd.NewReader(nil) + if err != nil { + return nil, errors.Wrap(err, "failed to create zstd decoder") + } return &Center{ log: log, submatcher: ®expSubmatcher{re: authorizationFieldRegexp}, zstdEncoder: zstdEncoder, zstdDecoder: zstdDecoder, - } + }, nil } func (center *Center) SetNeoFSKeys(key *ecdsa.PrivateKey) error { diff --git a/cmd/gate/app-settings.go b/cmd/gate/app-settings.go index 5461f512f..323338f70 100644 --- a/cmd/gate/app-settings.go +++ b/cmd/gate/app-settings.go @@ -110,7 +110,10 @@ func fetchAuthCenter(l *zap.Logger, v *viper.Viper) (*auth.Center, error) { if err != nil { return nil, errors.Wrap(err, "could not load UserAuth private key") } - center := auth.NewCenter(l) + center, err := auth.NewCenter(l) + if err != nil { + return nil, errors.Wrap(err, "failed to create auth center") + } center.SetUserAuthKeys(userAuthPrivateKey) center.SetNeoFSKeys(neofsPrivateKey) return center, nil