From e7e71d620276b621e373d81b9b1f740e71b2fc8b Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Mon, 14 Feb 2022 22:37:50 +0300 Subject: [PATCH] [#352] Add appending of SetEACL token in authmate If Put session context exists Signed-off-by: Angira Kekteeva --- authmate/authmate.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/authmate/authmate.go b/authmate/authmate.go index e94b8d0..71ad1ed 100644 --- a/authmate/authmate.go +++ b/authmate/authmate.go @@ -384,6 +384,24 @@ func buildContext(rules []byte) ([]*session.ContainerContext, error) { if err != nil { return nil, fmt.Errorf("failed to unmarshal rules for session token: %w", err) } + + var ( + containsPut = false + containsSetEACL = false + ) + for _, s := range sessionCtxs { + if s.IsForPut() { + containsPut = true + } else if s.IsForSetEACL() { + containsSetEACL = true + } + } + if containsPut && !containsSetEACL { + ectx := session.NewContainerContext() + ectx.ForSetEACL() + sessionCtxs = append(sessionCtxs, ectx) + } + return sessionCtxs, nil }