Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support bearer token issuer #446

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
}
}

issuer := v.GetIssuer()
if issuer == nil {
bt.issuer = nil

Check warning on line 470 in acl/convert.go

View check run for this annotation

Codecov / codecov/patch

acl/convert.go#L470

Added line #L470 was not covered by tests
} else {
if bt.issuer == nil {
bt.issuer = new(refs.OwnerID)
}

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

Check warning on line 478 in acl/convert.go

View check run for this annotation

Codecov / codecov/patch

acl/convert.go#L478

Added line #L478 was not covered by tests
}
}

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 BearerTokenBody struct {
eacl *Table

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

lifetime *TokenLifetime
}
Expand Down Expand Up @@ -334,6 +334,18 @@
bt.ownerID = v
}

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

Check warning on line 339 in acl/types.go

View check run for this annotation

Codecov / codecov/patch

acl/types.go#L337-L339

Added lines #L337 - L339 were not covered by tests
}

return nil

Check warning on line 342 in acl/types.go

View check run for this annotation

Codecov / codecov/patch

acl/types.go#L342

Added line #L342 was not covered by tests
}

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
Loading