Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #446 from nspcc-dev/feature/bearer-issuer
Browse files Browse the repository at this point in the history
Support bearer token issuer
  • Loading branch information
roman-khimov authored Mar 5, 2024
2 parents cb87bbd + c97dae0 commit 35bc78d
Show file tree
Hide file tree
Showing 28 changed files with 169 additions and 111 deletions.
2 changes: 1 addition & 1 deletion accounting/grpc/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion accounting/grpc/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions acl/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ func (bt *BearerTokenBody) ToGRPCMessage() grpc.Message {
m = new(acl.BearerToken_Body)

m.SetOwnerId(bt.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID))
m.SetIssuer(bt.issuer.ToGRPCMessage().(*refsGRPC.OwnerID))
m.SetLifetime(bt.lifetime.ToGRPCMessage().(*acl.BearerToken_Body_TokenLifetime))
m.SetEaclTable(bt.eacl.ToGRPCMessage().(*acl.EACLTable))
}
Expand Down Expand Up @@ -464,6 +465,20 @@ func (bt *BearerTokenBody) FromGRPCMessage(m grpc.Message) error {
}
}

issuer := v.GetIssuer()
if issuer == nil {
bt.issuer = nil
} else {
if bt.issuer == nil {
bt.issuer = new(refs.OwnerID)
}

err = bt.issuer.FromGRPCMessage(issuer)
if err != nil {
return err
}
}

lifetime := v.GetLifetime()
if lifetime == nil {
bt.lifetime = nil
Expand Down
5 changes: 5 additions & 0 deletions acl/grpc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func (m *BearerToken_Body) SetOwnerId(v *refs.OwnerID) {
m.OwnerId = v
}

// SetIssuer sets identifier of the bearer token issuer.
func (m *BearerToken_Body) SetIssuer(v *refs.OwnerID) {
m.Issuer = v
}

// SetLifetime sets lifetime of the bearer token.
func (m *BearerToken_Body) SetLifetime(v *BearerToken_Body_TokenLifetime) {
m.Lifetime = v
Expand Down
110 changes: 62 additions & 48 deletions acl/grpc/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion acl/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
bearerTokenBodyACLField = 1
bearerTokenBodyOwnerField = 2
bearerTokenBodyLifetimeField = 3
bearerTokenBodyIssuerField = 4

bearerTokenBodyField = 1
bearerTokenSignatureField = 2
Expand Down Expand Up @@ -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.NestedStructureMarshal(bearerTokenBodyIssuerField, buf[offset:], bt.issuer)

return buf
}
Expand All @@ -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.NestedStructureSize(bearerTokenBodyIssuerField, bt.issuer)

return size
}
Expand Down
1 change: 1 addition & 0 deletions acl/test/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func GenerateBearerTokenBody(empty bool) *acl.BearerTokenBody {

if !empty {
m.SetOwnerID(accountingtest.GenerateOwnerID(false))
m.SetIssuer(accountingtest.GenerateOwnerID(false))
m.SetEACL(GenerateTable(false))
m.SetLifetime(GenerateTokenLifetime(false))
}
Expand Down
14 changes: 13 additions & 1 deletion acl/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type TokenLifetime struct {
type BearerTokenBody struct {
eacl *Table

ownerID *refs.OwnerID
ownerID, issuer *refs.OwnerID

lifetime *TokenLifetime
}
Expand Down Expand Up @@ -334,6 +334,18 @@ func (bt *BearerTokenBody) SetOwnerID(v *refs.OwnerID) {
bt.ownerID = v
}

func (bt *BearerTokenBody) GetIssuer() *refs.OwnerID {
if bt != nil {
return bt.issuer
}

return nil
}

func (bt *BearerTokenBody) SetIssuer(v *refs.OwnerID) {
bt.issuer = v
}

func (bt *BearerTokenBody) GetLifetime() *TokenLifetime {
if bt != nil {
return bt.lifetime
Expand Down
2 changes: 1 addition & 1 deletion audit/grpc/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion container/grpc/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion container/grpc/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion link/grpc/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lock/grpc/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion netmap/grpc/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion netmap/grpc/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions object/grpc/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 35bc78d

Please sign in to comment.