2020-08-24 14:54:48 +00:00
|
|
|
package session
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/ecdsa"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util"
|
2024-11-07 14:32:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session"
|
2020-08-24 14:54:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type signService struct {
|
2020-08-26 09:43:39 +00:00
|
|
|
sigSvc *util.SignService
|
2020-08-26 09:20:26 +00:00
|
|
|
|
2021-03-15 10:53:08 +00:00
|
|
|
svc Server
|
2020-08-24 14:54:48 +00:00
|
|
|
}
|
|
|
|
|
2021-03-15 10:53:08 +00:00
|
|
|
func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
|
2020-08-24 14:54:48 +00:00
|
|
|
return &signService{
|
2020-08-26 09:43:39 +00:00
|
|
|
sigSvc: util.NewUnarySignService(key),
|
2020-09-21 09:33:55 +00:00
|
|
|
svc: svc,
|
2020-08-24 14:54:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *signService) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error) {
|
2022-12-30 15:26:43 +00:00
|
|
|
if err := s.sigSvc.VerifyRequest(req); err != nil {
|
|
|
|
resp := new(session.CreateResponse)
|
2023-07-26 12:47:32 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
2020-08-24 14:54:48 +00:00
|
|
|
}
|
2022-12-30 15:26:43 +00:00
|
|
|
resp, err := util.EnsureNonNilResponse(s.svc.Create(ctx, req))
|
2023-07-26 12:47:32 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
2020-08-24 14:54:48 +00:00
|
|
|
}
|