[#17] acl: Add impersonate flag to bearer token
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
5f318f0b75
commit
b3ccd0166f
6 changed files with 28 additions and 1 deletions
|
@ -3,6 +3,8 @@
|
|||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- Add impersonate flag to bearer token (#17)
|
||||
|
||||
### Fixed
|
||||
### Changed
|
||||
### Updated
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
BIN
acl/grpc/types.pb.go
generated
BIN
acl/grpc/types.pb.go
generated
Binary file not shown.
|
@ -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
|
||||
}
|
||||
|
|
14
acl/types.go
14
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
|
||||
|
|
Loading…
Reference in a new issue