[#525] v2/container: Write session token from header to removal witness
If container is removed via session, then session token should be included in removal witness. Write session token from request meta header to `container.RemovalWitness` structure which is passed to `wrapper.Delete` function. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
40c796bd7e
commit
a1bfcdc74a
2 changed files with 5 additions and 3 deletions
|
@ -17,7 +17,7 @@ type ContextWithToken struct {
|
|||
|
||||
type ServiceExecutor interface {
|
||||
Put(ContextWithToken, *container.PutRequestBody) (*container.PutResponseBody, error)
|
||||
Delete(context.Context, *container.DeleteRequestBody) (*container.DeleteResponseBody, error)
|
||||
Delete(ContextWithToken, *container.DeleteRequestBody) (*container.DeleteResponseBody, error)
|
||||
Get(context.Context, *container.GetRequestBody) (*container.GetResponseBody, error)
|
||||
List(context.Context, *container.ListRequestBody) (*container.ListResponseBody, error)
|
||||
SetExtendedACL(ContextWithToken, *container.SetExtendedACLRequestBody) (*container.SetExtendedACLResponseBody, error)
|
||||
|
@ -65,7 +65,7 @@ func (s *executorSvc) Put(ctx context.Context, req *container.PutRequest) (*cont
|
|||
}
|
||||
|
||||
func (s *executorSvc) Delete(ctx context.Context, req *container.DeleteRequest) (*container.DeleteResponse, error) {
|
||||
respBody, err := s.exec.Delete(ctx, req.GetBody())
|
||||
respBody, err := s.exec.Delete(contextWithTokenFromRequest(ctx, req), req.GetBody())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not execute Delete request: %w", err)
|
||||
}
|
||||
|
|
|
@ -51,14 +51,16 @@ func (s *morphExecutor) Put(ctx containerSvc.ContextWithToken, body *container.P
|
|||
return res, nil
|
||||
}
|
||||
|
||||
func (s *morphExecutor) Delete(ctx context.Context, body *container.DeleteRequestBody) (*container.DeleteResponseBody, error) {
|
||||
func (s *morphExecutor) Delete(ctx containerSvc.ContextWithToken, body *container.DeleteRequestBody) (*container.DeleteResponseBody, error) {
|
||||
cid := containerSDK.NewIDFromV2(body.GetContainerID())
|
||||
sig := body.GetSignature().GetSign()
|
||||
tok := session.NewTokenFromV2(ctx.SessionToken)
|
||||
|
||||
var rmWitness containercore.RemovalWitness
|
||||
|
||||
rmWitness.SetContainerID(cid)
|
||||
rmWitness.SetSignature(sig)
|
||||
rmWitness.SetSessionToken(tok)
|
||||
|
||||
err := wrapper.Delete(s.wrapper, rmWitness)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue