forked from TrueCloudLab/frostfs-s3-gw
Add error checking while creating auth center
This commit is contained in:
parent
c6b6076544
commit
b5bd835cd5
2 changed files with 14 additions and 5 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue