diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ab694e..8f7a84e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## [Unreleased] ### Added +- Add impersonate flag to bearer token (#17) + ### Fixed ### Changed ### Updated diff --git a/acl/convert.go b/acl/convert.go index d42aebd..3020f4d 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 e1e5336..b07f893 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 3581b88..583f89a 100644 Binary files a/acl/grpc/types.pb.go and b/acl/grpc/types.pb.go differ diff --git a/acl/marshal.go b/acl/marshal.go index c56b90f..cd6c6dd 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 71d83ce..1524e7b 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 diff --git a/container/grpc/service_grpc.pb.go b/container/grpc/service_grpc.pb.go index 3af498b..1de8b5f 100644 Binary files a/container/grpc/service_grpc.pb.go and b/container/grpc/service_grpc.pb.go differ diff --git a/object/grpc/service.go b/object/grpc/service.go index 44b5f4a..74dc168 100644 --- a/object/grpc/service.go +++ b/object/grpc/service.go @@ -109,7 +109,7 @@ func (m *PutRequest_Body_Init) SetHeader(v *Header) { } // SetCopiesNumber sets number of the copies to save. -func (m *PutRequest_Body_Init) SetCopiesNumber(v uint32) { +func (m *PutRequest_Body_Init) SetCopiesNumber(v []uint32) { m.CopiesNumber = v } diff --git a/object/grpc/service.pb.go b/object/grpc/service.pb.go index 207b0b0..6ba4090 100644 Binary files a/object/grpc/service.pb.go and b/object/grpc/service.pb.go differ diff --git a/object/grpc/service_grpc.pb.go b/object/grpc/service_grpc.pb.go index 23906d6..6b1c32a 100644 Binary files a/object/grpc/service_grpc.pb.go and b/object/grpc/service_grpc.pb.go differ diff --git a/object/marshal.go b/object/marshal.go index b918e69..7a89b97 100644 --- a/object/marshal.go +++ b/object/marshal.go @@ -516,7 +516,7 @@ func (r *PutObjectPartInit) StableMarshal(buf []byte) []byte { offset += proto.NestedStructureMarshal(putReqInitObjectIDField, buf[offset:], r.id) offset += proto.NestedStructureMarshal(putReqInitSignatureField, buf[offset:], r.sig) offset += proto.NestedStructureMarshal(putReqInitHeaderField, buf[offset:], r.hdr) - proto.UInt32Marshal(putReqInitCopiesNumField, buf[offset:], r.copyNum) + proto.RepeatedUInt32Marshal(putReqInitCopiesNumField, buf[offset:], r.copyNum) return buf } @@ -529,7 +529,9 @@ func (r *PutObjectPartInit) StableSize() (size int) { size += proto.NestedStructureSize(putReqInitObjectIDField, r.id) size += proto.NestedStructureSize(putReqInitSignatureField, r.sig) size += proto.NestedStructureSize(putReqInitHeaderField, r.hdr) - size += proto.UInt32Size(putReqInitCopiesNumField, r.copyNum) + + arrSize, _ := proto.RepeatedUInt32Size(putReqInitCopiesNumField, r.copyNum) + size += arrSize return size } diff --git a/object/test/generate.go b/object/test/generate.go index 0816ffc..32d7a3c 100644 --- a/object/test/generate.go +++ b/object/test/generate.go @@ -216,7 +216,7 @@ func GeneratePutObjectPartInit(empty bool) *object.PutObjectPartInit { m := new(object.PutObjectPartInit) if !empty { - m.SetCopiesNumber(234) + m.SetCopiesNumber([]uint32{234}) m.SetObjectID(refstest.GenerateObjectID(false)) } diff --git a/object/types.go b/object/types.go index f076b74..a40de57 100644 --- a/object/types.go +++ b/object/types.go @@ -128,7 +128,7 @@ type PutObjectPartInit struct { hdr *Header - copyNum uint32 + copyNum []uint32 } type PutObjectPartChunk struct { @@ -894,15 +894,15 @@ func (r *PutObjectPartInit) SetHeader(v *Header) { r.hdr = v } -func (r *PutObjectPartInit) GetCopiesNumber() uint32 { +func (r *PutObjectPartInit) GetCopiesNumber() []uint32 { if r != nil { return r.copyNum } - return 0 + return nil } -func (r *PutObjectPartInit) SetCopiesNumber(v uint32) { +func (r *PutObjectPartInit) SetCopiesNumber(v []uint32) { r.copyNum = v } diff --git a/pkg/tracing/grpc.go b/pkg/tracing/grpc.go index cea59b0..884ecb2 100644 --- a/pkg/tracing/grpc.go +++ b/pkg/tracing/grpc.go @@ -51,7 +51,6 @@ func NewGRPCStreamClientInterceptor() grpc.StreamClientInterceptor { strWrp := newgRPCClientStream(str, desc, finished, done) go func() { - defer close(finished) defer close(done) defer span.End()