Skip to content

Commit 77314fc

Browse files
authored
Fix creating system admin rolebinding with no resource is not allowed (#246)
1 parent 16b0397 commit 77314fc

File tree

5 files changed

+39
-26
lines changed

5 files changed

+39
-26
lines changed

api/domain/commanddata/user.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ message CreateUserRoleBindingCommandData {
4747
// Unique identifier of the affected resource within scope (UUID 128-bit
4848
// number)
4949
google.protobuf.StringValue resource = 4
50-
[ (validate.rules).string.uuid = true ];
50+
[ (validate.rules).string = {ignore_empty: true, uuid: true} ];
5151
}
5252

5353
// Command data to update a user

go.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ endif
103103
ifeq ($(PROTO_ARCH),arm64)
104104
PROTO_ARCH = aarch_64
105105
endif
106+
ifeq ($(PROTO_ARCH),amd64)
107+
PROTO_ARCH = x86_64
108+
endif
106109
PROTO_ARCH_OS := $(PROTO_OS)-$(PROTO_ARCH)
107110

108111
## Tool Config

pkg/api/domain/commanddata/user.pb.go

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/api/domain/commanddata/user.pb.validate.go

Lines changed: 13 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/grpc/middleware/validator/user_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ var _ = Describe("Test validation rules for user messages", func() {
7272
Expect(err).NotTo(HaveOccurred())
7373
})
7474

75+
It("should allow empty resource id for cases like system admin", func() {
76+
cd.Resource = wrapperspb.String("")
77+
err := cd.Validate()
78+
Expect(err).NotTo(HaveOccurred())
79+
})
80+
7581
It("should check for a valid UserId", func() {
7682
cd.UserId = invalidUUID
7783
ValidateErrorExpected()

0 commit comments

Comments
 (0)