[#17] acl: Add impersonate flag to bearer token

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2023-02-21 11:23:08 +03:00
parent 5f318f0b75
commit b3ccd0166f
6 changed files with 28 additions and 1 deletions

View file

@ -3,6 +3,8 @@
## [Unreleased] ## [Unreleased]
### Added ### Added
- Add impersonate flag to bearer token (#17)
### Fixed ### Fixed
### Changed ### Changed
### Updated ### Updated

View file

@ -427,6 +427,7 @@ func (bt *BearerTokenBody) ToGRPCMessage() grpc.Message {
m.SetOwnerId(bt.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID)) m.SetOwnerId(bt.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID))
m.SetLifetime(bt.lifetime.ToGRPCMessage().(*acl.BearerToken_Body_TokenLifetime)) m.SetLifetime(bt.lifetime.ToGRPCMessage().(*acl.BearerToken_Body_TokenLifetime))
m.SetEaclTable(bt.eacl.ToGRPCMessage().(*acl.EACLTable)) m.SetEaclTable(bt.eacl.ToGRPCMessage().(*acl.EACLTable))
m.SetImpersonate(bt.impersonate)
} }
return m return m
@ -479,6 +480,8 @@ func (bt *BearerTokenBody) FromGRPCMessage(m grpc.Message) error {
err = bt.eacl.FromGRPCMessage(eacl) err = bt.eacl.FromGRPCMessage(eacl)
} }
bt.impersonate = v.GetAllowImpersonate()
return err return err
} }

View file

@ -84,6 +84,11 @@ func (m *BearerToken_Body) SetLifetime(v *BearerToken_Body_TokenLifetime) {
m.Lifetime = v m.Lifetime = v
} }
// SetImpersonate allows impersonate.
func (m *BearerToken_Body) SetImpersonate(v bool) {
m.AllowImpersonate = v
}
// SetBody sets bearer token body. // SetBody sets bearer token body.
func (m *BearerToken) SetBody(v *BearerToken_Body) { func (m *BearerToken) SetBody(v *BearerToken_Body) {
m.Body = v m.Body = v

BIN
acl/grpc/types.pb.go generated

Binary file not shown.

View file

@ -31,6 +31,7 @@ const (
bearerTokenBodyACLField = 1 bearerTokenBodyACLField = 1
bearerTokenBodyOwnerField = 2 bearerTokenBodyOwnerField = 2
bearerTokenBodyLifetimeField = 3 bearerTokenBodyLifetimeField = 3
bearerTokenBodyImpersonate = 4
bearerTokenBodyField = 1 bearerTokenBodyField = 1
bearerTokenSignatureField = 2 bearerTokenSignatureField = 2
@ -251,7 +252,8 @@ func (bt *BearerTokenBody) StableMarshal(buf []byte) []byte {
offset += protoutil.NestedStructureMarshal(bearerTokenBodyACLField, buf[offset:], bt.eacl) offset += protoutil.NestedStructureMarshal(bearerTokenBodyACLField, buf[offset:], bt.eacl)
offset += protoutil.NestedStructureMarshal(bearerTokenBodyOwnerField, buf[offset:], bt.ownerID) 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 return buf
} }
@ -264,6 +266,7 @@ func (bt *BearerTokenBody) StableSize() (size int) {
size += protoutil.NestedStructureSize(bearerTokenBodyACLField, bt.eacl) size += protoutil.NestedStructureSize(bearerTokenBodyACLField, bt.eacl)
size += protoutil.NestedStructureSize(bearerTokenBodyOwnerField, bt.ownerID) size += protoutil.NestedStructureSize(bearerTokenBodyOwnerField, bt.ownerID)
size += protoutil.NestedStructureSize(bearerTokenBodyLifetimeField, bt.lifetime) size += protoutil.NestedStructureSize(bearerTokenBodyLifetimeField, bt.lifetime)
size += protoutil.BoolSize(bearerTokenBodyImpersonate, bt.impersonate)
return size return size
} }

View file

@ -52,6 +52,8 @@ type BearerTokenBody struct {
ownerID *refs.OwnerID ownerID *refs.OwnerID
lifetime *TokenLifetime lifetime *TokenLifetime
impersonate bool
} }
type BearerToken struct { type BearerToken struct {
@ -340,6 +342,18 @@ func (bt *BearerTokenBody) SetLifetime(v *TokenLifetime) {
bt.lifetime = v 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 { func (bt *BearerToken) GetBody() *BearerTokenBody {
if bt != nil { if bt != nil {
return bt.body return bt.body