From ac00938fa4479c4666f30da21a9a17cbeb7bd591 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Tue, 21 Feb 2023 11:23:08 +0300 Subject: [PATCH] [#XX] Add impersonate flag to bearer token Signed-off-by: Denis Kirillov --- acl/convert.go | 3 +++ acl/grpc/types.go | 5 +++++ acl/grpc/types.pb.go | Bin 38729 -> 39400 bytes acl/marshal.go | 5 ++++- acl/types.go | 14 ++++++++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/acl/convert.go b/acl/convert.go index 697f699..b07639a 100644 --- a/acl/convert.go +++ b/acl/convert.go @@ -427,6 +427,7 @@ func (bt *BearerTokenBody) ToGRPCMessage() grpc.Message { m.SetOwnerId(bt.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID)) m.SetLifetime(bt.lifetime.ToGRPCMessage().(*acl.BearerToken_Body_TokenLifetime)) m.SetEaclTable(bt.eacl.ToGRPCMessage().(*acl.EACLTable)) + m.SetImpersonate(bt.impersonate) } return m @@ -479,6 +480,8 @@ func (bt *BearerTokenBody) FromGRPCMessage(m grpc.Message) error { err = bt.eacl.FromGRPCMessage(eacl) } + bt.impersonate = v.GetAllowImpersonate() + return err } diff --git a/acl/grpc/types.go b/acl/grpc/types.go index 436ae58..c9c0649 100644 --- a/acl/grpc/types.go +++ b/acl/grpc/types.go @@ -84,6 +84,11 @@ func (m *BearerToken_Body) SetLifetime(v *BearerToken_Body_TokenLifetime) { m.Lifetime = v } +// SetImpersonate allows impersonate. +func (m *BearerToken_Body) SetImpersonate(v bool) { + m.AllowImpersonate = v +} + // SetBody sets bearer token body. func (m *BearerToken) SetBody(v *BearerToken_Body) { m.Body = v diff --git a/acl/grpc/types.pb.go b/acl/grpc/types.pb.go index 6e9ac460474a8a6b0bc7ed9e8a762b7aa4009cd2..0f546a20b35c92f512937d07d4cf79fd967907c5 100644 GIT binary patch delta 1315 zcmaJ=K}Zx)7^Y>C7XKuew#YPFReNJ!}N(q zH*3^q#NFb7iMSwHC=#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OV~GTvTOMgEPk9c O4s?bzzx2t_F8>3@-08po diff --git a/acl/marshal.go b/acl/marshal.go index 1ecdb70..c744798 100644 --- a/acl/marshal.go +++ b/acl/marshal.go @@ -31,6 +31,7 @@ const ( bearerTokenBodyACLField = 1 bearerTokenBodyOwnerField = 2 bearerTokenBodyLifetimeField = 3 + bearerTokenBodyImpersonate = 4 bearerTokenBodyField = 1 bearerTokenSignatureField = 2 @@ -251,7 +252,8 @@ func (bt *BearerTokenBody) StableMarshal(buf []byte) []byte { offset += protoutil.NestedStructureMarshal(bearerTokenBodyACLField, buf[offset:], bt.eacl) offset += protoutil.NestedStructureMarshal(bearerTokenBodyOwnerField, buf[offset:], bt.ownerID) - protoutil.NestedStructureMarshal(bearerTokenBodyLifetimeField, buf[offset:], bt.lifetime) + offset += protoutil.NestedStructureMarshal(bearerTokenBodyLifetimeField, buf[offset:], bt.lifetime) + protoutil.BoolMarshal(bearerTokenBodyImpersonate, buf[offset:], bt.impersonate) return buf } @@ -264,6 +266,7 @@ func (bt *BearerTokenBody) StableSize() (size int) { size += protoutil.NestedStructureSize(bearerTokenBodyACLField, bt.eacl) size += protoutil.NestedStructureSize(bearerTokenBodyOwnerField, bt.ownerID) size += protoutil.NestedStructureSize(bearerTokenBodyLifetimeField, bt.lifetime) + size += protoutil.BoolSize(bearerTokenBodyImpersonate, bt.impersonate) return size } diff --git a/acl/types.go b/acl/types.go index f360af6..a2309cb 100644 --- a/acl/types.go +++ b/acl/types.go @@ -52,6 +52,8 @@ type BearerTokenBody struct { ownerID *refs.OwnerID lifetime *TokenLifetime + + impersonate bool } type BearerToken struct { @@ -340,6 +342,18 @@ func (bt *BearerTokenBody) SetLifetime(v *TokenLifetime) { bt.lifetime = v } +func (bt *BearerTokenBody) GetImpersonate() bool { + if bt != nil { + return bt.impersonate + } + + return false +} + +func (bt *BearerTokenBody) SetImpersonate(v bool) { + bt.impersonate = v +} + func (bt *BearerToken) GetBody() *BearerTokenBody { if bt != nil { return bt.body