diff --git a/app/cli/cmd/organization_describe.go b/app/cli/cmd/organization_describe.go index b29813e0d..c09ce455a 100644 --- a/app/cli/cmd/organization_describe.go +++ b/app/cli/cmd/organization_describe.go @@ -46,7 +46,11 @@ func contextTableOutput(config *action.ConfigContextItem) error { gt.SetTitle("Current Context") gt.AppendRow(table.Row{"Logged in as", config.CurrentUser.Email}) gt.AppendSeparator() - gt.AppendRow(table.Row{"Organization", fmt.Sprintf("%s (%s)", config.CurrentOrg.Name, config.CurrentOrg.ID)}) + + if m := config.CurrentMembership; m != nil { + gt.AppendRow(table.Row{"Organization", fmt.Sprintf("%s (role=%s)", m.Org.Name, m.Role)}) + } + backend := config.CurrentCASBackend if backend != nil { gt.AppendSeparator() diff --git a/app/cli/cmd/organization_list.go b/app/cli/cmd/organization_list.go index 3742898be..71a0f260a 100644 --- a/app/cli/cmd/organization_list.go +++ b/app/cli/cmd/organization_list.go @@ -1,5 +1,5 @@ // -// Copyright 2023 The Chainloop Authors. +// Copyright 2024 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -49,10 +49,10 @@ func orgMembershipTableOutput(items []*action.MembershipItem) error { } t := newTableWriter() - t.AppendHeader(table.Row{"Org ID", "Org Name", "Current", "Joined At"}) + t.AppendHeader(table.Row{"Org ID", "Org Name", "Current", "Role", "Joined At"}) for _, i := range items { - t.AppendRow(table.Row{i.Org.ID, i.Org.Name, i.Current, i.CreatedAt.Format(time.RFC822)}) + t.AppendRow(table.Row{i.Org.ID, i.Org.Name, i.Current, i.Role, i.CreatedAt.Format(time.RFC822)}) t.AppendSeparator() } diff --git a/app/cli/internal/action/config_current_context.go b/app/cli/internal/action/config_current_context.go index c6fb235a3..4149dd4ef 100644 --- a/app/cli/internal/action/config_current_context.go +++ b/app/cli/internal/action/config_current_context.go @@ -32,7 +32,7 @@ func NewConfigCurrentContext(cfg *ActionsOpts) *ConfigCurrentContext { type ConfigContextItem struct { CurrentUser *UserItem - CurrentOrg *OrgItem + CurrentMembership *MembershipItem CurrentCASBackend *CASBackendItem } @@ -52,7 +52,7 @@ func (action *ConfigCurrentContext) Run() (*ConfigContextItem, error) { return &ConfigContextItem{ CurrentUser: pbUserItemToAction(res.GetCurrentUser()), - CurrentOrg: pbOrgItemToAction(res.GetCurrentOrg()), + CurrentMembership: pbMembershipItemToAction(res.GetCurrentMembership()), CurrentCASBackend: pbCASBackendItemToAction(res.GetCurrentCasBackend()), }, nil } diff --git a/app/cli/internal/action/membership_list.go b/app/cli/internal/action/membership_list.go index 31570c6e5..dd6d82c53 100644 --- a/app/cli/internal/action/membership_list.go +++ b/app/cli/internal/action/membership_list.go @@ -1,5 +1,5 @@ // -// Copyright 2023 The Chainloop Authors. +// Copyright 2024 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ type MembershipItem struct { CreatedAt *time.Time `json:"joinedAt"` UpdatedAt *time.Time `json:"updatedAt"` Org *OrgItem + Role string `json:"role"` } func NewMembershipList(cfg *ActionsOpts) *MembershipList { @@ -71,11 +72,22 @@ func pbMembershipItemToAction(in *pb.OrgMembershipItem) *MembershipItem { return nil } + var role string + switch in.Role { + case pb.MembershipRole_MEMBERSHIP_ROLE_ORG_ADMIN: + role = "admin" + case pb.MembershipRole_MEMBERSHIP_ROLE_ORG_VIEWER: + role = "viewer" + case pb.MembershipRole_MEMBERSHIP_ROLE_ORG_OWNER: + role = "owner" + } + return &MembershipItem{ ID: in.GetId(), CreatedAt: toTimePtr(in.GetCreatedAt().AsTime()), UpdatedAt: toTimePtr(in.GetCreatedAt().AsTime()), Org: pbOrgItemToAction(in.Org), Current: in.Current, + Role: role, } } diff --git a/app/controlplane/api/controlplane/v1/context.pb.go b/app/controlplane/api/controlplane/v1/context.pb.go index d6df31572..6596fd18c 100644 --- a/app/controlplane/api/controlplane/v1/context.pb.go +++ b/app/controlplane/api/controlplane/v1/context.pb.go @@ -1,5 +1,5 @@ // -// Copyright 2023 The Chainloop Authors. +// Copyright 2024 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -125,9 +125,9 @@ type ContextServiceCurrentResponse_Result struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - CurrentUser *User `protobuf:"bytes,1,opt,name=current_user,json=currentUser,proto3" json:"current_user,omitempty"` - CurrentOrg *OrgItem `protobuf:"bytes,2,opt,name=current_org,json=currentOrg,proto3" json:"current_org,omitempty"` - CurrentCasBackend *CASBackendItem `protobuf:"bytes,3,opt,name=current_cas_backend,json=currentCasBackend,proto3" json:"current_cas_backend,omitempty"` + CurrentUser *User `protobuf:"bytes,1,opt,name=current_user,json=currentUser,proto3" json:"current_user,omitempty"` + CurrentMembership *OrgMembershipItem `protobuf:"bytes,2,opt,name=current_membership,json=currentMembership,proto3" json:"current_membership,omitempty"` + CurrentCasBackend *CASBackendItem `protobuf:"bytes,3,opt,name=current_cas_backend,json=currentCasBackend,proto3" json:"current_cas_backend,omitempty"` } func (x *ContextServiceCurrentResponse_Result) Reset() { @@ -169,9 +169,9 @@ func (x *ContextServiceCurrentResponse_Result) GetCurrentUser() *User { return nil } -func (x *ContextServiceCurrentResponse_Result) GetCurrentOrg() *OrgItem { +func (x *ContextServiceCurrentResponse_Result) GetCurrentMembership() *OrgMembershipItem { if x != nil { - return x.CurrentOrg + return x.CurrentMembership } return nil } @@ -193,40 +193,42 @@ var file_controlplane_v1_context_proto_rawDesc = []byte{ 0x31, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1e, 0x0a, 0x1c, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xbf, 0x02, 0x0a, 0x1d, 0x43, 0x6f, + 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xd7, 0x02, 0x0a, 0x1d, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0xce, 0x01, 0x0a, 0x06, 0x52, + 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0xe6, 0x01, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x38, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, - 0x39, 0x0a, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6f, 0x72, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, - 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x0a, - 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4f, 0x72, 0x67, 0x12, 0x4f, 0x0a, 0x13, 0x63, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x61, 0x73, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, - 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, - 0x6b, 0x65, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x11, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x43, 0x61, 0x73, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x32, 0x7a, 0x0a, 0x0e, 0x43, - 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x68, 0x0a, - 0x07, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, - 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, - 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, - 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, - 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x51, 0x0a, 0x12, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x73, 0x68, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, + 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, + 0x11, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, + 0x69, 0x70, 0x12, 0x4f, 0x0a, 0x13, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x61, + 0x73, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, + 0x52, 0x11, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x61, 0x73, 0x42, 0x61, 0x63, 0x6b, + 0x65, 0x6e, 0x64, 0x32, 0x7a, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x68, 0x0a, 0x07, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -246,14 +248,14 @@ var file_controlplane_v1_context_proto_goTypes = []interface{}{ (*ContextServiceCurrentRequest)(nil), // 0: controlplane.v1.ContextServiceCurrentRequest (*ContextServiceCurrentResponse)(nil), // 1: controlplane.v1.ContextServiceCurrentResponse (*ContextServiceCurrentResponse_Result)(nil), // 2: controlplane.v1.ContextServiceCurrentResponse.Result - (*User)(nil), // 3: controlplane.v1.User - (*OrgItem)(nil), // 4: controlplane.v1.OrgItem - (*CASBackendItem)(nil), // 5: controlplane.v1.CASBackendItem + (*User)(nil), // 3: controlplane.v1.User + (*OrgMembershipItem)(nil), // 4: controlplane.v1.OrgMembershipItem + (*CASBackendItem)(nil), // 5: controlplane.v1.CASBackendItem } var file_controlplane_v1_context_proto_depIdxs = []int32{ 2, // 0: controlplane.v1.ContextServiceCurrentResponse.result:type_name -> controlplane.v1.ContextServiceCurrentResponse.Result 3, // 1: controlplane.v1.ContextServiceCurrentResponse.Result.current_user:type_name -> controlplane.v1.User - 4, // 2: controlplane.v1.ContextServiceCurrentResponse.Result.current_org:type_name -> controlplane.v1.OrgItem + 4, // 2: controlplane.v1.ContextServiceCurrentResponse.Result.current_membership:type_name -> controlplane.v1.OrgMembershipItem 5, // 3: controlplane.v1.ContextServiceCurrentResponse.Result.current_cas_backend:type_name -> controlplane.v1.CASBackendItem 0, // 4: controlplane.v1.ContextService.Current:input_type -> controlplane.v1.ContextServiceCurrentRequest 1, // 5: controlplane.v1.ContextService.Current:output_type -> controlplane.v1.ContextServiceCurrentResponse diff --git a/app/controlplane/api/controlplane/v1/context.pb.validate.go b/app/controlplane/api/controlplane/v1/context.pb.validate.go index cc1006e64..886b5f1d4 100644 --- a/app/controlplane/api/controlplane/v1/context.pb.validate.go +++ b/app/controlplane/api/controlplane/v1/context.pb.validate.go @@ -323,11 +323,11 @@ func (m *ContextServiceCurrentResponse_Result) validate(all bool) error { } if all { - switch v := interface{}(m.GetCurrentOrg()).(type) { + switch v := interface{}(m.GetCurrentMembership()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, ContextServiceCurrentResponse_ResultValidationError{ - field: "CurrentOrg", + field: "CurrentMembership", reason: "embedded message failed validation", cause: err, }) @@ -335,16 +335,16 @@ func (m *ContextServiceCurrentResponse_Result) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, ContextServiceCurrentResponse_ResultValidationError{ - field: "CurrentOrg", + field: "CurrentMembership", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetCurrentOrg()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetCurrentMembership()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ContextServiceCurrentResponse_ResultValidationError{ - field: "CurrentOrg", + field: "CurrentMembership", reason: "embedded message failed validation", cause: err, } diff --git a/app/controlplane/api/controlplane/v1/context.proto b/app/controlplane/api/controlplane/v1/context.proto index 0db394826..4fcb7cd0f 100644 --- a/app/controlplane/api/controlplane/v1/context.proto +++ b/app/controlplane/api/controlplane/v1/context.proto @@ -1,5 +1,5 @@ // -// Copyright 2023 The Chainloop Authors. +// Copyright 2024 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,23 +16,24 @@ syntax = "proto3"; package controlplane.v1; -option go_package = "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1;v1"; import "controlplane/v1/response_messages.proto"; +option go_package = "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1;v1"; + service ContextService { // Get information about the current logged in context - rpc Current (ContextServiceCurrentRequest) returns (ContextServiceCurrentResponse); + rpc Current(ContextServiceCurrentRequest) returns (ContextServiceCurrentResponse); } message ContextServiceCurrentRequest {} message ContextServiceCurrentResponse { Result result = 1; - + message Result { User current_user = 1; - OrgItem current_org = 2; + OrgMembershipItem current_membership = 2; CASBackendItem current_cas_backend = 3; } } diff --git a/app/controlplane/api/controlplane/v1/context_grpc.pb.go b/app/controlplane/api/controlplane/v1/context_grpc.pb.go index d94f33f53..26784d7c5 100644 --- a/app/controlplane/api/controlplane/v1/context_grpc.pb.go +++ b/app/controlplane/api/controlplane/v1/context_grpc.pb.go @@ -1,5 +1,5 @@ // -// Copyright 2023 The Chainloop Authors. +// Copyright 2024 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/app/controlplane/api/controlplane/v1/organization.pb.go b/app/controlplane/api/controlplane/v1/organization.pb.go index 0ab009df7..44253a985 100644 --- a/app/controlplane/api/controlplane/v1/organization.pb.go +++ b/app/controlplane/api/controlplane/v1/organization.pb.go @@ -1,5 +1,5 @@ // -// Copyright 2023 The Chainloop Authors. +// Copyright 2024 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/app/controlplane/api/controlplane/v1/organization.proto b/app/controlplane/api/controlplane/v1/organization.proto index 4380bcf9f..c3ac80049 100644 --- a/app/controlplane/api/controlplane/v1/organization.proto +++ b/app/controlplane/api/controlplane/v1/organization.proto @@ -1,5 +1,5 @@ // -// Copyright 2023 The Chainloop Authors. +// Copyright 2024 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,20 +16,21 @@ syntax = "proto3"; package controlplane.v1; -option go_package = "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1;v1"; import "controlplane/v1/response_messages.proto"; import "validate/validate.proto"; +option go_package = "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1;v1"; + service OrganizationService { // Mermbership management // List the organizations this user has access to - rpc ListMemberships (OrganizationServiceListMembershipsRequest) returns (OrganizationServiceListMembershipsResponse); - rpc DeleteMembership (DeleteMembershipRequest) returns (DeleteMembershipResponse); - rpc SetCurrentMembership (SetCurrentMembershipRequest) returns (SetCurrentMembershipResponse); + rpc ListMemberships(OrganizationServiceListMembershipsRequest) returns (OrganizationServiceListMembershipsResponse); + rpc DeleteMembership(DeleteMembershipRequest) returns (DeleteMembershipResponse); + rpc SetCurrentMembership(SetCurrentMembershipRequest) returns (SetCurrentMembershipResponse); // Organization management - rpc Create (OrganizationServiceCreateRequest) returns (OrganizationServiceCreateResponse); - rpc Update (OrganizationServiceUpdateRequest) returns (OrganizationServiceUpdateResponse); + rpc Create(OrganizationServiceCreateRequest) returns (OrganizationServiceCreateResponse); + rpc Update(OrganizationServiceUpdateRequest) returns (OrganizationServiceUpdateResponse); } message OrganizationServiceListMembershipsRequest {} diff --git a/app/controlplane/api/controlplane/v1/organization_grpc.pb.go b/app/controlplane/api/controlplane/v1/organization_grpc.pb.go index f3d0c9c39..c0493ad38 100644 --- a/app/controlplane/api/controlplane/v1/organization_grpc.pb.go +++ b/app/controlplane/api/controlplane/v1/organization_grpc.pb.go @@ -1,5 +1,5 @@ // -// Copyright 2023 The Chainloop Authors. +// Copyright 2024 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/app/controlplane/api/controlplane/v1/response_messages.pb.go b/app/controlplane/api/controlplane/v1/response_messages.pb.go index f593acf0d..792a82e3b 100644 --- a/app/controlplane/api/controlplane/v1/response_messages.pb.go +++ b/app/controlplane/api/controlplane/v1/response_messages.pb.go @@ -1,5 +1,5 @@ // -// Copyright 2023 The Chainloop Authors. +// Copyright 2024 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -96,6 +96,58 @@ func (RunStatus) EnumDescriptor() ([]byte, []int) { return file_controlplane_v1_response_messages_proto_rawDescGZIP(), []int{0} } +type MembershipRole int32 + +const ( + MembershipRole_MEMBERSHIP_ROLE_UNSPECIFIED MembershipRole = 0 + MembershipRole_MEMBERSHIP_ROLE_ORG_VIEWER MembershipRole = 1 + MembershipRole_MEMBERSHIP_ROLE_ORG_ADMIN MembershipRole = 2 + MembershipRole_MEMBERSHIP_ROLE_ORG_OWNER MembershipRole = 3 +) + +// Enum value maps for MembershipRole. +var ( + MembershipRole_name = map[int32]string{ + 0: "MEMBERSHIP_ROLE_UNSPECIFIED", + 1: "MEMBERSHIP_ROLE_ORG_VIEWER", + 2: "MEMBERSHIP_ROLE_ORG_ADMIN", + 3: "MEMBERSHIP_ROLE_ORG_OWNER", + } + MembershipRole_value = map[string]int32{ + "MEMBERSHIP_ROLE_UNSPECIFIED": 0, + "MEMBERSHIP_ROLE_ORG_VIEWER": 1, + "MEMBERSHIP_ROLE_ORG_ADMIN": 2, + "MEMBERSHIP_ROLE_ORG_OWNER": 3, + } +) + +func (x MembershipRole) Enum() *MembershipRole { + p := new(MembershipRole) + *p = x + return p +} + +func (x MembershipRole) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (MembershipRole) Descriptor() protoreflect.EnumDescriptor { + return file_controlplane_v1_response_messages_proto_enumTypes[1].Descriptor() +} + +func (MembershipRole) Type() protoreflect.EnumType { + return &file_controlplane_v1_response_messages_proto_enumTypes[1] +} + +func (x MembershipRole) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use MembershipRole.Descriptor instead. +func (MembershipRole) EnumDescriptor() ([]byte, []int) { + return file_controlplane_v1_response_messages_proto_rawDescGZIP(), []int{1} +} + type AllowListError int32 const ( @@ -126,11 +178,11 @@ func (x AllowListError) String() string { } func (AllowListError) Descriptor() protoreflect.EnumDescriptor { - return file_controlplane_v1_response_messages_proto_enumTypes[1].Descriptor() + return file_controlplane_v1_response_messages_proto_enumTypes[2].Descriptor() } func (AllowListError) Type() protoreflect.EnumType { - return &file_controlplane_v1_response_messages_proto_enumTypes[1] + return &file_controlplane_v1_response_messages_proto_enumTypes[2] } func (x AllowListError) Number() protoreflect.EnumNumber { @@ -139,7 +191,7 @@ func (x AllowListError) Number() protoreflect.EnumNumber { // Deprecated: Use AllowListError.Descriptor instead. func (AllowListError) EnumDescriptor() ([]byte, []int) { - return file_controlplane_v1_response_messages_proto_rawDescGZIP(), []int{1} + return file_controlplane_v1_response_messages_proto_rawDescGZIP(), []int{2} } type CASBackendItem_ValidationStatus int32 @@ -175,11 +227,11 @@ func (x CASBackendItem_ValidationStatus) String() string { } func (CASBackendItem_ValidationStatus) Descriptor() protoreflect.EnumDescriptor { - return file_controlplane_v1_response_messages_proto_enumTypes[2].Descriptor() + return file_controlplane_v1_response_messages_proto_enumTypes[3].Descriptor() } func (CASBackendItem_ValidationStatus) Type() protoreflect.EnumType { - return &file_controlplane_v1_response_messages_proto_enumTypes[2] + return &file_controlplane_v1_response_messages_proto_enumTypes[3] } func (x CASBackendItem_ValidationStatus) Number() protoreflect.EnumNumber { @@ -791,6 +843,7 @@ type OrgMembershipItem struct { Current bool `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` CreatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + Role MembershipRole `protobuf:"varint,6,opt,name=role,proto3,enum=controlplane.v1.MembershipRole" json:"role,omitempty"` } func (x *OrgMembershipItem) Reset() { @@ -860,6 +913,13 @@ func (x *OrgMembershipItem) GetUpdatedAt() *timestamppb.Timestamp { return nil } +func (x *OrgMembershipItem) GetRole() MembershipRole { + if x != nil { + return x.Role + } + return MembershipRole_MEMBERSHIP_ROLE_UNSPECIFIED +} + type OrgItem struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1418,7 +1478,7 @@ var file_controlplane_v1_response_messages_proto_rawDesc = []byte{ 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0xdf, 0x01, 0x0a, 0x11, 0x4f, 0x72, 0x67, 0x4d, 0x65, 0x6d, + 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x94, 0x02, 0x0a, 0x11, 0x4f, 0x72, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2a, 0x0a, 0x03, 0x6f, 0x72, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, @@ -1432,74 +1492,86 @@ var file_controlplane_v1_response_messages_proto_rawDesc = []byte{ 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x68, 0x0a, 0x07, 0x4f, 0x72, 0x67, 0x49, 0x74, - 0x65, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, - 0x74, 0x22, 0xe1, 0x04, 0x0a, 0x0e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, - 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x3d, 0x0a, - 0x0c, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x0b, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x5d, 0x0a, 0x11, - 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, - 0x6b, 0x65, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, - 0x74, 0x12, 0x3e, 0x0a, 0x06, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x49, 0x74, - 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x06, 0x6c, 0x69, 0x6d, 0x69, 0x74, - 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x49, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x1a, 0x25, - 0x0a, 0x06, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x5f, - 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6d, 0x61, 0x78, - 0x42, 0x79, 0x74, 0x65, 0x73, 0x22, 0x6e, 0x0a, 0x10, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x21, 0x0a, 0x1d, 0x56, 0x41, 0x4c, - 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, - 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x18, 0x0a, 0x14, - 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, - 0x53, 0x5f, 0x4f, 0x4b, 0x10, 0x01, 0x12, 0x1d, 0x0a, 0x19, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, - 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, 0x4e, 0x56, 0x41, - 0x4c, 0x49, 0x44, 0x10, 0x02, 0x2a, 0xa6, 0x01, 0x0a, 0x09, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x16, 0x52, 0x55, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, - 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, - 0x1a, 0x0a, 0x16, 0x52, 0x55, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, 0x4e, - 0x49, 0x54, 0x49, 0x41, 0x4c, 0x49, 0x5a, 0x45, 0x44, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x52, - 0x55, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x45, - 0x44, 0x45, 0x44, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x55, 0x4e, 0x5f, 0x53, 0x54, 0x41, - 0x54, 0x55, 0x53, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x03, 0x12, 0x16, 0x0a, 0x12, - 0x52, 0x55, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x45, 0x58, 0x50, 0x49, 0x52, - 0x45, 0x44, 0x10, 0x04, 0x12, 0x18, 0x0a, 0x14, 0x52, 0x55, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, - 0x55, 0x53, 0x5f, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x4c, 0x45, 0x44, 0x10, 0x05, 0x2a, 0x60, - 0x0a, 0x0e, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x72, 0x72, 0x6f, 0x72, - 0x12, 0x20, 0x0a, 0x1c, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x4c, 0x49, 0x53, 0x54, 0x5f, 0x45, - 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, - 0x10, 0x00, 0x12, 0x26, 0x0a, 0x1c, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x4c, 0x49, 0x53, 0x54, - 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x49, 0x4e, 0x5f, 0x4c, 0x49, - 0x53, 0x54, 0x10, 0x01, 0x1a, 0x04, 0xa8, 0x45, 0x93, 0x03, 0x1a, 0x04, 0xa0, 0x45, 0xf4, 0x03, - 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, - 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, - 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x33, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, + 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, + 0x69, 0x70, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x68, 0x0a, 0x07, + 0x4f, 0x72, 0x67, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x63, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0xe1, 0x04, 0x0a, 0x0e, 0x43, 0x41, 0x53, 0x42, 0x61, + 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, + 0x41, 0x74, 0x12, 0x3d, 0x0a, 0x0c, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, + 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, + 0x74, 0x12, 0x5d, 0x0a, 0x11, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, + 0x41, 0x53, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x2e, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x10, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, + 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x3e, 0x0a, 0x06, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x73, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x41, 0x53, 0x42, 0x61, 0x63, 0x6b, + 0x65, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x06, + 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x69, 0x6e, 0x6c, + 0x69, 0x6e, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x49, 0x6e, 0x6c, + 0x69, 0x6e, 0x65, 0x1a, 0x25, 0x0a, 0x06, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x1b, 0x0a, + 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x08, 0x6d, 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x22, 0x6e, 0x0a, 0x10, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x21, + 0x0a, 0x1d, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, + 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, + 0x00, 0x12, 0x18, 0x0a, 0x14, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x4b, 0x10, 0x01, 0x12, 0x1d, 0x0a, 0x19, 0x56, + 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, + 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x02, 0x2a, 0xa6, 0x01, 0x0a, 0x09, 0x52, + 0x75, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x16, 0x52, 0x55, 0x4e, 0x5f, + 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, + 0x45, 0x44, 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, 0x52, 0x55, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, + 0x55, 0x53, 0x5f, 0x49, 0x4e, 0x49, 0x54, 0x49, 0x41, 0x4c, 0x49, 0x5a, 0x45, 0x44, 0x10, 0x01, + 0x12, 0x18, 0x0a, 0x14, 0x52, 0x55, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x53, + 0x55, 0x43, 0x43, 0x45, 0x45, 0x44, 0x45, 0x44, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x55, + 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, + 0x03, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x55, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, + 0x45, 0x58, 0x50, 0x49, 0x52, 0x45, 0x44, 0x10, 0x04, 0x12, 0x18, 0x0a, 0x14, 0x52, 0x55, 0x4e, + 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x4c, 0x45, + 0x44, 0x10, 0x05, 0x2a, 0x8f, 0x01, 0x0a, 0x0e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, + 0x69, 0x70, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x1f, 0x0a, 0x1b, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, + 0x53, 0x48, 0x49, 0x50, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x1a, 0x4d, 0x45, 0x4d, 0x42, 0x45, + 0x52, 0x53, 0x48, 0x49, 0x50, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x4f, 0x52, 0x47, 0x5f, 0x56, + 0x49, 0x45, 0x57, 0x45, 0x52, 0x10, 0x01, 0x12, 0x1d, 0x0a, 0x19, 0x4d, 0x45, 0x4d, 0x42, 0x45, + 0x52, 0x53, 0x48, 0x49, 0x50, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x4f, 0x52, 0x47, 0x5f, 0x41, + 0x44, 0x4d, 0x49, 0x4e, 0x10, 0x02, 0x12, 0x1d, 0x0a, 0x19, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, + 0x53, 0x48, 0x49, 0x50, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x4f, 0x52, 0x47, 0x5f, 0x4f, 0x57, + 0x4e, 0x45, 0x52, 0x10, 0x03, 0x2a, 0x60, 0x0a, 0x0e, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x4c, 0x69, + 0x73, 0x74, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x20, 0x0a, 0x1c, 0x41, 0x4c, 0x4c, 0x4f, 0x57, + 0x5f, 0x4c, 0x49, 0x53, 0x54, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x26, 0x0a, 0x1c, 0x41, 0x4c, 0x4c, + 0x4f, 0x57, 0x5f, 0x4c, 0x49, 0x53, 0x54, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4e, 0x4f, + 0x54, 0x5f, 0x49, 0x4e, 0x5f, 0x4c, 0x49, 0x53, 0x54, 0x10, 0x01, 0x1a, 0x04, 0xa8, 0x45, 0x93, + 0x03, 0x1a, 0x04, 0xa0, 0x45, 0xf4, 0x03, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, + 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, + 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, + 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1514,60 +1586,62 @@ func file_controlplane_v1_response_messages_proto_rawDescGZIP() []byte { return file_controlplane_v1_response_messages_proto_rawDescData } -var file_controlplane_v1_response_messages_proto_enumTypes = make([]protoimpl.EnumInfo, 3) +var file_controlplane_v1_response_messages_proto_enumTypes = make([]protoimpl.EnumInfo, 4) var file_controlplane_v1_response_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_controlplane_v1_response_messages_proto_goTypes = []interface{}{ (RunStatus)(0), // 0: controlplane.v1.RunStatus - (AllowListError)(0), // 1: controlplane.v1.AllowListError - (CASBackendItem_ValidationStatus)(0), // 2: controlplane.v1.CASBackendItem.ValidationStatus - (*WorkflowItem)(nil), // 3: controlplane.v1.WorkflowItem - (*WorkflowRunItem)(nil), // 4: controlplane.v1.WorkflowRunItem - (*AttestationItem)(nil), // 5: controlplane.v1.AttestationItem - (*WorkflowContractItem)(nil), // 6: controlplane.v1.WorkflowContractItem - (*WorkflowContractVersionItem)(nil), // 7: controlplane.v1.WorkflowContractVersionItem - (*User)(nil), // 8: controlplane.v1.User - (*OrgMembershipItem)(nil), // 9: controlplane.v1.OrgMembershipItem - (*OrgItem)(nil), // 10: controlplane.v1.OrgItem - (*CASBackendItem)(nil), // 11: controlplane.v1.CASBackendItem - nil, // 12: controlplane.v1.AttestationItem.AnnotationsEntry - (*AttestationItem_EnvVariable)(nil), // 13: controlplane.v1.AttestationItem.EnvVariable - (*AttestationItem_Material)(nil), // 14: controlplane.v1.AttestationItem.Material - nil, // 15: controlplane.v1.AttestationItem.Material.AnnotationsEntry - (*CASBackendItem_Limits)(nil), // 16: controlplane.v1.CASBackendItem.Limits - (*timestamppb.Timestamp)(nil), // 17: google.protobuf.Timestamp - (v1.CraftingSchema_Runner_RunnerType)(0), // 18: workflowcontract.v1.CraftingSchema.Runner.RunnerType - (*v1.CraftingSchema)(nil), // 19: workflowcontract.v1.CraftingSchema + (MembershipRole)(0), // 1: controlplane.v1.MembershipRole + (AllowListError)(0), // 2: controlplane.v1.AllowListError + (CASBackendItem_ValidationStatus)(0), // 3: controlplane.v1.CASBackendItem.ValidationStatus + (*WorkflowItem)(nil), // 4: controlplane.v1.WorkflowItem + (*WorkflowRunItem)(nil), // 5: controlplane.v1.WorkflowRunItem + (*AttestationItem)(nil), // 6: controlplane.v1.AttestationItem + (*WorkflowContractItem)(nil), // 7: controlplane.v1.WorkflowContractItem + (*WorkflowContractVersionItem)(nil), // 8: controlplane.v1.WorkflowContractVersionItem + (*User)(nil), // 9: controlplane.v1.User + (*OrgMembershipItem)(nil), // 10: controlplane.v1.OrgMembershipItem + (*OrgItem)(nil), // 11: controlplane.v1.OrgItem + (*CASBackendItem)(nil), // 12: controlplane.v1.CASBackendItem + nil, // 13: controlplane.v1.AttestationItem.AnnotationsEntry + (*AttestationItem_EnvVariable)(nil), // 14: controlplane.v1.AttestationItem.EnvVariable + (*AttestationItem_Material)(nil), // 15: controlplane.v1.AttestationItem.Material + nil, // 16: controlplane.v1.AttestationItem.Material.AnnotationsEntry + (*CASBackendItem_Limits)(nil), // 17: controlplane.v1.CASBackendItem.Limits + (*timestamppb.Timestamp)(nil), // 18: google.protobuf.Timestamp + (v1.CraftingSchema_Runner_RunnerType)(0), // 19: workflowcontract.v1.CraftingSchema.Runner.RunnerType + (*v1.CraftingSchema)(nil), // 20: workflowcontract.v1.CraftingSchema } var file_controlplane_v1_response_messages_proto_depIdxs = []int32{ - 17, // 0: controlplane.v1.WorkflowItem.created_at:type_name -> google.protobuf.Timestamp - 4, // 1: controlplane.v1.WorkflowItem.last_run:type_name -> controlplane.v1.WorkflowRunItem - 17, // 2: controlplane.v1.WorkflowRunItem.created_at:type_name -> google.protobuf.Timestamp - 17, // 3: controlplane.v1.WorkflowRunItem.finished_at:type_name -> google.protobuf.Timestamp + 18, // 0: controlplane.v1.WorkflowItem.created_at:type_name -> google.protobuf.Timestamp + 5, // 1: controlplane.v1.WorkflowItem.last_run:type_name -> controlplane.v1.WorkflowRunItem + 18, // 2: controlplane.v1.WorkflowRunItem.created_at:type_name -> google.protobuf.Timestamp + 18, // 3: controlplane.v1.WorkflowRunItem.finished_at:type_name -> google.protobuf.Timestamp 0, // 4: controlplane.v1.WorkflowRunItem.status:type_name -> controlplane.v1.RunStatus - 3, // 5: controlplane.v1.WorkflowRunItem.workflow:type_name -> controlplane.v1.WorkflowItem - 18, // 6: controlplane.v1.WorkflowRunItem.runner_type:type_name -> workflowcontract.v1.CraftingSchema.Runner.RunnerType - 7, // 7: controlplane.v1.WorkflowRunItem.contract_version:type_name -> controlplane.v1.WorkflowContractVersionItem - 13, // 8: controlplane.v1.AttestationItem.env_vars:type_name -> controlplane.v1.AttestationItem.EnvVariable - 14, // 9: controlplane.v1.AttestationItem.materials:type_name -> controlplane.v1.AttestationItem.Material - 12, // 10: controlplane.v1.AttestationItem.annotations:type_name -> controlplane.v1.AttestationItem.AnnotationsEntry - 17, // 11: controlplane.v1.WorkflowContractItem.created_at:type_name -> google.protobuf.Timestamp - 17, // 12: controlplane.v1.WorkflowContractVersionItem.created_at:type_name -> google.protobuf.Timestamp - 19, // 13: controlplane.v1.WorkflowContractVersionItem.v1:type_name -> workflowcontract.v1.CraftingSchema - 17, // 14: controlplane.v1.User.created_at:type_name -> google.protobuf.Timestamp - 10, // 15: controlplane.v1.OrgMembershipItem.org:type_name -> controlplane.v1.OrgItem - 17, // 16: controlplane.v1.OrgMembershipItem.created_at:type_name -> google.protobuf.Timestamp - 17, // 17: controlplane.v1.OrgMembershipItem.updated_at:type_name -> google.protobuf.Timestamp - 17, // 18: controlplane.v1.OrgItem.created_at:type_name -> google.protobuf.Timestamp - 17, // 19: controlplane.v1.CASBackendItem.created_at:type_name -> google.protobuf.Timestamp - 17, // 20: controlplane.v1.CASBackendItem.validated_at:type_name -> google.protobuf.Timestamp - 2, // 21: controlplane.v1.CASBackendItem.validation_status:type_name -> controlplane.v1.CASBackendItem.ValidationStatus - 16, // 22: controlplane.v1.CASBackendItem.limits:type_name -> controlplane.v1.CASBackendItem.Limits - 15, // 23: controlplane.v1.AttestationItem.Material.annotations:type_name -> controlplane.v1.AttestationItem.Material.AnnotationsEntry - 24, // [24:24] is the sub-list for method output_type - 24, // [24:24] is the sub-list for method input_type - 24, // [24:24] is the sub-list for extension type_name - 24, // [24:24] is the sub-list for extension extendee - 0, // [0:24] is the sub-list for field type_name + 4, // 5: controlplane.v1.WorkflowRunItem.workflow:type_name -> controlplane.v1.WorkflowItem + 19, // 6: controlplane.v1.WorkflowRunItem.runner_type:type_name -> workflowcontract.v1.CraftingSchema.Runner.RunnerType + 8, // 7: controlplane.v1.WorkflowRunItem.contract_version:type_name -> controlplane.v1.WorkflowContractVersionItem + 14, // 8: controlplane.v1.AttestationItem.env_vars:type_name -> controlplane.v1.AttestationItem.EnvVariable + 15, // 9: controlplane.v1.AttestationItem.materials:type_name -> controlplane.v1.AttestationItem.Material + 13, // 10: controlplane.v1.AttestationItem.annotations:type_name -> controlplane.v1.AttestationItem.AnnotationsEntry + 18, // 11: controlplane.v1.WorkflowContractItem.created_at:type_name -> google.protobuf.Timestamp + 18, // 12: controlplane.v1.WorkflowContractVersionItem.created_at:type_name -> google.protobuf.Timestamp + 20, // 13: controlplane.v1.WorkflowContractVersionItem.v1:type_name -> workflowcontract.v1.CraftingSchema + 18, // 14: controlplane.v1.User.created_at:type_name -> google.protobuf.Timestamp + 11, // 15: controlplane.v1.OrgMembershipItem.org:type_name -> controlplane.v1.OrgItem + 18, // 16: controlplane.v1.OrgMembershipItem.created_at:type_name -> google.protobuf.Timestamp + 18, // 17: controlplane.v1.OrgMembershipItem.updated_at:type_name -> google.protobuf.Timestamp + 1, // 18: controlplane.v1.OrgMembershipItem.role:type_name -> controlplane.v1.MembershipRole + 18, // 19: controlplane.v1.OrgItem.created_at:type_name -> google.protobuf.Timestamp + 18, // 20: controlplane.v1.CASBackendItem.created_at:type_name -> google.protobuf.Timestamp + 18, // 21: controlplane.v1.CASBackendItem.validated_at:type_name -> google.protobuf.Timestamp + 3, // 22: controlplane.v1.CASBackendItem.validation_status:type_name -> controlplane.v1.CASBackendItem.ValidationStatus + 17, // 23: controlplane.v1.CASBackendItem.limits:type_name -> controlplane.v1.CASBackendItem.Limits + 16, // 24: controlplane.v1.AttestationItem.Material.annotations:type_name -> controlplane.v1.AttestationItem.Material.AnnotationsEntry + 25, // [25:25] is the sub-list for method output_type + 25, // [25:25] is the sub-list for method input_type + 25, // [25:25] is the sub-list for extension type_name + 25, // [25:25] is the sub-list for extension extendee + 0, // [0:25] is the sub-list for field type_name } func init() { file_controlplane_v1_response_messages_proto_init() } @@ -1729,7 +1803,7 @@ func file_controlplane_v1_response_messages_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_controlplane_v1_response_messages_proto_rawDesc, - NumEnums: 3, + NumEnums: 4, NumMessages: 14, NumExtensions: 0, NumServices: 0, diff --git a/app/controlplane/api/controlplane/v1/response_messages.pb.validate.go b/app/controlplane/api/controlplane/v1/response_messages.pb.validate.go index 84fa8f526..a3ce92528 100644 --- a/app/controlplane/api/controlplane/v1/response_messages.pb.validate.go +++ b/app/controlplane/api/controlplane/v1/response_messages.pb.validate.go @@ -1183,6 +1183,8 @@ func (m *OrgMembershipItem) validate(all bool) error { } } + // no validation rules for Role + if len(errors) > 0 { return OrgMembershipItemMultiError(errors) } diff --git a/app/controlplane/api/controlplane/v1/response_messages.proto b/app/controlplane/api/controlplane/v1/response_messages.proto index 24f985d5c..231e55463 100644 --- a/app/controlplane/api/controlplane/v1/response_messages.proto +++ b/app/controlplane/api/controlplane/v1/response_messages.proto @@ -1,5 +1,5 @@ // -// Copyright 2023 The Chainloop Authors. +// Copyright 2024 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -135,6 +135,14 @@ message OrgMembershipItem { bool current = 3; google.protobuf.Timestamp created_at = 4; google.protobuf.Timestamp updated_at = 5; + MembershipRole role = 6; +} + +enum MembershipRole { + MEMBERSHIP_ROLE_UNSPECIFIED = 0; + MEMBERSHIP_ROLE_ORG_VIEWER = 1; + MEMBERSHIP_ROLE_ORG_ADMIN = 2; + MEMBERSHIP_ROLE_ORG_OWNER = 3; } message OrgItem { diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/context.ts b/app/controlplane/api/gen/frontend/controlplane/v1/context.ts index a8439a938..fe0d86d6f 100644 --- a/app/controlplane/api/gen/frontend/controlplane/v1/context.ts +++ b/app/controlplane/api/gen/frontend/controlplane/v1/context.ts @@ -2,7 +2,7 @@ import { grpc } from "@improbable-eng/grpc-web"; import { BrowserHeaders } from "browser-headers"; import _m0 from "protobufjs/minimal"; -import { CASBackendItem, OrgItem, User } from "./response_messages"; +import { CASBackendItem, OrgMembershipItem, User } from "./response_messages"; export const protobufPackage = "controlplane.v1"; @@ -15,7 +15,7 @@ export interface ContextServiceCurrentResponse { export interface ContextServiceCurrentResponse_Result { currentUser?: User; - currentOrg?: OrgItem; + currentMembership?: OrgMembershipItem; currentCasBackend?: CASBackendItem; } @@ -125,7 +125,7 @@ export const ContextServiceCurrentResponse = { }; function createBaseContextServiceCurrentResponse_Result(): ContextServiceCurrentResponse_Result { - return { currentUser: undefined, currentOrg: undefined, currentCasBackend: undefined }; + return { currentUser: undefined, currentMembership: undefined, currentCasBackend: undefined }; } export const ContextServiceCurrentResponse_Result = { @@ -133,8 +133,8 @@ export const ContextServiceCurrentResponse_Result = { if (message.currentUser !== undefined) { User.encode(message.currentUser, writer.uint32(10).fork()).ldelim(); } - if (message.currentOrg !== undefined) { - OrgItem.encode(message.currentOrg, writer.uint32(18).fork()).ldelim(); + if (message.currentMembership !== undefined) { + OrgMembershipItem.encode(message.currentMembership, writer.uint32(18).fork()).ldelim(); } if (message.currentCasBackend !== undefined) { CASBackendItem.encode(message.currentCasBackend, writer.uint32(26).fork()).ldelim(); @@ -161,7 +161,7 @@ export const ContextServiceCurrentResponse_Result = { break; } - message.currentOrg = OrgItem.decode(reader, reader.uint32()); + message.currentMembership = OrgMembershipItem.decode(reader, reader.uint32()); continue; case 3: if (tag !== 26) { @@ -182,7 +182,9 @@ export const ContextServiceCurrentResponse_Result = { fromJSON(object: any): ContextServiceCurrentResponse_Result { return { currentUser: isSet(object.currentUser) ? User.fromJSON(object.currentUser) : undefined, - currentOrg: isSet(object.currentOrg) ? OrgItem.fromJSON(object.currentOrg) : undefined, + currentMembership: isSet(object.currentMembership) + ? OrgMembershipItem.fromJSON(object.currentMembership) + : undefined, currentCasBackend: isSet(object.currentCasBackend) ? CASBackendItem.fromJSON(object.currentCasBackend) : undefined, @@ -193,8 +195,9 @@ export const ContextServiceCurrentResponse_Result = { const obj: any = {}; message.currentUser !== undefined && (obj.currentUser = message.currentUser ? User.toJSON(message.currentUser) : undefined); - message.currentOrg !== undefined && - (obj.currentOrg = message.currentOrg ? OrgItem.toJSON(message.currentOrg) : undefined); + message.currentMembership !== undefined && (obj.currentMembership = message.currentMembership + ? OrgMembershipItem.toJSON(message.currentMembership) + : undefined); message.currentCasBackend !== undefined && (obj.currentCasBackend = message.currentCasBackend ? CASBackendItem.toJSON(message.currentCasBackend) @@ -215,8 +218,8 @@ export const ContextServiceCurrentResponse_Result = { message.currentUser = (object.currentUser !== undefined && object.currentUser !== null) ? User.fromPartial(object.currentUser) : undefined; - message.currentOrg = (object.currentOrg !== undefined && object.currentOrg !== null) - ? OrgItem.fromPartial(object.currentOrg) + message.currentMembership = (object.currentMembership !== undefined && object.currentMembership !== null) + ? OrgMembershipItem.fromPartial(object.currentMembership) : undefined; message.currentCasBackend = (object.currentCasBackend !== undefined && object.currentCasBackend !== null) ? CASBackendItem.fromPartial(object.currentCasBackend) diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts b/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts index eff8876a0..77f549b12 100644 --- a/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts +++ b/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts @@ -68,6 +68,51 @@ export function runStatusToJSON(object: RunStatus): string { } } +export enum MembershipRole { + MEMBERSHIP_ROLE_UNSPECIFIED = 0, + MEMBERSHIP_ROLE_ORG_VIEWER = 1, + MEMBERSHIP_ROLE_ORG_ADMIN = 2, + MEMBERSHIP_ROLE_ORG_OWNER = 3, + UNRECOGNIZED = -1, +} + +export function membershipRoleFromJSON(object: any): MembershipRole { + switch (object) { + case 0: + case "MEMBERSHIP_ROLE_UNSPECIFIED": + return MembershipRole.MEMBERSHIP_ROLE_UNSPECIFIED; + case 1: + case "MEMBERSHIP_ROLE_ORG_VIEWER": + return MembershipRole.MEMBERSHIP_ROLE_ORG_VIEWER; + case 2: + case "MEMBERSHIP_ROLE_ORG_ADMIN": + return MembershipRole.MEMBERSHIP_ROLE_ORG_ADMIN; + case 3: + case "MEMBERSHIP_ROLE_ORG_OWNER": + return MembershipRole.MEMBERSHIP_ROLE_ORG_OWNER; + case -1: + case "UNRECOGNIZED": + default: + return MembershipRole.UNRECOGNIZED; + } +} + +export function membershipRoleToJSON(object: MembershipRole): string { + switch (object) { + case MembershipRole.MEMBERSHIP_ROLE_UNSPECIFIED: + return "MEMBERSHIP_ROLE_UNSPECIFIED"; + case MembershipRole.MEMBERSHIP_ROLE_ORG_VIEWER: + return "MEMBERSHIP_ROLE_ORG_VIEWER"; + case MembershipRole.MEMBERSHIP_ROLE_ORG_ADMIN: + return "MEMBERSHIP_ROLE_ORG_ADMIN"; + case MembershipRole.MEMBERSHIP_ROLE_ORG_OWNER: + return "MEMBERSHIP_ROLE_ORG_OWNER"; + case MembershipRole.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + export enum AllowListError { ALLOW_LIST_ERROR_UNSPECIFIED = 0, ALLOW_LIST_ERROR_NOT_IN_LIST = 1, @@ -215,6 +260,7 @@ export interface OrgMembershipItem { current: boolean; createdAt?: Date; updatedAt?: Date; + role: MembershipRole; } export interface OrgItem { @@ -1550,7 +1596,7 @@ export const User = { }; function createBaseOrgMembershipItem(): OrgMembershipItem { - return { id: "", org: undefined, current: false, createdAt: undefined, updatedAt: undefined }; + return { id: "", org: undefined, current: false, createdAt: undefined, updatedAt: undefined, role: 0 }; } export const OrgMembershipItem = { @@ -1570,6 +1616,9 @@ export const OrgMembershipItem = { if (message.updatedAt !== undefined) { Timestamp.encode(toTimestamp(message.updatedAt), writer.uint32(42).fork()).ldelim(); } + if (message.role !== 0) { + writer.uint32(48).int32(message.role); + } return writer; }, @@ -1615,6 +1664,13 @@ export const OrgMembershipItem = { message.updatedAt = fromTimestamp(Timestamp.decode(reader, reader.uint32())); continue; + case 6: + if (tag !== 48) { + break; + } + + message.role = reader.int32() as any; + continue; } if ((tag & 7) === 4 || tag === 0) { break; @@ -1631,6 +1687,7 @@ export const OrgMembershipItem = { current: isSet(object.current) ? Boolean(object.current) : false, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, updatedAt: isSet(object.updatedAt) ? fromJsonTimestamp(object.updatedAt) : undefined, + role: isSet(object.role) ? membershipRoleFromJSON(object.role) : 0, }; }, @@ -1641,6 +1698,7 @@ export const OrgMembershipItem = { message.current !== undefined && (obj.current = message.current); message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString()); message.updatedAt !== undefined && (obj.updatedAt = message.updatedAt.toISOString()); + message.role !== undefined && (obj.role = membershipRoleToJSON(message.role)); return obj; }, @@ -1655,6 +1713,7 @@ export const OrgMembershipItem = { message.current = object.current ?? false; message.createdAt = object.createdAt ?? undefined; message.updatedAt = object.updatedAt ?? undefined; + message.role = object.role ?? 0; return message; }, }; diff --git a/app/controlplane/cmd/wire_gen.go b/app/controlplane/cmd/wire_gen.go index f0ddccd7f..6c4ff21a6 100644 --- a/app/controlplane/cmd/wire_gen.go +++ b/app/controlplane/cmd/wire_gen.go @@ -136,7 +136,7 @@ func wireApp(bootstrap *conf.Bootstrap, readerWriter credentials.ReaderWriter, l } attestationService := service.NewAttestationService(newAttestationServiceOpts) workflowContractService := service.NewWorkflowSchemaService(workflowContractUseCase, v2...) - contextService := service.NewContextService(casBackendUseCase, v2...) + contextService := service.NewContextService(casBackendUseCase, userUseCase, v2...) casCredentialsService := service.NewCASCredentialsService(casCredentialsUseCase, casMappingUseCase, casBackendUseCase, enforcer, v2...) orgMetricsRepo := data.NewOrgMetricsRepo(dataData, logger) orgMetricsUseCase, err := biz.NewOrgMetricsUseCase(orgMetricsRepo, logger) diff --git a/app/controlplane/internal/authz/authz.go b/app/controlplane/internal/authz/authz.go index f094c4ce5..11ace0509 100644 --- a/app/controlplane/internal/authz/authz.go +++ b/app/controlplane/internal/authz/authz.go @@ -180,7 +180,7 @@ var ServerOperationsMap = map[string][]*Policy{ "/controlplane.v1.WorkflowContractService/Describe": {PolicyWorkflowContractRead}, "/controlplane.v1.WorkflowContractService/Update": {PolicyWorkflowContractUpdate}, // Get current information about an organization - "/controlplane.v1.ContextService/Current": {PolicyOrganizationRead, PolicyCASBackendList}, + "/controlplane.v1.ContextService/Current": {PolicyOrganizationRead}, // Listing, create or selecting an organization does not have any required permissions, // since all the permissions here are in the context of an organization "/controlplane.v1.OrganizationService/Create": {}, diff --git a/app/controlplane/internal/biz/apitoken.go b/app/controlplane/internal/biz/apitoken.go index 35868eb2a..bcb37c4e5 100644 --- a/app/controlplane/internal/biz/apitoken.go +++ b/app/controlplane/internal/biz/apitoken.go @@ -74,6 +74,7 @@ func NewAPITokenUseCase(apiTokenRepo APITokenRepo, conf *conf.Auth, authzE *auth authz.PolicyWorkflowContractList, authz.PolicyWorkflowContractRead, authz.PolicyWorkflowContractUpdate, // to download artifacts and list referrers authz.PolicyArtifactDownload, authz.PolicyReferrerRead, + authz.PolicyOrganizationRead, }, } diff --git a/app/controlplane/internal/service/context.go b/app/controlplane/internal/service/context.go index 922904b00..8c2bc317f 100644 --- a/app/controlplane/internal/service/context.go +++ b/app/controlplane/internal/service/context.go @@ -29,13 +29,15 @@ type ContextService struct { *service pb.UnimplementedContextServiceServer - uc *biz.CASBackendUseCase + uc *biz.CASBackendUseCase + userUC *biz.UserUseCase } -func NewContextService(repoUC *biz.CASBackendUseCase, opts ...NewOpt) *ContextService { +func NewContextService(repoUC *biz.CASBackendUseCase, uUC *biz.UserUseCase, opts ...NewOpt) *ContextService { return &ContextService{ service: newService(opts...), uc: repoUC, + userUC: uUC, } } @@ -54,12 +56,9 @@ func (s *ContextService) Current(ctx context.Context, _ *pb.ContextServiceCurren return nil, errors.NotFound("not found", "logged in user") } - res := &pb.ContextServiceCurrentResponse_Result{ - CurrentOrg: bizOrgToPb(&biz.Organization{ - ID: currentOrg.ID, Name: currentOrg.Name, CreatedAt: currentOrg.CreatedAt, - }), - } + res := &pb.ContextServiceCurrentResponse_Result{} + // Load user/API token info if currentAPIToken != nil { res.CurrentUser = &pb.User{ Id: currentAPIToken.ID, Email: "API-token@chainloop", CreatedAt: timestamppb.New(*currentAPIToken.CreatedAt), @@ -70,6 +69,7 @@ func (s *ContextService) Current(ctx context.Context, _ *pb.ContextServiceCurren } } + // Add cas backend backend, err := s.uc.FindDefaultBackend(ctx, currentOrg.ID) if err != nil && !biz.IsNotFound(err) { return nil, sl.LogAndMaskErr(err, s.log) @@ -79,9 +79,19 @@ func (s *ContextService) Current(ctx context.Context, _ *pb.ContextServiceCurren res.CurrentCasBackend = bizCASBackendToPb(backend) } - return &pb.ContextServiceCurrentResponse{ - Result: res, - }, nil + // Optionally add current membership + if currentUser != nil { + m, err := s.userUC.CurrentMembership(ctx, currentUser.ID) + if err != nil { + return nil, handleUseCaseErr("membership", err, s.log) + } + + if m != nil { + res.CurrentMembership = bizMembershipToPb(m) + } + } + + return &pb.ContextServiceCurrentResponse{Result: res}, nil } func bizOrgToPb(m *biz.Organization) *pb.OrgItem { diff --git a/app/controlplane/internal/service/organization.go b/app/controlplane/internal/service/organization.go index 8ce748f4f..277641665 100644 --- a/app/controlplane/internal/service/organization.go +++ b/app/controlplane/internal/service/organization.go @@ -134,9 +134,26 @@ func bizMembershipToPb(m *biz.Membership) *pb.OrgMembershipItem { item := &pb.OrgMembershipItem{ Id: m.ID.String(), Current: m.Current, CreatedAt: timestamppb.New(*m.CreatedAt), - UpdatedAt: timestamppb.New(*m.UpdatedAt), Org: bizOrgToPb(m.Org), + Role: bizRoleToPb(m.Role), + } + + if m.UpdatedAt != nil { + item.UpdatedAt = timestamppb.New(*m.UpdatedAt) } return item } + +func bizRoleToPb(r authz.Role) pb.MembershipRole { + switch r { + case authz.RoleOwner: + return pb.MembershipRole_MEMBERSHIP_ROLE_ORG_OWNER + case authz.RoleAdmin: + return pb.MembershipRole_MEMBERSHIP_ROLE_ORG_ADMIN + case authz.RoleViewer: + return pb.MembershipRole_MEMBERSHIP_ROLE_ORG_VIEWER + default: + return pb.MembershipRole_MEMBERSHIP_ROLE_UNSPECIFIED + } +}