diff --git a/app/controlplane/api/controlplane/v1/robot_accounts.pb.go b/app/controlplane/api/controlplane/v1/robot_accounts.pb.go deleted file mode 100644 index 8f65423c8..000000000 --- a/app/controlplane/api/controlplane/v1/robot_accounts.pb.go +++ /dev/null @@ -1,584 +0,0 @@ -// -// Copyright 2023 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. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.11 -// protoc (unknown) -// source: controlplane/v1/robot_accounts.proto - -package v1 - -import ( - _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type RobotAccountServiceCreateRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - WorkflowId string `protobuf:"bytes,2,opt,name=workflow_id,json=workflowId,proto3" json:"workflow_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RobotAccountServiceCreateRequest) Reset() { - *x = RobotAccountServiceCreateRequest{} - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RobotAccountServiceCreateRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RobotAccountServiceCreateRequest) ProtoMessage() {} - -func (x *RobotAccountServiceCreateRequest) ProtoReflect() protoreflect.Message { - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RobotAccountServiceCreateRequest.ProtoReflect.Descriptor instead. -func (*RobotAccountServiceCreateRequest) Descriptor() ([]byte, []int) { - return file_controlplane_v1_robot_accounts_proto_rawDescGZIP(), []int{0} -} - -func (x *RobotAccountServiceCreateRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *RobotAccountServiceCreateRequest) GetWorkflowId() string { - if x != nil { - return x.WorkflowId - } - return "" -} - -type RobotAccountServiceCreateResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Result *RobotAccountServiceCreateResponse_RobotAccountFull `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RobotAccountServiceCreateResponse) Reset() { - *x = RobotAccountServiceCreateResponse{} - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RobotAccountServiceCreateResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RobotAccountServiceCreateResponse) ProtoMessage() {} - -func (x *RobotAccountServiceCreateResponse) ProtoReflect() protoreflect.Message { - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RobotAccountServiceCreateResponse.ProtoReflect.Descriptor instead. -func (*RobotAccountServiceCreateResponse) Descriptor() ([]byte, []int) { - return file_controlplane_v1_robot_accounts_proto_rawDescGZIP(), []int{1} -} - -func (x *RobotAccountServiceCreateResponse) GetResult() *RobotAccountServiceCreateResponse_RobotAccountFull { - if x != nil { - return x.Result - } - return nil -} - -type RobotAccountServiceRevokeRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RobotAccountServiceRevokeRequest) Reset() { - *x = RobotAccountServiceRevokeRequest{} - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RobotAccountServiceRevokeRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RobotAccountServiceRevokeRequest) ProtoMessage() {} - -func (x *RobotAccountServiceRevokeRequest) ProtoReflect() protoreflect.Message { - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RobotAccountServiceRevokeRequest.ProtoReflect.Descriptor instead. -func (*RobotAccountServiceRevokeRequest) Descriptor() ([]byte, []int) { - return file_controlplane_v1_robot_accounts_proto_rawDescGZIP(), []int{2} -} - -func (x *RobotAccountServiceRevokeRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -type RobotAccountServiceRevokeResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RobotAccountServiceRevokeResponse) Reset() { - *x = RobotAccountServiceRevokeResponse{} - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RobotAccountServiceRevokeResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RobotAccountServiceRevokeResponse) ProtoMessage() {} - -func (x *RobotAccountServiceRevokeResponse) ProtoReflect() protoreflect.Message { - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[3] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RobotAccountServiceRevokeResponse.ProtoReflect.Descriptor instead. -func (*RobotAccountServiceRevokeResponse) Descriptor() ([]byte, []int) { - return file_controlplane_v1_robot_accounts_proto_rawDescGZIP(), []int{3} -} - -type RobotAccountServiceListRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - WorkflowId string `protobuf:"bytes,1,opt,name=workflow_id,json=workflowId,proto3" json:"workflow_id,omitempty"` - IncludeRevoked bool `protobuf:"varint,2,opt,name=include_revoked,json=includeRevoked,proto3" json:"include_revoked,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RobotAccountServiceListRequest) Reset() { - *x = RobotAccountServiceListRequest{} - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RobotAccountServiceListRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RobotAccountServiceListRequest) ProtoMessage() {} - -func (x *RobotAccountServiceListRequest) ProtoReflect() protoreflect.Message { - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[4] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RobotAccountServiceListRequest.ProtoReflect.Descriptor instead. -func (*RobotAccountServiceListRequest) Descriptor() ([]byte, []int) { - return file_controlplane_v1_robot_accounts_proto_rawDescGZIP(), []int{4} -} - -func (x *RobotAccountServiceListRequest) GetWorkflowId() string { - if x != nil { - return x.WorkflowId - } - return "" -} - -func (x *RobotAccountServiceListRequest) GetIncludeRevoked() bool { - if x != nil { - return x.IncludeRevoked - } - return false -} - -type RobotAccountServiceListResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Result []*RobotAccountServiceListResponse_RobotAccountItem `protobuf:"bytes,1,rep,name=result,proto3" json:"result,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RobotAccountServiceListResponse) Reset() { - *x = RobotAccountServiceListResponse{} - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RobotAccountServiceListResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RobotAccountServiceListResponse) ProtoMessage() {} - -func (x *RobotAccountServiceListResponse) ProtoReflect() protoreflect.Message { - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[5] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RobotAccountServiceListResponse.ProtoReflect.Descriptor instead. -func (*RobotAccountServiceListResponse) Descriptor() ([]byte, []int) { - return file_controlplane_v1_robot_accounts_proto_rawDescGZIP(), []int{5} -} - -func (x *RobotAccountServiceListResponse) GetResult() []*RobotAccountServiceListResponse_RobotAccountItem { - if x != nil { - return x.Result - } - return nil -} - -type RobotAccountServiceCreateResponse_RobotAccountFull struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - WorkflowId string `protobuf:"bytes,3,opt,name=workflow_id,json=workflowId,proto3" json:"workflow_id,omitempty"` - CreatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` - RevokedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=revoked_at,json=revokedAt,proto3" json:"revoked_at,omitempty"` - // The key is returned only during creation - Key string `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RobotAccountServiceCreateResponse_RobotAccountFull) Reset() { - *x = RobotAccountServiceCreateResponse_RobotAccountFull{} - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RobotAccountServiceCreateResponse_RobotAccountFull) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RobotAccountServiceCreateResponse_RobotAccountFull) ProtoMessage() {} - -func (x *RobotAccountServiceCreateResponse_RobotAccountFull) ProtoReflect() protoreflect.Message { - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[6] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RobotAccountServiceCreateResponse_RobotAccountFull.ProtoReflect.Descriptor instead. -func (*RobotAccountServiceCreateResponse_RobotAccountFull) Descriptor() ([]byte, []int) { - return file_controlplane_v1_robot_accounts_proto_rawDescGZIP(), []int{1, 0} -} - -func (x *RobotAccountServiceCreateResponse_RobotAccountFull) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *RobotAccountServiceCreateResponse_RobotAccountFull) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *RobotAccountServiceCreateResponse_RobotAccountFull) GetWorkflowId() string { - if x != nil { - return x.WorkflowId - } - return "" -} - -func (x *RobotAccountServiceCreateResponse_RobotAccountFull) GetCreatedAt() *timestamppb.Timestamp { - if x != nil { - return x.CreatedAt - } - return nil -} - -func (x *RobotAccountServiceCreateResponse_RobotAccountFull) GetRevokedAt() *timestamppb.Timestamp { - if x != nil { - return x.RevokedAt - } - return nil -} - -func (x *RobotAccountServiceCreateResponse_RobotAccountFull) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -type RobotAccountServiceListResponse_RobotAccountItem struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - WorkflowId string `protobuf:"bytes,3,opt,name=workflow_id,json=workflowId,proto3" json:"workflow_id,omitempty"` - CreatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` - RevokedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=revoked_at,json=revokedAt,proto3" json:"revoked_at,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RobotAccountServiceListResponse_RobotAccountItem) Reset() { - *x = RobotAccountServiceListResponse_RobotAccountItem{} - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RobotAccountServiceListResponse_RobotAccountItem) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RobotAccountServiceListResponse_RobotAccountItem) ProtoMessage() {} - -func (x *RobotAccountServiceListResponse_RobotAccountItem) ProtoReflect() protoreflect.Message { - mi := &file_controlplane_v1_robot_accounts_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RobotAccountServiceListResponse_RobotAccountItem.ProtoReflect.Descriptor instead. -func (*RobotAccountServiceListResponse_RobotAccountItem) Descriptor() ([]byte, []int) { - return file_controlplane_v1_robot_accounts_proto_rawDescGZIP(), []int{5, 0} -} - -func (x *RobotAccountServiceListResponse_RobotAccountItem) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *RobotAccountServiceListResponse_RobotAccountItem) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *RobotAccountServiceListResponse_RobotAccountItem) GetWorkflowId() string { - if x != nil { - return x.WorkflowId - } - return "" -} - -func (x *RobotAccountServiceListResponse_RobotAccountItem) GetCreatedAt() *timestamppb.Timestamp { - if x != nil { - return x.CreatedAt - } - return nil -} - -func (x *RobotAccountServiceListResponse_RobotAccountItem) GetRevokedAt() *timestamppb.Timestamp { - if x != nil { - return x.RevokedAt - } - return nil -} - -var File_controlplane_v1_robot_accounts_proto protoreflect.FileDescriptor - -const file_controlplane_v1_robot_accounts_proto_rawDesc = "" + - "\n" + - "$controlplane/v1/robot_accounts.proto\x12\x0fcontrolplane.v1\x1a\x1bbuf/validate/validate.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"a\n" + - " RobotAccountServiceCreateRequest\x12\x12\n" + - "\x04name\x18\x01 \x01(\tR\x04name\x12)\n" + - "\vworkflow_id\x18\x02 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01R\n" + - "workflowId\"\xe2\x02\n" + - "!RobotAccountServiceCreateResponse\x12[\n" + - "\x06result\x18\x01 \x01(\v2C.controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFullR\x06result\x1a\xdf\x01\n" + - "\x10RobotAccountFull\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + - "\x04name\x18\x02 \x01(\tR\x04name\x12\x1f\n" + - "\vworkflow_id\x18\x03 \x01(\tR\n" + - "workflowId\x129\n" + - "\n" + - "created_at\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" + - "\n" + - "revoked_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\trevokedAt\x12\x10\n" + - "\x03key\x18\x06 \x01(\tR\x03key\"<\n" + - " RobotAccountServiceRevokeRequest\x12\x18\n" + - "\x02id\x18\x01 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01R\x02id\"#\n" + - "!RobotAccountServiceRevokeResponse\"t\n" + - "\x1eRobotAccountServiceListRequest\x12)\n" + - "\vworkflow_id\x18\x01 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01R\n" + - "workflowId\x12'\n" + - "\x0finclude_revoked\x18\x02 \x01(\bR\x0eincludeRevoked\"\xcc\x02\n" + - "\x1fRobotAccountServiceListResponse\x12Y\n" + - "\x06result\x18\x01 \x03(\v2A.controlplane.v1.RobotAccountServiceListResponse.RobotAccountItemR\x06result\x1a\xcd\x01\n" + - "\x10RobotAccountItem\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + - "\x04name\x18\x02 \x01(\tR\x04name\x12\x1f\n" + - "\vworkflow_id\x18\x03 \x01(\tR\n" + - "workflowId\x129\n" + - "\n" + - "created_at\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" + - "\n" + - "revoked_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\trevokedAt2\xe2\x02\n" + - "\x13RobotAccountService\x12o\n" + - "\x06Create\x121.controlplane.v1.RobotAccountServiceCreateRequest\x1a2.controlplane.v1.RobotAccountServiceCreateResponse\x12i\n" + - "\x04List\x12/.controlplane.v1.RobotAccountServiceListRequest\x1a0.controlplane.v1.RobotAccountServiceListResponse\x12o\n" + - "\x06Revoke\x121.controlplane.v1.RobotAccountServiceRevokeRequest\x1a2.controlplane.v1.RobotAccountServiceRevokeResponseBLZJgithub.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1;v1b\x06proto3" - -var ( - file_controlplane_v1_robot_accounts_proto_rawDescOnce sync.Once - file_controlplane_v1_robot_accounts_proto_rawDescData []byte -) - -func file_controlplane_v1_robot_accounts_proto_rawDescGZIP() []byte { - file_controlplane_v1_robot_accounts_proto_rawDescOnce.Do(func() { - file_controlplane_v1_robot_accounts_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_controlplane_v1_robot_accounts_proto_rawDesc), len(file_controlplane_v1_robot_accounts_proto_rawDesc))) - }) - return file_controlplane_v1_robot_accounts_proto_rawDescData -} - -var file_controlplane_v1_robot_accounts_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_controlplane_v1_robot_accounts_proto_goTypes = []any{ - (*RobotAccountServiceCreateRequest)(nil), // 0: controlplane.v1.RobotAccountServiceCreateRequest - (*RobotAccountServiceCreateResponse)(nil), // 1: controlplane.v1.RobotAccountServiceCreateResponse - (*RobotAccountServiceRevokeRequest)(nil), // 2: controlplane.v1.RobotAccountServiceRevokeRequest - (*RobotAccountServiceRevokeResponse)(nil), // 3: controlplane.v1.RobotAccountServiceRevokeResponse - (*RobotAccountServiceListRequest)(nil), // 4: controlplane.v1.RobotAccountServiceListRequest - (*RobotAccountServiceListResponse)(nil), // 5: controlplane.v1.RobotAccountServiceListResponse - (*RobotAccountServiceCreateResponse_RobotAccountFull)(nil), // 6: controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull - (*RobotAccountServiceListResponse_RobotAccountItem)(nil), // 7: controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem - (*timestamppb.Timestamp)(nil), // 8: google.protobuf.Timestamp -} -var file_controlplane_v1_robot_accounts_proto_depIdxs = []int32{ - 6, // 0: controlplane.v1.RobotAccountServiceCreateResponse.result:type_name -> controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull - 7, // 1: controlplane.v1.RobotAccountServiceListResponse.result:type_name -> controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem - 8, // 2: controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.created_at:type_name -> google.protobuf.Timestamp - 8, // 3: controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.revoked_at:type_name -> google.protobuf.Timestamp - 8, // 4: controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.created_at:type_name -> google.protobuf.Timestamp - 8, // 5: controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.revoked_at:type_name -> google.protobuf.Timestamp - 0, // 6: controlplane.v1.RobotAccountService.Create:input_type -> controlplane.v1.RobotAccountServiceCreateRequest - 4, // 7: controlplane.v1.RobotAccountService.List:input_type -> controlplane.v1.RobotAccountServiceListRequest - 2, // 8: controlplane.v1.RobotAccountService.Revoke:input_type -> controlplane.v1.RobotAccountServiceRevokeRequest - 1, // 9: controlplane.v1.RobotAccountService.Create:output_type -> controlplane.v1.RobotAccountServiceCreateResponse - 5, // 10: controlplane.v1.RobotAccountService.List:output_type -> controlplane.v1.RobotAccountServiceListResponse - 3, // 11: controlplane.v1.RobotAccountService.Revoke:output_type -> controlplane.v1.RobotAccountServiceRevokeResponse - 9, // [9:12] is the sub-list for method output_type - 6, // [6:9] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name -} - -func init() { file_controlplane_v1_robot_accounts_proto_init() } -func file_controlplane_v1_robot_accounts_proto_init() { - if File_controlplane_v1_robot_accounts_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_controlplane_v1_robot_accounts_proto_rawDesc), len(file_controlplane_v1_robot_accounts_proto_rawDesc)), - NumEnums: 0, - NumMessages: 8, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_controlplane_v1_robot_accounts_proto_goTypes, - DependencyIndexes: file_controlplane_v1_robot_accounts_proto_depIdxs, - MessageInfos: file_controlplane_v1_robot_accounts_proto_msgTypes, - }.Build() - File_controlplane_v1_robot_accounts_proto = out.File - file_controlplane_v1_robot_accounts_proto_goTypes = nil - file_controlplane_v1_robot_accounts_proto_depIdxs = nil -} diff --git a/app/controlplane/api/controlplane/v1/robot_accounts.proto b/app/controlplane/api/controlplane/v1/robot_accounts.proto deleted file mode 100644 index 464141dce..000000000 --- a/app/controlplane/api/controlplane/v1/robot_accounts.proto +++ /dev/null @@ -1,71 +0,0 @@ -// -// Copyright 2023 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. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package controlplane.v1; - -import "buf/validate/validate.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1;v1"; - -service RobotAccountService { - rpc Create(RobotAccountServiceCreateRequest) returns (RobotAccountServiceCreateResponse); - rpc List(RobotAccountServiceListRequest) returns (RobotAccountServiceListResponse); - rpc Revoke(RobotAccountServiceRevokeRequest) returns (RobotAccountServiceRevokeResponse); -} - -message RobotAccountServiceCreateRequest { - string name = 1; - string workflow_id = 2 [(buf.validate.field).string.uuid = true]; -} - -message RobotAccountServiceCreateResponse { - RobotAccountFull result = 1; - - message RobotAccountFull { - string id = 1; - string name = 2; - string workflow_id = 3; - google.protobuf.Timestamp created_at = 4; - google.protobuf.Timestamp revoked_at = 5; - // The key is returned only during creation - string key = 6; - } -} - -message RobotAccountServiceRevokeRequest { - string id = 1 [(buf.validate.field).string.uuid = true]; -} - -message RobotAccountServiceRevokeResponse {} - -message RobotAccountServiceListRequest { - string workflow_id = 1 [(buf.validate.field).string.uuid = true]; - bool include_revoked = 2; -} - -message RobotAccountServiceListResponse { - repeated RobotAccountItem result = 1; - - message RobotAccountItem { - string id = 1; - string name = 2; - string workflow_id = 3; - google.protobuf.Timestamp created_at = 4; - google.protobuf.Timestamp revoked_at = 5; - } -} diff --git a/app/controlplane/api/controlplane/v1/robot_accounts_grpc.pb.go b/app/controlplane/api/controlplane/v1/robot_accounts_grpc.pb.go deleted file mode 100644 index 42754955c..000000000 --- a/app/controlplane/api/controlplane/v1/robot_accounts_grpc.pb.go +++ /dev/null @@ -1,198 +0,0 @@ -// -// Copyright 2023 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. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc (unknown) -// source: controlplane/v1/robot_accounts.proto - -package v1 - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -const ( - RobotAccountService_Create_FullMethodName = "/controlplane.v1.RobotAccountService/Create" - RobotAccountService_List_FullMethodName = "/controlplane.v1.RobotAccountService/List" - RobotAccountService_Revoke_FullMethodName = "/controlplane.v1.RobotAccountService/Revoke" -) - -// RobotAccountServiceClient is the client API for RobotAccountService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type RobotAccountServiceClient interface { - Create(ctx context.Context, in *RobotAccountServiceCreateRequest, opts ...grpc.CallOption) (*RobotAccountServiceCreateResponse, error) - List(ctx context.Context, in *RobotAccountServiceListRequest, opts ...grpc.CallOption) (*RobotAccountServiceListResponse, error) - Revoke(ctx context.Context, in *RobotAccountServiceRevokeRequest, opts ...grpc.CallOption) (*RobotAccountServiceRevokeResponse, error) -} - -type robotAccountServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewRobotAccountServiceClient(cc grpc.ClientConnInterface) RobotAccountServiceClient { - return &robotAccountServiceClient{cc} -} - -func (c *robotAccountServiceClient) Create(ctx context.Context, in *RobotAccountServiceCreateRequest, opts ...grpc.CallOption) (*RobotAccountServiceCreateResponse, error) { - out := new(RobotAccountServiceCreateResponse) - err := c.cc.Invoke(ctx, RobotAccountService_Create_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *robotAccountServiceClient) List(ctx context.Context, in *RobotAccountServiceListRequest, opts ...grpc.CallOption) (*RobotAccountServiceListResponse, error) { - out := new(RobotAccountServiceListResponse) - err := c.cc.Invoke(ctx, RobotAccountService_List_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *robotAccountServiceClient) Revoke(ctx context.Context, in *RobotAccountServiceRevokeRequest, opts ...grpc.CallOption) (*RobotAccountServiceRevokeResponse, error) { - out := new(RobotAccountServiceRevokeResponse) - err := c.cc.Invoke(ctx, RobotAccountService_Revoke_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// RobotAccountServiceServer is the server API for RobotAccountService service. -// All implementations must embed UnimplementedRobotAccountServiceServer -// for forward compatibility -type RobotAccountServiceServer interface { - Create(context.Context, *RobotAccountServiceCreateRequest) (*RobotAccountServiceCreateResponse, error) - List(context.Context, *RobotAccountServiceListRequest) (*RobotAccountServiceListResponse, error) - Revoke(context.Context, *RobotAccountServiceRevokeRequest) (*RobotAccountServiceRevokeResponse, error) - mustEmbedUnimplementedRobotAccountServiceServer() -} - -// UnimplementedRobotAccountServiceServer must be embedded to have forward compatible implementations. -type UnimplementedRobotAccountServiceServer struct { -} - -func (UnimplementedRobotAccountServiceServer) Create(context.Context, *RobotAccountServiceCreateRequest) (*RobotAccountServiceCreateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} -func (UnimplementedRobotAccountServiceServer) List(context.Context, *RobotAccountServiceListRequest) (*RobotAccountServiceListResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} -func (UnimplementedRobotAccountServiceServer) Revoke(context.Context, *RobotAccountServiceRevokeRequest) (*RobotAccountServiceRevokeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Revoke not implemented") -} -func (UnimplementedRobotAccountServiceServer) mustEmbedUnimplementedRobotAccountServiceServer() {} - -// UnsafeRobotAccountServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to RobotAccountServiceServer will -// result in compilation errors. -type UnsafeRobotAccountServiceServer interface { - mustEmbedUnimplementedRobotAccountServiceServer() -} - -func RegisterRobotAccountServiceServer(s grpc.ServiceRegistrar, srv RobotAccountServiceServer) { - s.RegisterService(&RobotAccountService_ServiceDesc, srv) -} - -func _RobotAccountService_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RobotAccountServiceCreateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RobotAccountServiceServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: RobotAccountService_Create_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RobotAccountServiceServer).Create(ctx, req.(*RobotAccountServiceCreateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _RobotAccountService_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RobotAccountServiceListRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RobotAccountServiceServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: RobotAccountService_List_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RobotAccountServiceServer).List(ctx, req.(*RobotAccountServiceListRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _RobotAccountService_Revoke_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RobotAccountServiceRevokeRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RobotAccountServiceServer).Revoke(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: RobotAccountService_Revoke_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RobotAccountServiceServer).Revoke(ctx, req.(*RobotAccountServiceRevokeRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// RobotAccountService_ServiceDesc is the grpc.ServiceDesc for RobotAccountService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var RobotAccountService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "controlplane.v1.RobotAccountService", - HandlerType: (*RobotAccountServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Create", - Handler: _RobotAccountService_Create_Handler, - }, - { - MethodName: "List", - Handler: _RobotAccountService_List_Handler, - }, - { - MethodName: "Revoke", - Handler: _RobotAccountService_Revoke_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "controlplane/v1/robot_accounts.proto", -} diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/robot_accounts.ts b/app/controlplane/api/gen/frontend/controlplane/v1/robot_accounts.ts deleted file mode 100644 index 714f758d9..000000000 --- a/app/controlplane/api/gen/frontend/controlplane/v1/robot_accounts.ts +++ /dev/null @@ -1,945 +0,0 @@ -/* eslint-disable */ -import { grpc } from "@improbable-eng/grpc-web"; -import { BrowserHeaders } from "browser-headers"; -import _m0 from "protobufjs/minimal"; -import { Timestamp } from "../../google/protobuf/timestamp"; - -export const protobufPackage = "controlplane.v1"; - -export interface RobotAccountServiceCreateRequest { - name: string; - workflowId: string; -} - -export interface RobotAccountServiceCreateResponse { - result?: RobotAccountServiceCreateResponse_RobotAccountFull; -} - -export interface RobotAccountServiceCreateResponse_RobotAccountFull { - id: string; - name: string; - workflowId: string; - createdAt?: Date; - revokedAt?: Date; - /** The key is returned only during creation */ - key: string; -} - -export interface RobotAccountServiceRevokeRequest { - id: string; -} - -export interface RobotAccountServiceRevokeResponse { -} - -export interface RobotAccountServiceListRequest { - workflowId: string; - includeRevoked: boolean; -} - -export interface RobotAccountServiceListResponse { - result: RobotAccountServiceListResponse_RobotAccountItem[]; -} - -export interface RobotAccountServiceListResponse_RobotAccountItem { - id: string; - name: string; - workflowId: string; - createdAt?: Date; - revokedAt?: Date; -} - -function createBaseRobotAccountServiceCreateRequest(): RobotAccountServiceCreateRequest { - return { name: "", workflowId: "" }; -} - -export const RobotAccountServiceCreateRequest = { - encode(message: RobotAccountServiceCreateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== "") { - writer.uint32(10).string(message.name); - } - if (message.workflowId !== "") { - writer.uint32(18).string(message.workflowId); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): RobotAccountServiceCreateRequest { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseRobotAccountServiceCreateRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.name = reader.string(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.workflowId = reader.string(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): RobotAccountServiceCreateRequest { - return { - name: isSet(object.name) ? String(object.name) : "", - workflowId: isSet(object.workflowId) ? String(object.workflowId) : "", - }; - }, - - toJSON(message: RobotAccountServiceCreateRequest): unknown { - const obj: any = {}; - message.name !== undefined && (obj.name = message.name); - message.workflowId !== undefined && (obj.workflowId = message.workflowId); - return obj; - }, - - create, I>>( - base?: I, - ): RobotAccountServiceCreateRequest { - return RobotAccountServiceCreateRequest.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): RobotAccountServiceCreateRequest { - const message = createBaseRobotAccountServiceCreateRequest(); - message.name = object.name ?? ""; - message.workflowId = object.workflowId ?? ""; - return message; - }, -}; - -function createBaseRobotAccountServiceCreateResponse(): RobotAccountServiceCreateResponse { - return { result: undefined }; -} - -export const RobotAccountServiceCreateResponse = { - encode(message: RobotAccountServiceCreateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.result !== undefined) { - RobotAccountServiceCreateResponse_RobotAccountFull.encode(message.result, writer.uint32(10).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): RobotAccountServiceCreateResponse { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseRobotAccountServiceCreateResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.result = RobotAccountServiceCreateResponse_RobotAccountFull.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): RobotAccountServiceCreateResponse { - return { - result: isSet(object.result) - ? RobotAccountServiceCreateResponse_RobotAccountFull.fromJSON(object.result) - : undefined, - }; - }, - - toJSON(message: RobotAccountServiceCreateResponse): unknown { - const obj: any = {}; - message.result !== undefined && (obj.result = message.result - ? RobotAccountServiceCreateResponse_RobotAccountFull.toJSON(message.result) - : undefined); - return obj; - }, - - create, I>>( - base?: I, - ): RobotAccountServiceCreateResponse { - return RobotAccountServiceCreateResponse.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): RobotAccountServiceCreateResponse { - const message = createBaseRobotAccountServiceCreateResponse(); - message.result = (object.result !== undefined && object.result !== null) - ? RobotAccountServiceCreateResponse_RobotAccountFull.fromPartial(object.result) - : undefined; - return message; - }, -}; - -function createBaseRobotAccountServiceCreateResponse_RobotAccountFull(): RobotAccountServiceCreateResponse_RobotAccountFull { - return { id: "", name: "", workflowId: "", createdAt: undefined, revokedAt: undefined, key: "" }; -} - -export const RobotAccountServiceCreateResponse_RobotAccountFull = { - encode( - message: RobotAccountServiceCreateResponse_RobotAccountFull, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { - if (message.id !== "") { - writer.uint32(10).string(message.id); - } - if (message.name !== "") { - writer.uint32(18).string(message.name); - } - if (message.workflowId !== "") { - writer.uint32(26).string(message.workflowId); - } - if (message.createdAt !== undefined) { - Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(34).fork()).ldelim(); - } - if (message.revokedAt !== undefined) { - Timestamp.encode(toTimestamp(message.revokedAt), writer.uint32(42).fork()).ldelim(); - } - if (message.key !== "") { - writer.uint32(50).string(message.key); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): RobotAccountServiceCreateResponse_RobotAccountFull { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseRobotAccountServiceCreateResponse_RobotAccountFull(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.id = reader.string(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.name = reader.string(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.workflowId = reader.string(); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.createdAt = fromTimestamp(Timestamp.decode(reader, reader.uint32())); - continue; - case 5: - if (tag !== 42) { - break; - } - - message.revokedAt = fromTimestamp(Timestamp.decode(reader, reader.uint32())); - continue; - case 6: - if (tag !== 50) { - break; - } - - message.key = reader.string(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): RobotAccountServiceCreateResponse_RobotAccountFull { - return { - id: isSet(object.id) ? String(object.id) : "", - name: isSet(object.name) ? String(object.name) : "", - workflowId: isSet(object.workflowId) ? String(object.workflowId) : "", - createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, - revokedAt: isSet(object.revokedAt) ? fromJsonTimestamp(object.revokedAt) : undefined, - key: isSet(object.key) ? String(object.key) : "", - }; - }, - - toJSON(message: RobotAccountServiceCreateResponse_RobotAccountFull): unknown { - const obj: any = {}; - message.id !== undefined && (obj.id = message.id); - message.name !== undefined && (obj.name = message.name); - message.workflowId !== undefined && (obj.workflowId = message.workflowId); - message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString()); - message.revokedAt !== undefined && (obj.revokedAt = message.revokedAt.toISOString()); - message.key !== undefined && (obj.key = message.key); - return obj; - }, - - create, I>>( - base?: I, - ): RobotAccountServiceCreateResponse_RobotAccountFull { - return RobotAccountServiceCreateResponse_RobotAccountFull.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): RobotAccountServiceCreateResponse_RobotAccountFull { - const message = createBaseRobotAccountServiceCreateResponse_RobotAccountFull(); - message.id = object.id ?? ""; - message.name = object.name ?? ""; - message.workflowId = object.workflowId ?? ""; - message.createdAt = object.createdAt ?? undefined; - message.revokedAt = object.revokedAt ?? undefined; - message.key = object.key ?? ""; - return message; - }, -}; - -function createBaseRobotAccountServiceRevokeRequest(): RobotAccountServiceRevokeRequest { - return { id: "" }; -} - -export const RobotAccountServiceRevokeRequest = { - encode(message: RobotAccountServiceRevokeRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== "") { - writer.uint32(10).string(message.id); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): RobotAccountServiceRevokeRequest { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseRobotAccountServiceRevokeRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.id = reader.string(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): RobotAccountServiceRevokeRequest { - return { id: isSet(object.id) ? String(object.id) : "" }; - }, - - toJSON(message: RobotAccountServiceRevokeRequest): unknown { - const obj: any = {}; - message.id !== undefined && (obj.id = message.id); - return obj; - }, - - create, I>>( - base?: I, - ): RobotAccountServiceRevokeRequest { - return RobotAccountServiceRevokeRequest.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): RobotAccountServiceRevokeRequest { - const message = createBaseRobotAccountServiceRevokeRequest(); - message.id = object.id ?? ""; - return message; - }, -}; - -function createBaseRobotAccountServiceRevokeResponse(): RobotAccountServiceRevokeResponse { - return {}; -} - -export const RobotAccountServiceRevokeResponse = { - encode(_: RobotAccountServiceRevokeResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): RobotAccountServiceRevokeResponse { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseRobotAccountServiceRevokeResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(_: any): RobotAccountServiceRevokeResponse { - return {}; - }, - - toJSON(_: RobotAccountServiceRevokeResponse): unknown { - const obj: any = {}; - return obj; - }, - - create, I>>( - base?: I, - ): RobotAccountServiceRevokeResponse { - return RobotAccountServiceRevokeResponse.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - _: I, - ): RobotAccountServiceRevokeResponse { - const message = createBaseRobotAccountServiceRevokeResponse(); - return message; - }, -}; - -function createBaseRobotAccountServiceListRequest(): RobotAccountServiceListRequest { - return { workflowId: "", includeRevoked: false }; -} - -export const RobotAccountServiceListRequest = { - encode(message: RobotAccountServiceListRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.workflowId !== "") { - writer.uint32(10).string(message.workflowId); - } - if (message.includeRevoked === true) { - writer.uint32(16).bool(message.includeRevoked); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): RobotAccountServiceListRequest { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseRobotAccountServiceListRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.workflowId = reader.string(); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.includeRevoked = reader.bool(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): RobotAccountServiceListRequest { - return { - workflowId: isSet(object.workflowId) ? String(object.workflowId) : "", - includeRevoked: isSet(object.includeRevoked) ? Boolean(object.includeRevoked) : false, - }; - }, - - toJSON(message: RobotAccountServiceListRequest): unknown { - const obj: any = {}; - message.workflowId !== undefined && (obj.workflowId = message.workflowId); - message.includeRevoked !== undefined && (obj.includeRevoked = message.includeRevoked); - return obj; - }, - - create, I>>(base?: I): RobotAccountServiceListRequest { - return RobotAccountServiceListRequest.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): RobotAccountServiceListRequest { - const message = createBaseRobotAccountServiceListRequest(); - message.workflowId = object.workflowId ?? ""; - message.includeRevoked = object.includeRevoked ?? false; - return message; - }, -}; - -function createBaseRobotAccountServiceListResponse(): RobotAccountServiceListResponse { - return { result: [] }; -} - -export const RobotAccountServiceListResponse = { - encode(message: RobotAccountServiceListResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - for (const v of message.result) { - RobotAccountServiceListResponse_RobotAccountItem.encode(v!, writer.uint32(10).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): RobotAccountServiceListResponse { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseRobotAccountServiceListResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.result.push(RobotAccountServiceListResponse_RobotAccountItem.decode(reader, reader.uint32())); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): RobotAccountServiceListResponse { - return { - result: Array.isArray(object?.result) - ? object.result.map((e: any) => RobotAccountServiceListResponse_RobotAccountItem.fromJSON(e)) - : [], - }; - }, - - toJSON(message: RobotAccountServiceListResponse): unknown { - const obj: any = {}; - if (message.result) { - obj.result = message.result.map((e) => - e ? RobotAccountServiceListResponse_RobotAccountItem.toJSON(e) : undefined - ); - } else { - obj.result = []; - } - return obj; - }, - - create, I>>(base?: I): RobotAccountServiceListResponse { - return RobotAccountServiceListResponse.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): RobotAccountServiceListResponse { - const message = createBaseRobotAccountServiceListResponse(); - message.result = object.result?.map((e) => RobotAccountServiceListResponse_RobotAccountItem.fromPartial(e)) || []; - return message; - }, -}; - -function createBaseRobotAccountServiceListResponse_RobotAccountItem(): RobotAccountServiceListResponse_RobotAccountItem { - return { id: "", name: "", workflowId: "", createdAt: undefined, revokedAt: undefined }; -} - -export const RobotAccountServiceListResponse_RobotAccountItem = { - encode( - message: RobotAccountServiceListResponse_RobotAccountItem, - writer: _m0.Writer = _m0.Writer.create(), - ): _m0.Writer { - if (message.id !== "") { - writer.uint32(10).string(message.id); - } - if (message.name !== "") { - writer.uint32(18).string(message.name); - } - if (message.workflowId !== "") { - writer.uint32(26).string(message.workflowId); - } - if (message.createdAt !== undefined) { - Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(34).fork()).ldelim(); - } - if (message.revokedAt !== undefined) { - Timestamp.encode(toTimestamp(message.revokedAt), writer.uint32(42).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): RobotAccountServiceListResponse_RobotAccountItem { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseRobotAccountServiceListResponse_RobotAccountItem(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.id = reader.string(); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.name = reader.string(); - continue; - case 3: - if (tag !== 26) { - break; - } - - message.workflowId = reader.string(); - continue; - case 4: - if (tag !== 34) { - break; - } - - message.createdAt = fromTimestamp(Timestamp.decode(reader, reader.uint32())); - continue; - case 5: - if (tag !== 42) { - break; - } - - message.revokedAt = fromTimestamp(Timestamp.decode(reader, reader.uint32())); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): RobotAccountServiceListResponse_RobotAccountItem { - return { - id: isSet(object.id) ? String(object.id) : "", - name: isSet(object.name) ? String(object.name) : "", - workflowId: isSet(object.workflowId) ? String(object.workflowId) : "", - createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, - revokedAt: isSet(object.revokedAt) ? fromJsonTimestamp(object.revokedAt) : undefined, - }; - }, - - toJSON(message: RobotAccountServiceListResponse_RobotAccountItem): unknown { - const obj: any = {}; - message.id !== undefined && (obj.id = message.id); - message.name !== undefined && (obj.name = message.name); - message.workflowId !== undefined && (obj.workflowId = message.workflowId); - message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString()); - message.revokedAt !== undefined && (obj.revokedAt = message.revokedAt.toISOString()); - return obj; - }, - - create, I>>( - base?: I, - ): RobotAccountServiceListResponse_RobotAccountItem { - return RobotAccountServiceListResponse_RobotAccountItem.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): RobotAccountServiceListResponse_RobotAccountItem { - const message = createBaseRobotAccountServiceListResponse_RobotAccountItem(); - message.id = object.id ?? ""; - message.name = object.name ?? ""; - message.workflowId = object.workflowId ?? ""; - message.createdAt = object.createdAt ?? undefined; - message.revokedAt = object.revokedAt ?? undefined; - return message; - }, -}; - -export interface RobotAccountService { - Create( - request: DeepPartial, - metadata?: grpc.Metadata, - ): Promise; - List( - request: DeepPartial, - metadata?: grpc.Metadata, - ): Promise; - Revoke( - request: DeepPartial, - metadata?: grpc.Metadata, - ): Promise; -} - -export class RobotAccountServiceClientImpl implements RobotAccountService { - private readonly rpc: Rpc; - - constructor(rpc: Rpc) { - this.rpc = rpc; - this.Create = this.Create.bind(this); - this.List = this.List.bind(this); - this.Revoke = this.Revoke.bind(this); - } - - Create( - request: DeepPartial, - metadata?: grpc.Metadata, - ): Promise { - return this.rpc.unary( - RobotAccountServiceCreateDesc, - RobotAccountServiceCreateRequest.fromPartial(request), - metadata, - ); - } - - List( - request: DeepPartial, - metadata?: grpc.Metadata, - ): Promise { - return this.rpc.unary(RobotAccountServiceListDesc, RobotAccountServiceListRequest.fromPartial(request), metadata); - } - - Revoke( - request: DeepPartial, - metadata?: grpc.Metadata, - ): Promise { - return this.rpc.unary( - RobotAccountServiceRevokeDesc, - RobotAccountServiceRevokeRequest.fromPartial(request), - metadata, - ); - } -} - -export const RobotAccountServiceDesc = { serviceName: "controlplane.v1.RobotAccountService" }; - -export const RobotAccountServiceCreateDesc: UnaryMethodDefinitionish = { - methodName: "Create", - service: RobotAccountServiceDesc, - requestStream: false, - responseStream: false, - requestType: { - serializeBinary() { - return RobotAccountServiceCreateRequest.encode(this).finish(); - }, - } as any, - responseType: { - deserializeBinary(data: Uint8Array) { - const value = RobotAccountServiceCreateResponse.decode(data); - return { - ...value, - toObject() { - return value; - }, - }; - }, - } as any, -}; - -export const RobotAccountServiceListDesc: UnaryMethodDefinitionish = { - methodName: "List", - service: RobotAccountServiceDesc, - requestStream: false, - responseStream: false, - requestType: { - serializeBinary() { - return RobotAccountServiceListRequest.encode(this).finish(); - }, - } as any, - responseType: { - deserializeBinary(data: Uint8Array) { - const value = RobotAccountServiceListResponse.decode(data); - return { - ...value, - toObject() { - return value; - }, - }; - }, - } as any, -}; - -export const RobotAccountServiceRevokeDesc: UnaryMethodDefinitionish = { - methodName: "Revoke", - service: RobotAccountServiceDesc, - requestStream: false, - responseStream: false, - requestType: { - serializeBinary() { - return RobotAccountServiceRevokeRequest.encode(this).finish(); - }, - } as any, - responseType: { - deserializeBinary(data: Uint8Array) { - const value = RobotAccountServiceRevokeResponse.decode(data); - return { - ...value, - toObject() { - return value; - }, - }; - }, - } as any, -}; - -interface UnaryMethodDefinitionishR extends grpc.UnaryMethodDefinition { - requestStream: any; - responseStream: any; -} - -type UnaryMethodDefinitionish = UnaryMethodDefinitionishR; - -interface Rpc { - unary( - methodDesc: T, - request: any, - metadata: grpc.Metadata | undefined, - ): Promise; -} - -export class GrpcWebImpl { - private host: string; - private options: { - transport?: grpc.TransportFactory; - - debug?: boolean; - metadata?: grpc.Metadata; - upStreamRetryCodes?: number[]; - }; - - constructor( - host: string, - options: { - transport?: grpc.TransportFactory; - - debug?: boolean; - metadata?: grpc.Metadata; - upStreamRetryCodes?: number[]; - }, - ) { - this.host = host; - this.options = options; - } - - unary( - methodDesc: T, - _request: any, - metadata: grpc.Metadata | undefined, - ): Promise { - const request = { ..._request, ...methodDesc.requestType }; - const maybeCombinedMetadata = metadata && this.options.metadata - ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) - : metadata || this.options.metadata; - return new Promise((resolve, reject) => { - grpc.unary(methodDesc, { - request, - host: this.host, - metadata: maybeCombinedMetadata, - transport: this.options.transport, - debug: this.options.debug, - onEnd: function (response) { - if (response.status === grpc.Code.OK) { - resolve(response.message!.toObject()); - } else { - const err = new GrpcWebError(response.statusMessage, response.status, response.trailers); - reject(err); - } - }, - }); - }); - } -} - -declare var self: any | undefined; -declare var window: any | undefined; -declare var global: any | undefined; -var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== "undefined") { - return globalThis; - } - if (typeof self !== "undefined") { - return self; - } - if (typeof window !== "undefined") { - return window; - } - if (typeof global !== "undefined") { - return global; - } - throw "Unable to locate global object"; -})(); - -type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; - -export type DeepPartial = T extends Builtin ? T - : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> - : T extends {} ? { [K in keyof T]?: DeepPartial } - : Partial; - -type KeysOfUnion = T extends T ? keyof T : never; -export type Exact = P extends Builtin ? P - : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; - -function toTimestamp(date: Date): Timestamp { - const seconds = date.getTime() / 1_000; - const nanos = (date.getTime() % 1_000) * 1_000_000; - return { seconds, nanos }; -} - -function fromTimestamp(t: Timestamp): Date { - let millis = (t.seconds || 0) * 1_000; - millis += (t.nanos || 0) / 1_000_000; - return new Date(millis); -} - -function fromJsonTimestamp(o: any): Date { - if (o instanceof Date) { - return o; - } else if (typeof o === "string") { - return new Date(o); - } else { - return fromTimestamp(Timestamp.fromJSON(o)); - } -} - -function isSet(value: any): boolean { - return value !== null && value !== undefined; -} - -export class GrpcWebError extends tsProtoGlobalThis.Error { - constructor(message: string, public code: grpc.Code, public metadata: grpc.Metadata) { - super(message); - } -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateRequest.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateRequest.jsonschema.json deleted file mode 100644 index 62db70d00..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateRequest.jsonschema.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceCreateRequest.jsonschema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "patternProperties": { - "^(workflow_id)$": { - "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "type": "string" - } - }, - "properties": { - "name": { - "type": "string" - }, - "workflowId": { - "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "type": "string" - } - }, - "title": "Robot Account Service Create Request", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateRequest.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateRequest.schema.json deleted file mode 100644 index 16fc205e6..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateRequest.schema.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceCreateRequest.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "patternProperties": { - "^(workflowId)$": { - "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "type": "string" - } - }, - "properties": { - "name": { - "type": "string" - }, - "workflow_id": { - "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "type": "string" - } - }, - "title": "Robot Account Service Create Request", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.jsonschema.json deleted file mode 100644 index 6efcf6ebd..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.jsonschema.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.jsonschema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "patternProperties": { - "^(created_at)$": { - "$ref": "google.protobuf.Timestamp.jsonschema.json" - }, - "^(revoked_at)$": { - "$ref": "google.protobuf.Timestamp.jsonschema.json" - }, - "^(workflow_id)$": { - "type": "string" - } - }, - "properties": { - "createdAt": { - "$ref": "google.protobuf.Timestamp.jsonschema.json" - }, - "id": { - "type": "string" - }, - "key": { - "description": "The key is returned only during creation", - "type": "string" - }, - "name": { - "type": "string" - }, - "revokedAt": { - "$ref": "google.protobuf.Timestamp.jsonschema.json" - }, - "workflowId": { - "type": "string" - } - }, - "title": "Robot Account Full", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.schema.json deleted file mode 100644 index 3576211c6..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.schema.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "patternProperties": { - "^(createdAt)$": { - "$ref": "google.protobuf.Timestamp.schema.json" - }, - "^(revokedAt)$": { - "$ref": "google.protobuf.Timestamp.schema.json" - }, - "^(workflowId)$": { - "type": "string" - } - }, - "properties": { - "created_at": { - "$ref": "google.protobuf.Timestamp.schema.json" - }, - "id": { - "type": "string" - }, - "key": { - "description": "The key is returned only during creation", - "type": "string" - }, - "name": { - "type": "string" - }, - "revoked_at": { - "$ref": "google.protobuf.Timestamp.schema.json" - }, - "workflow_id": { - "type": "string" - } - }, - "title": "Robot Account Full", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.jsonschema.json deleted file mode 100644 index 2581c0625..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.jsonschema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceCreateResponse.jsonschema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "properties": { - "result": { - "$ref": "controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.jsonschema.json" - } - }, - "title": "Robot Account Service Create Response", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.schema.json deleted file mode 100644 index 31e2c20f8..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceCreateResponse.schema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceCreateResponse.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "properties": { - "result": { - "$ref": "controlplane.v1.RobotAccountServiceCreateResponse.RobotAccountFull.schema.json" - } - }, - "title": "Robot Account Service Create Response", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListRequest.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListRequest.jsonschema.json deleted file mode 100644 index c54ddf661..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListRequest.jsonschema.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceListRequest.jsonschema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "patternProperties": { - "^(include_revoked)$": { - "type": "boolean" - }, - "^(workflow_id)$": { - "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "type": "string" - } - }, - "properties": { - "includeRevoked": { - "type": "boolean" - }, - "workflowId": { - "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "type": "string" - } - }, - "title": "Robot Account Service List Request", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListRequest.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListRequest.schema.json deleted file mode 100644 index c37b27473..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListRequest.schema.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceListRequest.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "patternProperties": { - "^(includeRevoked)$": { - "type": "boolean" - }, - "^(workflowId)$": { - "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "type": "string" - } - }, - "properties": { - "include_revoked": { - "type": "boolean" - }, - "workflow_id": { - "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "type": "string" - } - }, - "title": "Robot Account Service List Request", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.jsonschema.json deleted file mode 100644 index 297c7e76f..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.jsonschema.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.jsonschema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "patternProperties": { - "^(created_at)$": { - "$ref": "google.protobuf.Timestamp.jsonschema.json" - }, - "^(revoked_at)$": { - "$ref": "google.protobuf.Timestamp.jsonschema.json" - }, - "^(workflow_id)$": { - "type": "string" - } - }, - "properties": { - "createdAt": { - "$ref": "google.protobuf.Timestamp.jsonschema.json" - }, - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "revokedAt": { - "$ref": "google.protobuf.Timestamp.jsonschema.json" - }, - "workflowId": { - "type": "string" - } - }, - "title": "Robot Account Item", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.schema.json deleted file mode 100644 index 5e9259414..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.schema.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "patternProperties": { - "^(createdAt)$": { - "$ref": "google.protobuf.Timestamp.schema.json" - }, - "^(revokedAt)$": { - "$ref": "google.protobuf.Timestamp.schema.json" - }, - "^(workflowId)$": { - "type": "string" - } - }, - "properties": { - "created_at": { - "$ref": "google.protobuf.Timestamp.schema.json" - }, - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "revoked_at": { - "$ref": "google.protobuf.Timestamp.schema.json" - }, - "workflow_id": { - "type": "string" - } - }, - "title": "Robot Account Item", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.jsonschema.json deleted file mode 100644 index 4191d65a7..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.jsonschema.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceListResponse.jsonschema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "properties": { - "result": { - "items": { - "$ref": "controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.jsonschema.json" - }, - "type": "array" - } - }, - "title": "Robot Account Service List Response", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.schema.json deleted file mode 100644 index 2ffdd83c8..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceListResponse.schema.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceListResponse.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "properties": { - "result": { - "items": { - "$ref": "controlplane.v1.RobotAccountServiceListResponse.RobotAccountItem.schema.json" - }, - "type": "array" - } - }, - "title": "Robot Account Service List Response", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeRequest.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeRequest.jsonschema.json deleted file mode 100644 index 1c2f6f56d..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeRequest.jsonschema.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceRevokeRequest.jsonschema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "properties": { - "id": { - "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "type": "string" - } - }, - "title": "Robot Account Service Revoke Request", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeRequest.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeRequest.schema.json deleted file mode 100644 index 4104b4c94..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeRequest.schema.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceRevokeRequest.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "properties": { - "id": { - "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "type": "string" - } - }, - "title": "Robot Account Service Revoke Request", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeResponse.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeResponse.jsonschema.json deleted file mode 100644 index 29354c2de..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeResponse.jsonschema.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceRevokeResponse.jsonschema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "properties": {}, - "title": "Robot Account Service Revoke Response", - "type": "object" -} diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeResponse.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeResponse.schema.json deleted file mode 100644 index 224207efe..000000000 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.RobotAccountServiceRevokeResponse.schema.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$id": "controlplane.v1.RobotAccountServiceRevokeResponse.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "properties": {}, - "title": "Robot Account Service Revoke Response", - "type": "object" -} diff --git a/app/controlplane/cmd/wire_gen.go b/app/controlplane/cmd/wire_gen.go index 4e2151e9e..d40d2ae8f 100644 --- a/app/controlplane/cmd/wire_gen.go +++ b/app/controlplane/cmd/wire_gen.go @@ -112,9 +112,9 @@ func wireApp(contextContext context.Context, bootstrap *conf.Bootstrap, readerWr UserAccessSyncer: userAccessSyncerUseCase, } userUseCase := biz.NewUserUseCase(newUserUseCaseParams) - robotAccountRepo := data.NewRobotAccountRepo(dataData, logger) + robotAccountRepo := data.NewRobotAccountRepo(dataData) + robotAccountUseCase := biz.NewRobotAccountUseCase(robotAccountRepo) auth := bootstrap.Auth - robotAccountUseCase := biz.NewRootAccountUseCase(robotAccountRepo, workflowRepo, auth, logger) casCredentialsUseCase, err := biz.NewCASCredentialsUseCase(auth) if err != nil { cleanup3() @@ -187,7 +187,6 @@ func wireApp(contextContext context.Context, bootstrap *conf.Bootstrap, readerWr cleanup() return nil, nil, err } - robotAccountService := service.NewRobotAccountService(robotAccountUseCase, v5...) workflowRunRepo := data.NewWorkflowRunRepo(dataData, logger) signingUseCase, err := biz.NewChainloopSigningUseCase(bootstrap, logger) if err != nil { @@ -342,7 +341,6 @@ func wireApp(contextContext context.Context, bootstrap *conf.Bootstrap, readerWr ClaimsCache: cacheCache, WorkflowSvc: workflowService, AuthSvc: authService, - RobotAccountSvc: robotAccountService, WorkflowRunSvc: workflowRunService, AttestationSvc: attestationService, WorkflowContractSvc: workflowContractService, diff --git a/app/controlplane/internal/server/grpc.go b/app/controlplane/internal/server/grpc.go index 38711d932..f93150d25 100644 --- a/app/controlplane/internal/server/grpc.go +++ b/app/controlplane/internal/server/grpc.go @@ -70,7 +70,6 @@ type Opts struct { // Services WorkflowSvc *service.WorkflowService AuthSvc *service.AuthService - RobotAccountSvc *service.RobotAccountService WorkflowRunSvc *service.WorkflowRunService AttestationSvc *service.AttestationService WorkflowContractSvc *service.WorkflowContractService @@ -156,7 +155,6 @@ func NewGRPCServer(opts *Opts) (*grpc.Server, error) { srv := grpc.NewServer(serverOpts...) v1.RegisterWorkflowServiceServer(srv, opts.WorkflowSvc) v1.RegisterStatusServiceServer(srv, service.NewStatusService(opts.AuthSvc.AuthURLs.Login, Version, opts.CASClientUseCase, opts.BootstrapConfig)) - v1.RegisterRobotAccountServiceServer(srv, opts.RobotAccountSvc) v1.RegisterWorkflowRunServiceServer(srv, opts.WorkflowRunSvc) v1.RegisterAttestationServiceServer(srv, opts.AttestationSvc) v1.RegisterWorkflowContractServiceServer(srv, opts.WorkflowContractSvc) diff --git a/app/controlplane/internal/service/robotaccount.go b/app/controlplane/internal/service/robotaccount.go deleted file mode 100644 index d142f8295..000000000 --- a/app/controlplane/internal/service/robotaccount.go +++ /dev/null @@ -1,103 +0,0 @@ -// -// Copyright 2023 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. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package service - -import ( - "context" - - pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1" - "github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz" - "github.com/go-kratos/kratos/v2/errors" - "google.golang.org/protobuf/types/known/timestamppb" -) - -type RobotAccountService struct { - pb.UnimplementedRobotAccountServiceServer - *service - - robotAccountUseCase *biz.RobotAccountUseCase -} - -func NewRobotAccountService(uc *biz.RobotAccountUseCase, opts ...NewOpt) *RobotAccountService { - return &RobotAccountService{ - service: newService(opts...), - robotAccountUseCase: uc, - } -} - -func (s *RobotAccountService) Create(ctx context.Context, req *pb.RobotAccountServiceCreateRequest) (*pb.RobotAccountServiceCreateResponse, error) { - currentOrg, err := requireCurrentOrg(ctx) - if err != nil { - return nil, err - } - - robotAccount, err := s.robotAccountUseCase.Create(ctx, req.Name, currentOrg.ID, req.WorkflowId) - if err != nil && biz.IsNotFound(err) { - return nil, errors.NotFound("not found", err.Error()) - } else if err != nil { - return nil, handleUseCaseErr(err, s.log) - } - - return &pb.RobotAccountServiceCreateResponse{ - Result: &pb.RobotAccountServiceCreateResponse_RobotAccountFull{ - Id: robotAccount.ID.String(), Name: robotAccount.Name, WorkflowId: robotAccount.WorkflowID.String(), CreatedAt: timestamppb.New(*robotAccount.CreatedAt), Key: robotAccount.JWT, - }, - }, nil -} - -func (s *RobotAccountService) List(ctx context.Context, req *pb.RobotAccountServiceListRequest) (*pb.RobotAccountServiceListResponse, error) { - currentOrg, err := requireCurrentOrg(ctx) - if err != nil { - return nil, err - } - - robotAccounts, err := s.robotAccountUseCase.List(ctx, currentOrg.ID, req.WorkflowId, req.IncludeRevoked) - if err != nil && biz.IsNotFound(err) { - return nil, errors.NotFound("not found", err.Error()) - } else if err != nil { - return nil, handleUseCaseErr(err, s.log) - } - - result := make([]*pb.RobotAccountServiceListResponse_RobotAccountItem, 0, len(robotAccounts)) - for _, p := range robotAccounts { - acc := &pb.RobotAccountServiceListResponse_RobotAccountItem{ - Id: p.ID.String(), WorkflowId: p.WorkflowID.String(), - Name: p.Name, - CreatedAt: timestamppb.New(*p.CreatedAt), - } - - if p.RevokedAt != nil { - acc.RevokedAt = timestamppb.New(*p.RevokedAt) - } - - result = append(result, acc) - } - - return &pb.RobotAccountServiceListResponse{Result: result}, nil -} - -func (s *RobotAccountService) Revoke(ctx context.Context, req *pb.RobotAccountServiceRevokeRequest) (*pb.RobotAccountServiceRevokeResponse, error) { - currentOrg, err := requireCurrentOrg(ctx) - if err != nil { - return nil, err - } - - if err := s.robotAccountUseCase.Revoke(ctx, currentOrg.ID, req.Id); err != nil { - return nil, handleUseCaseErr(err, s.log) - } - - return &pb.RobotAccountServiceRevokeResponse{}, nil -} diff --git a/app/controlplane/internal/service/service.go b/app/controlplane/internal/service/service.go index 40e613b5e..4821f664d 100644 --- a/app/controlplane/internal/service/service.go +++ b/app/controlplane/internal/service/service.go @@ -40,7 +40,6 @@ import ( var ProviderSet = wire.NewSet( NewWorkflowService, NewAuthService, - NewRobotAccountService, NewWorkflowRunService, NewAttestationService, NewWorkflowSchemaService, diff --git a/app/controlplane/pkg/authz/authz.go b/app/controlplane/pkg/authz/authz.go index 04e2a483b..fe230e52c 100644 --- a/app/controlplane/pkg/authz/authz.go +++ b/app/controlplane/pkg/authz/authz.go @@ -58,7 +58,6 @@ const ( ResourceRegisteredIntegration = "integration_registered" ResourceAttachedIntegration = "integration_attached" ResourceOrgMetric = "metrics_org" - ResourceRobotAccount = "robot_account" ResourceWorkflowRun = "workflow_run" ResourceWorkflow = "workflow" ResourceProject = "project" @@ -133,9 +132,6 @@ var ( PolicyAttachedIntegrationDetach = &Policy{ResourceAttachedIntegration, ActionDelete} // Org Metrics PolicyOrgMetricsRead = &Policy{ResourceOrgMetric, ActionList} - // Robot Account - PolicyRobotAccountList = &Policy{ResourceRobotAccount, ActionList} - PolicyRobotAccountCreate = &Policy{ResourceRobotAccount, ActionCreate} // Workflow Contract PolicyWorkflowContractList = &Policy{ResourceWorkflowContract, ActionList} PolicyWorkflowContractRead = &Policy{ResourceWorkflowContract, ActionRead} @@ -232,8 +228,6 @@ var RolesMap = map[Role][]*Policy{ PolicyAttachedIntegrationList, // Metrics PolicyOrgMetricsRead, - // Robot Account - PolicyRobotAccountList, // Workflow Contract PolicyWorkflowContractList, PolicyWorkflowContractRead, @@ -386,9 +380,6 @@ var ServerOperationsMap = map[string]*OperationPolicy{ "/controlplane.v1.OrgMetricsService/Totals": {Policies: []*Policy{PolicyOrgMetricsRead}}, "/controlplane.v1.OrgMetricsService/TopWorkflowsByRunsCount": {Policies: []*Policy{PolicyOrgMetricsRead}}, "/controlplane.v1.OrgMetricsService/DailyRunsCount": {Policies: []*Policy{PolicyOrgMetricsRead}}, - // Robot Account - "/controlplane.v1.RobotAccountService/List": {Policies: []*Policy{PolicyRobotAccountList}}, - "/controlplane.v1.RobotAccountService/Create": {Policies: []*Policy{PolicyRobotAccountCreate}}, // Workflows "/controlplane.v1.WorkflowService/List": {Policies: []*Policy{PolicyWorkflowList}}, "/controlplane.v1.WorkflowService/View": {Policies: []*Policy{PolicyWorkflowRead}}, diff --git a/app/controlplane/pkg/authz/authz_consistency_test.go b/app/controlplane/pkg/authz/authz_consistency_test.go index 1be3b6062..40577ba88 100644 --- a/app/controlplane/pkg/authz/authz_consistency_test.go +++ b/app/controlplane/pkg/authz/authz_consistency_test.go @@ -99,9 +99,6 @@ var adminOnlyProcedures = map[string]struct{}{ "/controlplane.v1.OrganizationService/DeleteMembership": {}, "/controlplane.v1.OrganizationService/Update": {}, "/controlplane.v1.OrganizationService/UpdateMembership": {}, - - // Robot account revocation (List/Create are role-gated in ServerOperationsMap). - "/controlplane.v1.RobotAccountService/Revoke": {}, } // TestEveryProcedureIsClassified asserts that every controlplane.v1 wire procedure is explicitly diff --git a/app/controlplane/pkg/biz/apitoken.go b/app/controlplane/pkg/biz/apitoken.go index 00a801ae8..f57ffd116 100644 --- a/app/controlplane/pkg/biz/apitoken.go +++ b/app/controlplane/pkg/biz/apitoken.go @@ -38,12 +38,40 @@ type APITokenJWTConfig struct { SymmetricHmacKey string } -// orgLevelTokenPolicies are additional policies granted only to org-level tokens. -// They allow managing project-scoped tokens. +// orgLevelTokenPolicies are granted only to org-level tokens. RegisteredIntegrationAdd is here because +// IntegrationsService/Register creates an org-level object and performs no project-scope check. +// RegisteredIntegrationList/Read gate ListRegistrations/DescribeRegistration, which enumerate and read +// any registered integration in the organization — including its configuration — with no project filter. var orgLevelTokenPolicies = []*authz.Policy{ authz.PolicyAPITokenCreate, authz.PolicyAPITokenList, authz.PolicyAPITokenRevoke, + authz.PolicyRegisteredIntegrationAdd, + authz.PolicyRegisteredIntegrationList, + authz.PolicyRegisteredIntegrationRead, +} + +// defaultAuthzPolicies are granted to every token regardless of scope, so each entry must be safe +// for a caller confined to a single project. Org-wide capabilities go in orgLevelTokenPolicies. +var defaultAuthzPolicies = []*authz.Policy{ + // Add permissions to workflow run + authz.PolicyWorkflowRunList, authz.PolicyWorkflowRunRead, + // To read, list and create workflows + authz.PolicyWorkflowRead, authz.PolicyWorkflowList, authz.PolicyWorkflowCreate, + // Add permissions to workflow contract management + authz.PolicyWorkflowContractList, authz.PolicyWorkflowContractRead, authz.PolicyWorkflowContractUpdate, authz.PolicyWorkflowContractCreate, + // to download artifacts and list referrers + authz.PolicyArtifactDownload, authz.PolicyReferrerRead, + authz.PolicyOrganizationRead, + + // to attach integrations + authz.PolicyAvailableIntegrationRead, + authz.PolicyAvailableIntegrationList, + authz.PolicyAttachedIntegrationList, + authz.PolicyAttachedIntegrationAttach, + + // to upload CAS artifacts + authz.PolicyArtifactUpload, } // APIToken is used for unattended access to the control plane API. @@ -101,36 +129,12 @@ type APITokenUseCase struct { func NewAPITokenUseCase(apiTokenRepo APITokenRepo, jwtConfig *APITokenJWTConfig, authzUC *AuthzUseCase, orgUseCase *OrganizationUseCase, auditorUC *AuditorUseCase, logger log.Logger) (*APITokenUseCase, error) { uc := &APITokenUseCase{ - apiTokenRepo: apiTokenRepo, - orgUseCase: orgUseCase, - auditorUC: auditorUC, - logger: servicelogger.ScopedHelper(logger, "biz/APITokenUseCase"), - authz: authzUC, - DefaultAuthzPolicies: []*authz.Policy{ - // Add permissions to workflow run - authz.PolicyWorkflowRunList, authz.PolicyWorkflowRunRead, - // To read, list and create workflows - authz.PolicyWorkflowRead, authz.PolicyWorkflowList, authz.PolicyWorkflowCreate, - // Add permissions to workflow contract management - authz.PolicyWorkflowContractList, authz.PolicyWorkflowContractRead, authz.PolicyWorkflowContractUpdate, authz.PolicyWorkflowContractCreate, - // to download artifacts and list referrers - authz.PolicyArtifactDownload, authz.PolicyReferrerRead, - authz.PolicyOrganizationRead, - // to create robot accounts - authz.PolicyRobotAccountCreate, - - // to attach integrations - authz.PolicyAvailableIntegrationRead, - authz.PolicyAvailableIntegrationList, - authz.PolicyRegisteredIntegrationList, - authz.PolicyRegisteredIntegrationRead, - authz.PolicyRegisteredIntegrationAdd, - authz.PolicyAttachedIntegrationList, - authz.PolicyAttachedIntegrationAttach, - - // to upload CAS artifacts - authz.PolicyArtifactUpload, - }, + apiTokenRepo: apiTokenRepo, + orgUseCase: orgUseCase, + auditorUC: auditorUC, + logger: servicelogger.ScopedHelper(logger, "biz/APITokenUseCase"), + authz: authzUC, + DefaultAuthzPolicies: defaultAuthzPolicies, } // Create the JWT builder for the API token @@ -251,9 +255,9 @@ func (uc *APITokenUseCase) Create(ctx context.Context, name string, description policies = uc.DefaultAuthzPolicies } - // Org-level tokens additionally get project-level API token management policies + // Concat, not append: policies may alias the shared defaultAuthzPolicies slice. if projectID == nil && orgUUID != nil { - policies = append(policies, orgLevelTokenPolicies...) + policies = slices.Concat(policies, orgLevelTokenPolicies) } // NOTE: the expiration time is stored just for reference, it's also encoded in the JWT diff --git a/app/controlplane/pkg/biz/apitoken_authz_test.go b/app/controlplane/pkg/biz/apitoken_authz_test.go new file mode 100644 index 000000000..6aaefff67 --- /dev/null +++ b/app/controlplane/pkg/biz/apitoken_authz_test.go @@ -0,0 +1,52 @@ +// +// Copyright 2026 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. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package biz + +import ( + "testing" + + "github.com/chainloop-dev/chainloop/app/controlplane/pkg/authz" + "github.com/stretchr/testify/assert" +) + +// TestDefaultTokenPoliciesAreHeldByAHumanRole guards against privilege escalation through +// project-scoped tokens: a policy held by no role in RolesMap is reachable for users only via the +// authz middleware's IsAdmin() bypass, so shipping it to every token makes it an org-admin capability +// that any project-scoped token would also get. +func TestDefaultTokenPoliciesAreHeldByAHumanRole(t *testing.T) { + heldByRole := make(map[authz.Policy]struct{}) + for _, policies := range authz.RolesMap { + for _, p := range policies { + heldByRole[*p] = struct{}{} + } + } + + for _, p := range defaultAuthzPolicies { + assert.Containsf(t, heldByRole, *p, + "policy %s:%s is in defaultAuthzPolicies but held by no role in RolesMap; move it to orgLevelTokenPolicies", + p.Resource, p.Action) + } +} + +// Backstops the test above, which stops guarding anything if a project-level role is ever granted one +// of these policies in RolesMap. The two sets must stay disjoint. +func TestOrgLevelPoliciesStayOutOfDefaults(t *testing.T) { + for _, p := range orgLevelTokenPolicies { + assert.NotContainsf(t, defaultAuthzPolicies, p, + "policy %s:%s is org-level-only but also in defaultAuthzPolicies, so project-scoped tokens receive it", + p.Resource, p.Action) + } +} diff --git a/app/controlplane/pkg/biz/biz.go b/app/controlplane/pkg/biz/biz.go index 57e18974f..ab4d6a812 100644 --- a/app/controlplane/pkg/biz/biz.go +++ b/app/controlplane/pkg/biz/biz.go @@ -32,7 +32,7 @@ import ( var ProviderSet = wire.NewSet( NewWorkflowUsecase, NewUserUseCase, - NewRootAccountUseCase, + NewRobotAccountUseCase, NewWorkflowRunUseCase, wire.Struct(new(WorkflowRunUseCaseOpts), "*"), NewOrganizationUseCase, diff --git a/app/controlplane/pkg/biz/robotaccount.go b/app/controlplane/pkg/biz/robotaccount.go index 53c2221d4..893975af4 100644 --- a/app/controlplane/pkg/biz/robotaccount.go +++ b/app/controlplane/pkg/biz/robotaccount.go @@ -19,138 +19,43 @@ import ( "context" "time" - conf "github.com/chainloop-dev/chainloop/app/controlplane/internal/conf/controlplane/config/v1" - "github.com/chainloop-dev/chainloop/app/controlplane/pkg/jwt" - "github.com/chainloop-dev/chainloop/app/controlplane/pkg/jwt/robotaccount" "github.com/chainloop-dev/chainloop/pkg/otelx" - "github.com/go-kratos/kratos/v2/log" "github.com/google/uuid" ) var robotAccountTracer = otelx.Tracer("chainloop-controlplane", "biz/robotaccount") +// RobotAccount is a legacy, workflow-scoped credential superseded by API tokens. Its management API +// (RobotAccountService) was removed (CP-N4): accounts can no longer be created, listed or revoked. +// Existing tokens are still honored during attestation, which is why lookup remains. type RobotAccount struct { - Name string - ID uuid.UUID - JWT string - WorkflowID uuid.UUID - CreatedAt, RevokedAt *time.Time + ID, WorkflowID uuid.UUID + RevokedAt *time.Time } type RobotAccountRepo interface { - Create(ctx context.Context, name string, workflowID uuid.UUID) (*RobotAccount, error) - List(ctx context.Context, workflowID uuid.UUID, includeRevoked bool) ([]*RobotAccount, error) + // FindByID returns (nil, nil) when no account with the given ID exists. FindByID(ctx context.Context, ID uuid.UUID) (*RobotAccount, error) - Revoke(ctx context.Context, orgID, ID uuid.UUID) error } type RobotAccountUseCase struct { robotAccountRepo RobotAccountRepo - workflowRepo WorkflowRepo - authConf *conf.Auth - logger *log.Helper } -func NewRootAccountUseCase(robotAccountRepo RobotAccountRepo, workflowRepo WorkflowRepo, conf *conf.Auth, logger log.Logger) *RobotAccountUseCase { +func NewRobotAccountUseCase(robotAccountRepo RobotAccountRepo) *RobotAccountUseCase { return &RobotAccountUseCase{ robotAccountRepo: robotAccountRepo, - workflowRepo: workflowRepo, - authConf: conf, - logger: log.NewHelper(logger), } } -func (uc *RobotAccountUseCase) Create(ctx context.Context, name string, orgID, workflowID string) (*RobotAccount, error) { - ctx, span := otelx.Start(ctx, robotAccountTracer, "RobotAccountUseCase.Create") - defer span.End() - - workflowUUID, err := uuid.Parse(workflowID) - if err != nil { - return nil, NewErrInvalidUUID(err) - } - - orgUUID, err := uuid.Parse(orgID) - if err != nil { - return nil, NewErrInvalidUUID(err) - } - - // Make sure that the given workflow belongs to the provided org - if wf, err := uc.workflowRepo.GetOrgScoped(ctx, orgUUID, workflowUUID); err != nil { - return nil, err - } else if wf == nil { - return nil, NewErrNotFound("workflow") - } - - res, err := uc.robotAccountRepo.Create(ctx, name, workflowUUID) - if err != nil { - return nil, err - } - - // Create Key - b, err := robotaccount.NewBuilder( - robotaccount.WithIssuer(jwt.DefaultIssuer), - robotaccount.WithKeySecret(uc.authConf.GeneratedJwsHmacSecret), - ) - if err != nil { - return nil, err - } - - jwt, err := b.GenerateJWT(orgID, workflowID, res.ID.String()) - if err != nil { - return nil, err - } - - res.JWT = jwt - return res, nil -} - -func (uc *RobotAccountUseCase) List(ctx context.Context, orgID, workflowID string, includeRevoked bool) ([]*RobotAccount, error) { - ctx, span := otelx.Start(ctx, robotAccountTracer, "RobotAccountUseCase.List") - defer span.End() - - workflowUUID, err := uuid.Parse(workflowID) - if err != nil { - return nil, NewErrInvalidUUID(err) - } - - orgUUID, err := uuid.Parse(orgID) - if err != nil { - return nil, NewErrInvalidUUID(err) - } - // Check that the workflow is from the provided user - if wf, err := uc.workflowRepo.GetOrgScoped(ctx, orgUUID, workflowUUID); err != nil { - return nil, err - } else if wf == nil { - return nil, NewErrNotFound("workflow") - } - - return uc.robotAccountRepo.List(ctx, workflowUUID, includeRevoked) -} - func (uc *RobotAccountUseCase) FindByID(ctx context.Context, id string) (*RobotAccount, error) { ctx, span := otelx.Start(ctx, robotAccountTracer, "RobotAccountUseCase.FindByID") defer span.End() - uuid, err := uuid.Parse(id) + accountUUID, err := uuid.Parse(id) if err != nil { return nil, NewErrInvalidUUID(err) } - return uc.robotAccountRepo.FindByID(ctx, uuid) -} - -func (uc *RobotAccountUseCase) Revoke(ctx context.Context, orgID, id string) error { - ctx, span := otelx.Start(ctx, robotAccountTracer, "RobotAccountUseCase.Revoke") - defer span.End() - - orgUUID, err := uuid.Parse(orgID) - if err != nil { - return NewErrInvalidUUID(err) - } - - uuid, err := uuid.Parse(id) - if err != nil { - return NewErrInvalidUUID(err) - } - return uc.robotAccountRepo.Revoke(ctx, orgUUID, uuid) + return uc.robotAccountRepo.FindByID(ctx, accountUUID) } diff --git a/app/controlplane/pkg/biz/robotaccount_integration_test.go b/app/controlplane/pkg/biz/robotaccount_integration_test.go index c13a4a9ba..833a8b33e 100644 --- a/app/controlplane/pkg/biz/robotaccount_integration_test.go +++ b/app/controlplane/pkg/biz/robotaccount_integration_test.go @@ -1,5 +1,5 @@ // -// Copyright 2024 The Chainloop Authors. +// Copyright 2024-2026 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. @@ -18,6 +18,7 @@ package biz_test import ( "context" "testing" + "time" "github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz" "github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz/testhelpers" @@ -25,30 +26,33 @@ import ( "github.com/stretchr/testify/suite" ) -func (s *robotAccountTestSuite) TestRevoke() { +func (s *robotAccountTestSuite) TestFindByID() { ctx := context.Background() - s.Run("returns an error if org ID format is not valid", func() { - err := s.RobotAccount.Revoke(ctx, "not_valid_uuid", uuid.NewString()) - s.ErrorAs(err, &biz.ErrInvalidUUID{}) - }) - s.Run("returns an error if robot account ID format is not valid", func() { - err := s.RobotAccount.Revoke(ctx, uuid.NewString(), "not_valid_uuid") - s.ErrorAs(err, &biz.ErrInvalidUUID{}) + s.Run("returns an error if the ID format is not valid", func() { + _, err := s.RobotAccount.FindByID(ctx, "not_valid_uuid") + s.True(biz.IsErrInvalidUUID(err)) }) - s.Run("returns a Not Found if robot account cannot be found", func() { - err := s.RobotAccount.Revoke(ctx, s.org.ID, uuid.NewString()) - s.ErrorAs(err, &biz.ErrNotFound{}) + s.Run("returns nil if the robot account cannot be found", func() { + ra, err := s.RobotAccount.FindByID(ctx, uuid.NewString()) + s.NoError(err) + s.Nil(ra) }) - s.Run("revokes the robot account", func() { - err := s.RobotAccount.Revoke(ctx, s.org.ID, s.ra.ID.String()) + s.Run("finds an active robot account", func() { + ra, err := s.RobotAccount.FindByID(ctx, s.raID.String()) s.NoError(err) + s.NotNil(ra) + s.Equal(s.raID, ra.ID) + s.Equal(s.workflowID, ra.WorkflowID) + s.Nil(ra.RevokedAt) + }) - // Reload the robot account - ra, err := s.RobotAccount.FindByID(ctx, s.ra.ID.String()) + s.Run("finds a revoked robot account with its revocation timestamp", func() { + ra, err := s.RobotAccount.FindByID(ctx, s.revokedRaID.String()) s.NoError(err) + s.NotNil(ra) s.NotNil(ra.RevokedAt) }) } @@ -56,11 +60,12 @@ func (s *robotAccountTestSuite) TestRevoke() { // Utility struct to hold the test suite type robotAccountTestSuite struct { testhelpers.UseCasesEachTestSuite - org *biz.Organization - ra *biz.RobotAccount + org *biz.Organization + workflowID uuid.UUID + raID, revokedRaID uuid.UUID } -// // Run the tests +// Run the tests func TestRobotAccountUseCase(t *testing.T) { suite.Run(t, new(robotAccountTestSuite)) } @@ -71,14 +76,24 @@ func (s *robotAccountTestSuite) SetupTest() { s.TestingUseCases = testhelpers.NewTestingUseCases(s.T()) s.org, err = s.Organization.CreateWithRandomName(ctx) - s.NoError(err) + s.Require().NoError(err) wf, err := s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{ Name: "myworkflow", Project: "myproject", OrgID: s.org.ID, }) - s.NoError(err) - s.ra, err = s.RobotAccount.Create(ctx, "myRobotAccount", s.org.ID, wf.ID.String()) - s.NoError(err) + s.Require().NoError(err) + s.workflowID = wf.ID + + // Seeded via ent: management is no longer exposed, but existing accounts must remain + // resolvable for attestation-time authentication. + ra, err := s.Data.DB.RobotAccount.Create().SetName("myRobotAccount").SetWorkflowID(wf.ID).Save(ctx) + s.Require().NoError(err) + s.raID = ra.ID + + revoked, err := s.Data.DB.RobotAccount.Create().SetName("myRevokedRobotAccount"). + SetWorkflowID(wf.ID).SetRevokedAt(time.Now()).Save(ctx) + s.Require().NoError(err) + s.revokedRaID = revoked.ID } diff --git a/app/controlplane/pkg/biz/testhelpers/wire_gen.go b/app/controlplane/pkg/biz/testhelpers/wire_gen.go index 7b0d68699..c80e591de 100644 --- a/app/controlplane/pkg/biz/testhelpers/wire_gen.go +++ b/app/controlplane/pkg/biz/testhelpers/wire_gen.go @@ -139,8 +139,8 @@ func WireTestData(contextContext context.Context, testDatabase *TestDatabase, t UserAccessSyncer: userAccessSyncerUseCase, } userUseCase := biz.NewUserUseCase(newUserUseCaseParams) - robotAccountRepo := data.NewRobotAccountRepo(dataData, logger) - robotAccountUseCase := biz.NewRootAccountUseCase(robotAccountRepo, workflowRepo, auth, logger) + robotAccountRepo := data.NewRobotAccountRepo(dataData) + robotAccountUseCase := biz.NewRobotAccountUseCase(robotAccountRepo) orgInvitationRepo := data.NewOrgInvitation(dataData, logger) orgInvitationUseCase, err := biz.NewOrgInvitationUseCase(orgInvitationRepo, membershipRepo, userRepo, auditorUseCase, groupRepo, projectsRepo, authzUseCase, logger) if err != nil { diff --git a/app/controlplane/pkg/data/robotaccount.go b/app/controlplane/pkg/data/robotaccount.go index f9a3b5de5..2b11868a4 100644 --- a/app/controlplane/pkg/data/robotaccount.go +++ b/app/controlplane/pkg/data/robotaccount.go @@ -17,14 +17,10 @@ package data import ( "context" - "time" "github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz" "github.com/chainloop-dev/chainloop/app/controlplane/pkg/data/ent" - "github.com/chainloop-dev/chainloop/app/controlplane/pkg/data/ent/robotaccount" - "github.com/chainloop-dev/chainloop/app/controlplane/pkg/data/ent/workflow" "github.com/chainloop-dev/chainloop/pkg/otelx" - "github.com/go-kratos/kratos/v2/log" "github.com/google/uuid" ) @@ -32,50 +28,14 @@ var robotAccountRepoTracer = otelx.Tracer("chainloop-controlplane", "data/robota type RobotAccountRepo struct { data *Data - log *log.Helper } -func NewRobotAccountRepo(data *Data, logger log.Logger) biz.RobotAccountRepo { +func NewRobotAccountRepo(data *Data) biz.RobotAccountRepo { return &RobotAccountRepo{ data: data, - log: log.NewHelper(logger), } } -func (r *RobotAccountRepo) Create(ctx context.Context, name string, workflowID uuid.UUID) (*biz.RobotAccount, error) { - ctx, span := otelx.Start(ctx, robotAccountRepoTracer, "RobotAccountRepo.Create") - defer span.End() - - p, err := r.data.DB.RobotAccount.Create().SetName(name).SetWorkflowID(workflowID).Save(ctx) - if err != nil { - return nil, err - } - - return entRaToBizRa(p, workflowID), nil -} - -func (r *RobotAccountRepo) List(ctx context.Context, workflowID uuid.UUID, includeRevoked bool) ([]*biz.RobotAccount, error) { - ctx, span := otelx.Start(ctx, robotAccountRepoTracer, "RobotAccountRepo.List") - defer span.End() - - raQuery := r.data.DB.Workflow.Query().Where(workflow.ID(workflowID)).QueryRobotaccounts() - if !includeRevoked { - raQuery = raQuery.Where(robotaccount.RevokedAtIsNil()) - } - - robotAccounts, err := raQuery.All(ctx) - if err != nil { - return nil, err - } - - result := make([]*biz.RobotAccount, 0, len(robotAccounts)) - for _, a := range robotAccounts { - result = append(result, entRaToBizRa(a, workflowID)) - } - - return result, nil -} - func (r *RobotAccountRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.RobotAccount, error) { ctx, span := otelx.Start(ctx, robotAccountRepoTracer, "RobotAccountRepo.FindByID") defer span.End() @@ -92,29 +52,5 @@ func (r *RobotAccountRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.Rob return nil, err } - return entRaToBizRa(p, workflowID), nil -} - -func (r *RobotAccountRepo) Revoke(ctx context.Context, orgID, id uuid.UUID) error { - ctx, span := otelx.Start(ctx, robotAccountRepoTracer, "RobotAccountRepo.Revoke") - defer span.End() - - // Find a non-revoked robot account in the scope of the organization - acc, err := orgScopedQuery(r.data.DB, orgID). - QueryWorkflows(). - QueryRobotaccounts().Where(robotaccount.ID(id)).Where(robotaccount.RevokedAtIsNil()). - First(ctx) - if err != nil { - if ent.IsNotFound(err) { - return biz.NewErrNotFound("robot account") - } - return err - } - - // and update it - return acc.Update().SetRevokedAt(time.Now()).Exec(ctx) -} - -func entRaToBizRa(a *ent.RobotAccount, workflowID uuid.UUID) *biz.RobotAccount { - return &biz.RobotAccount{Name: a.Name, ID: a.ID, CreatedAt: toTimePtr(a.CreatedAt), WorkflowID: workflowID, RevokedAt: toTimePtr(a.RevokedAt)} + return &biz.RobotAccount{ID: p.ID, WorkflowID: workflowID, RevokedAt: toTimePtr(p.RevokedAt)}, nil } diff --git a/buf.yaml b/buf.yaml index babfd6d57..389630a66 100644 --- a/buf.yaml +++ b/buf.yaml @@ -61,6 +61,12 @@ modules: - app/controlplane/api/controlplane/v1/workflow_run.proto - app/controlplane/api/controlplane/v1/workflow.proto - app/controlplane/api/controlplane/v1/referrer.proto + # The RobotAccountService was removed entirely (CP-N4): robot accounts are superseded by + # workflow-scoped API tokens, creation had no caller after 2024, and the policy gating it + # was grantable to API tokens. Existing robot-account JWTs are still honored at attestation + # time, but the management API (Create/List/Revoke) is gone. + FILE_NO_DELETE: + - app/controlplane/api/controlplane/v1/robot_accounts.proto RPC_NO_DELETE: - app/controlplane/api/controlplane/v1/referrer.proto MESSAGE_NO_DELETE: