From b09f21299050083266b9ab756a7d0ebe12d24465 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 25 May 2021 19:25:14 +0300 Subject: [PATCH] [#525] v2/container: Write session token from header to eACL table If eACL table is set via session, then session token should be written to it. Write session token from request meta header to `eacl.Table` structure which is passed to `wrapper.PutEACL` function. Signed-off-by: Leonard Lyubich --- pkg/services/container/executor.go | 4 ++-- pkg/services/container/morph/executor.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/services/container/executor.go b/pkg/services/container/executor.go index 7dc74843..0c73cc75 100644 --- a/pkg/services/container/executor.go +++ b/pkg/services/container/executor.go @@ -20,7 +20,7 @@ type ServiceExecutor interface { Delete(context.Context, *container.DeleteRequestBody) (*container.DeleteResponseBody, error) Get(context.Context, *container.GetRequestBody) (*container.GetResponseBody, error) List(context.Context, *container.ListRequestBody) (*container.ListResponseBody, error) - SetExtendedACL(context.Context, *container.SetExtendedACLRequestBody) (*container.SetExtendedACLResponseBody, error) + SetExtendedACL(ContextWithToken, *container.SetExtendedACLRequestBody) (*container.SetExtendedACLResponseBody, error) GetExtendedACL(context.Context, *container.GetExtendedACLRequestBody) (*container.GetExtendedACLResponseBody, error) } @@ -101,7 +101,7 @@ func (s *executorSvc) List(ctx context.Context, req *container.ListRequest) (*co } func (s *executorSvc) SetExtendedACL(ctx context.Context, req *container.SetExtendedACLRequest) (*container.SetExtendedACLResponse, error) { - respBody, err := s.exec.SetExtendedACL(ctx, req.GetBody()) + respBody, err := s.exec.SetExtendedACL(contextWithTokenFromRequest(ctx, req), req.GetBody()) if err != nil { return nil, fmt.Errorf("could not execute SetEACL request: %w", err) } diff --git a/pkg/services/container/morph/executor.go b/pkg/services/container/morph/executor.go index 8fde3960..69788b65 100644 --- a/pkg/services/container/morph/executor.go +++ b/pkg/services/container/morph/executor.go @@ -97,12 +97,16 @@ func (s *morphExecutor) List(ctx context.Context, body *container.ListRequestBod return res, nil } -func (s *morphExecutor) SetExtendedACL(ctx context.Context, body *container.SetExtendedACLRequestBody) (*container.SetExtendedACLResponseBody, error) { +func (s *morphExecutor) SetExtendedACL(ctx containerSvc.ContextWithToken, body *container.SetExtendedACLRequestBody) (*container.SetExtendedACLResponseBody, error) { table := eaclSDK.NewTableFromV2(body.GetEACL()) sign := pkg.NewSignatureFromV2(body.GetSignature()) table.SetSignature(sign) + table.SetSessionToken( + session.NewTokenFromV2(ctx.SessionToken), + ) + err := wrapper.PutEACL(s.wrapper, table) return new(container.SetExtendedACLResponseBody), err