frostfs-node/pkg/services/apemanager/sign.go
Airat Arifullin 9b13a18aac [#1479] go.mod: Bump frostfs-sdk-go version
* Update version within go.mod;
* Fix deprecated frostfs-api-go/v2 package and use frostfs-sdk-go/api
  instead.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
2024-11-08 10:43:19 +03:00

49 lines
1.6 KiB
Go

package apemanager
import (
"context"
"crypto/ecdsa"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util"
apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/apemanager"
)
type signService struct {
sigSvc *util.SignService
next Server
}
func NewSignService(key *ecdsa.PrivateKey, next Server) Server {
return &signService{
sigSvc: util.NewUnarySignService(key),
next: next,
}
}
func (s *signService) AddChain(ctx context.Context, req *apemanager_v2.AddChainRequest) (*apemanager_v2.AddChainResponse, error) {
if err := s.sigSvc.VerifyRequest(req); err != nil {
resp := new(apemanager_v2.AddChainResponse)
return resp, s.sigSvc.SignResponse(resp, err)
}
resp, err := util.EnsureNonNilResponse(s.next.AddChain(ctx, req))
return resp, s.sigSvc.SignResponse(resp, err)
}
func (s *signService) RemoveChain(ctx context.Context, req *apemanager_v2.RemoveChainRequest) (*apemanager_v2.RemoveChainResponse, error) {
if err := s.sigSvc.VerifyRequest(req); err != nil {
resp := new(apemanager_v2.RemoveChainResponse)
return resp, s.sigSvc.SignResponse(resp, err)
}
resp, err := util.EnsureNonNilResponse(s.next.RemoveChain(ctx, req))
return resp, s.sigSvc.SignResponse(resp, err)
}
func (s *signService) ListChains(ctx context.Context, req *apemanager_v2.ListChainsRequest) (*apemanager_v2.ListChainsResponse, error) {
if err := s.sigSvc.VerifyRequest(req); err != nil {
resp := new(apemanager_v2.ListChainsResponse)
return resp, s.sigSvc.SignResponse(resp, err)
}
resp, err := util.EnsureNonNilResponse(s.next.ListChains(ctx, req))
return resp, s.sigSvc.SignResponse(resp, err)
}