From 82291659a84f4282b8d6c27b8e06c4357fbc5646 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Mon, 13 Jun 2022 14:50:46 -0600 Subject: [PATCH] feat: [CDS-37432]: repo creds (#22) * feat: [CDS-37807]: Updating List call to return complete object (#15) * feat: [CDS-37486]: remove check for project in create repo flow (#16) * fix: [CDS-38108]: Supporting connection status for repo creds (#21) * harness gen --- assets/swagger.json | 26 ++ hack/generate-proto.sh | 2 +- pkg/apiclient/repository/repository.pb.go | 277 ++++++++++++++++------ server/repocreds/repocreds.go | 14 +- server/repository/repository.go | 74 ++++-- server/repository/repository.proto | 6 +- 6 files changed, 292 insertions(+), 107 deletions(-) diff --git a/assets/swagger.json b/assets/swagger.json index 7bec9f9b09df7..8d2f51d8a4048 100644 --- a/assets/swagger.json +++ b/assets/swagger.json @@ -2492,6 +2492,16 @@ "schema": { "$ref": "#/definitions/v1alpha1RepoCreds" } + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "The set of field mask paths.", + "name": "updateMask.paths", + "in": "query" } ], "responses": { @@ -2982,6 +2992,22 @@ "description": "Reference between project and repository that allow you automatically to be added as item inside SourceRepos project entity.", "name": "project", "in": "query" + }, + { + "type": "string", + "description": "Connection type of the repository.", + "name": "connectionType", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "The set of field mask paths.", + "name": "updateMask.paths", + "in": "query" } ], "responses": { diff --git a/hack/generate-proto.sh b/hack/generate-proto.sh index 70c232a3132ed..5d00b5d1761ca 100755 --- a/hack/generate-proto.sh +++ b/hack/generate-proto.sh @@ -123,7 +123,7 @@ clean_swagger() { } echo "If additional types are added, the number of expected collisions may need to be increased" -EXPECTED_COLLISION_COUNT=65 +EXPECTED_COLLISION_COUNT=66 collect_swagger server ${EXPECTED_COLLISION_COUNT} clean_swagger server clean_swagger reposerver diff --git a/pkg/apiclient/repository/repository.pb.go b/pkg/apiclient/repository/repository.pb.go index 646291cd0b345..6ec188de77f0c 100644 --- a/pkg/apiclient/repository/repository.pb.go +++ b/pkg/apiclient/repository/repository.pb.go @@ -367,10 +367,14 @@ type RepoAccessQuery struct { // HTTP/HTTPS proxy to access the repository Proxy string `protobuf:"bytes,16,opt,name=proxy,proto3" json:"proxy,omitempty"` // Reference between project and repository that allow you automatically to be added as item inside SourceRepos project entity - Project string `protobuf:"bytes,17,opt,name=project,proto3" json:"project,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Project string `protobuf:"bytes,17,opt,name=project,proto3" json:"project,omitempty"` + // Connection type of the repository + ConnectionType string `protobuf:"bytes,18,opt,name=connectionType,proto3" json:"connectionType,omitempty"` + // A list of what fields have been updated in order to make an access request to the repo + UpdateMask *types.FieldMask `protobuf:"bytes,19,opt,name=updateMask,proto3" json:"updateMask,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *RepoAccessQuery) Reset() { *m = RepoAccessQuery{} } @@ -518,6 +522,20 @@ func (m *RepoAccessQuery) GetProject() string { return "" } +func (m *RepoAccessQuery) GetConnectionType() string { + if m != nil { + return m.ConnectionType + } + return "" +} + +func (m *RepoAccessQuery) GetUpdateMask() *types.FieldMask { + if m != nil { + return m.UpdateMask + } + return nil +} + type RepoResponse struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -696,81 +714,83 @@ func init() { } var fileDescriptor_8d38260443475705 = []byte{ - // 1173 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xd7, 0x26, 0xa9, 0x9b, 0x8c, 0x9b, 0xd4, 0x99, 0x84, 0xb2, 0xb8, 0x69, 0x6a, 0x6d, 0x4b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0x93, 0x03, 0xd5, 0xbe, - 0x85, 0x4a, 0x3d, 0xa2, 0x7d, 0x10, 0x8c, 0xc6, 0x02, 0xf0, 0x2b, 0xe8, 0x42, 0x28, 0xa1, 0x25, - 0x6c, 0xab, 0x32, 0xb9, 0x52, 0xac, 0x2e, 0xb8, 0xb9, 0xeb, 0x49, 0xa8, 0xf1, 0x8d, 0x87, 0xb3, - 0x89, 0x66, 0xd4, 0xe7, 0xa3, 0xef, 0xc8, 0x41, 0x97, 0xea, 0x54, 0x41, 0x85, 0x3a, 0x07, 0x61, - 0x68, 0x9b, 0xf6, 0xfb, 0x74, 0xce, 0x6f, 0x53, 0xe8, 0xb2, 0x06, 0x11, 0x04, 0x20, 0xc6, 0xdf, - 0x77, 0x5b, 0x00, 0x8f, 0xb3, 0x32, 0x53, 0x59, 0xd9, 0x18, 0x11, 0xe2, 0x33, 0xca, 0x6b, 0x49, - 0x95, 0xa9, 0x8c, 0x6f, 0xa2, 0x59, 0x21, 0x9a, 0x0f, 0x79, 0xd8, 0x21, 0x12, 0xde, 0x85, 0x6e, - 0x72, 0xe9, 0xfd, 0x4a, 0x15, 0x21, 0x8c, 0x05, 0x04, 0x6d, 0x0e, 0xf6, 0x05, 0x8d, 0x32, 0x95, - 0xf1, 0x6d, 0x34, 0x2f, 0x23, 0xb1, 0x19, 0x85, 0x10, 0xcb, 0x4d, 0xe0, 0x72, 0x8b, 0x48, 0x62, - 0x17, 0x74, 0x94, 0x41, 0x03, 0x5e, 0x45, 0xa5, 0x3e, 0xa5, 0x4a, 0x79, 0x51, 0x3b, 0x0f, 0xe8, - 0xd3, 0x16, 0x9b, 0xe9, 0x6f, 0x31, 0x5d, 0x23, 0x32, 0x3a, 0x5d, 0xdf, 0x12, 0x9a, 0x81, 0x98, - 0x1c, 0x44, 0xb0, 0x17, 0x84, 0x76, 0x51, 0xc3, 0xcb, 0x14, 0xf8, 0x0e, 0x5a, 0x30, 0x9d, 0xb5, - 0xa1, 0x6e, 0x36, 0xad,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 0xbc, 0xb7, 0xfd, 0xfb, 0xd1, 0xb2, 0xf5, 0xc7, 0xd1, - 0xb2, 0xf5, 0xd7, 0xd1, 0xb2, 0xf5, 0xd1, 0x1b, 0xa7, 0xfb, 0xeb, 0x16, 0xe8, 0x5f, 0x9c, 0xb9, - 0x3f, 0x59, 0x07, 0x05, 0xbd, 0xe7, 0x5f, 0xfb, 0x37, 0x00, 0x00, 0xff, 0xff, 0xca, 0x04, 0xfc, - 0xb9, 0xa6, 0x0e, 0x00, 0x00, + // 1201 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xcf, 0x6f, 0x1b, 0xc5, + 0x17, 0xd7, 0x26, 0x8d, 0x9b, 0x4c, 0x9a, 0xd4, 0x99, 0xe4, 0xdb, 0xef, 0xe2, 0xa6, 0xa9, 0xb5, + 0x2d, 0x51, 0x88, 0xca, 0x6e, 0x63, 0x84, 0xa8, 0x82, 0x40, 0x4a, 0x93, 0xd0, 0x46, 0x04, 0x52, + 0xb6, 0x84, 0x03, 0x02, 0x55, 0x93, 0xf5, 0xb3, 0xbd, 0xcd, 0x7a, 0x67, 0x98, 0x19, 0x1b, 0xac, + 0xaa, 0x17, 0x4e, 0x48, 0x70, 0x41, 0x08, 0x89, 0x1b, 0x42, 0x42, 0xe2, 0x80, 0xb8, 0xf3, 0x27, + 0x70, 0x44, 0xe2, 0x1f, 0x40, 0x11, 0x7f, 0x07, 0x42, 0x33, 0xb3, 0xde, 0x5d, 0xc7, 0x3f, 0x92, + 0x88, 0x90, 0xdb, 0xbc, 0x1f, 0xfb, 0xde, 0xe7, 0x7d, 0xe6, 0xcd, 0x9b, 0x59, 0xe4, 0x08, 0xe0, + 0x6d, 0xe0, 0x1e, 0x07, 0x46, 0x45, 0x28, 0x29, 0xef, 0xe4, 0x96, 0x2e, 0xe3, 0x54, 0x52, 0x8c, + 0x32, 0x4d, 0x69, 0xa1, 0x4e, 0xeb, 0x54, 0xab, 0x3d, 0xb5, 0x32, 0x1e, 0xa5, 0xc5, 0x3a, 0xa5, + 0xf5, 0x08, 0x3c, 0xc2, 0x42, 0x8f, 0xc4, 0x31, 0x95, 0x44, 0x86, 0x34, 0x16, 0x89, 0xb5, 0x9c, + 0x58, 0xb5, 0x74, 0xd0, 0xaa, 0x79, 0xb5, 0x10, 0xa2, 0xea, 0x93, 0x26, 0x11, 0x87, 0x89, 0x87, + 0x73, 0x78, 0x4f, 0xb8, 0x21, 0xd5, 0xdf, 0x07, 0x94, 0x83, 0xd7, 0x5e, 0xf3, 0xea, 0x10, 0x03, + 0x27, 0x12, 0xaa, 0x89, 0xcf, 0x6e, 0x3d, 0x94, 0x8d, 0xd6, 0x81, 0x1b, 0xd0, 0xa6, 0x47, 0xb8, + 0x06, 0xf1, 0x54, 0x2f, 0x5e, 0x0e, 0xaa, 0x5e, 0xbb, 0xe2, 0xb1, 0xc3, 0xba, 0xfa, 0x5e, 0x78, + 0x84, 0xb1, 0x28, 0x0c, 0x34, 0x02, 0xaf, 0xbd, 0x46, 0x22, 0xd6, 0x20, 0xfd, 0xd1, 0xb6, 0x4f, + 0x88, 0xa6, 0x4b, 0x3e, 0x91, 0x1a, 0xa7, 0x83, 0x66, 0x7c, 0x60, 0x74, 0x83, 0x31, 0xf1, 0x5e, + 0x0b, 0x78, 0x07, 0x63, 0x74, 0x49, 0x39, 0xd9, 0x56, 0xd9, 0x5a, 0x99, 0xf2, 0xf5, 0x1a, 0x97, + 0xd0, 0x24, 0x87, 0x76, 0x28, 0x42, 0x1a, 0xdb, 0x63, 0x5a, 0x9f, 0xca, 0xd8, 0x46, 0x97, 0x09, + 0x63, 0xef, 0x92, 0x26, 0xd8, 0xe3, 0xda, 0xd4, 0x15, 0xf1, 0x12, 0x42, 0x84, 0xb1, 0x47, 0x9c, + 0x3e, 0x85, 0x40, 0xda, 0x97, 0xb4, 0x31, 0xa7, 0x71, 0xd6, 0xd0, 0xe5, 0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89, 0x7f, 0xb4, 0x50, 0xc1, 0x4c, 0xe3, 0x7e, 0x5c, + 0x3d, 0x53, 0xfa, 0x1c, 0x71, 0xad, 0x99, 0x0d, 0x2e, 0x8d, 0x68, 0x73, 0x0d, 0xe5, 0x79, 0x46, + 0xe4, 0xcf, 0x16, 0x2a, 0x76, 0xe1, 0x0c, 0x27, 0xf2, 0xbf, 0x02, 0xec, 0x9e, 0x0d, 0x30, 0x26, + 0xa8, 0xb0, 0x05, 0x11, 0x48, 0x18, 0x76, 0x04, 0xec, 0xe3, 0xea, 0xb4, 0xf9, 0x97, 0xcd, 0x8c, + 0x5d, 0x1d, 0x35, 0x63, 0x15, 0x21, 0x0d, 0x54, 0x34, 0x29, 0x72, 0x7c, 0x9c, 0x39, 0xd9, 0xad, + 0x53, 0x24, 0xc3, 0xcf, 0xd0, 0xec, 0x07, 0x24, 0x0a, 0x15, 0xb3, 0xe6, 0x51, 0x8c, 0xaf, 0xf7, + 0x4d, 0x92, 0xec, 0xb1, 0x3c, 0x22, 0x5b, 0x45, 0x67, 0xbb, 0xe3, 0xdc, 0x1e, 0x75, 0xae, 0xdb, + 0x49, 0x2a, 0xc3, 0xe4, 0xfd, 0xed, 0xdf, 0x8e, 0x96, 0xac, 0xdf, 0x8f, 0x96, 0xac, 0x3f, 0x8f, + 0x96, 0xac, 0x0f, 0x5f, 0x3b, 0xdd, 0xef, 0x61, 0xa0, 0x5f, 0xb5, 0xb9, 0x1f, 0xb9, 0x83, 0x82, + 0xbe, 0xe7, 0x5f, 0xf9, 0x27, 0x00, 0x00, 0xff, 0xff, 0xed, 0x1b, 0x8a, 0x15, 0x0a, 0x0f, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1609,6 +1629,29 @@ func (m *RepoAccessQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } + if m.UpdateMask != nil { + { + size, err := m.UpdateMask.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRepository(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x9a + } + if len(m.ConnectionType) > 0 { + i -= len(m.ConnectionType) + copy(dAtA[i:], m.ConnectionType) + i = encodeVarintRepository(dAtA, i, uint64(len(m.ConnectionType))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x92 + } if len(m.Project) > 0 { i -= len(m.Project) copy(dAtA[i:], m.Project) @@ -2053,6 +2096,14 @@ func (m *RepoAccessQuery) Size() (n int) { if l > 0 { n += 2 + l + sovRepository(uint64(l)) } + l = len(m.ConnectionType) + if l > 0 { + n += 2 + l + sovRepository(uint64(l)) + } + if m.UpdateMask != nil { + l = m.UpdateMask.Size() + n += 2 + l + sovRepository(uint64(l)) + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -3243,6 +3294,74 @@ func (m *RepoAccessQuery) Unmarshal(dAtA []byte) error { } m.Project = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 18: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRepository + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthRepository + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRepository + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectionType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 19: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateMask", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRepository + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRepository + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRepository + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpdateMask == nil { + m.UpdateMask = &types.FieldMask{} + } + if err := m.UpdateMask.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipRepository(dAtA[iNdEx:]) diff --git a/server/repocreds/repocreds.go b/server/repocreds/repocreds.go index dd95b7e1aa4c4..4474ce91b1655 100644 --- a/server/repocreds/repocreds.go +++ b/server/repocreds/repocreds.go @@ -56,8 +56,18 @@ func (s *Server) ListRepositoryCredentials(ctx context.Context, q *repocredspkg. } if repo != nil { items = append(items, appsv1.RepoCreds{ - URL: url, - Username: repo.Username, + URL: url, + Username: repo.Username, + Password: repo.Password, + SSHPrivateKey: repo.SSHPrivateKey, + TLSClientCertData: repo.TLSClientCertData, + TLSClientCertKey: repo.TLSClientCertKey, + GithubAppPrivateKey: repo.GithubAppPrivateKey, + GithubAppId: repo.GithubAppId, + GithubAppInstallationId: repo.GithubAppInstallationId, + GitHubAppEnterpriseBaseURL: repo.GitHubAppEnterpriseBaseURL, + EnableOCI: repo.EnableOCI, + Type: repo.Type, }) } } diff --git a/server/repository/repository.go b/server/repository/repository.go index 63e20c2be6399..9132c29a691bf 100644 --- a/server/repository/repository.go +++ b/server/repository/repository.go @@ -370,24 +370,21 @@ func (s *Server) CreateRepository(ctx context.Context, q *repositorypkg.RepoCrea return nil, err } - var repo *appsv1.Repository var err error - // check we can connect to the repo, copying any existing creds (not supported for project scoped repositories) - if q.Repo.Project == "" { - repo := q.Repo.DeepCopy() - if !repo.HasCredentials() { - creds, err := s.db.GetRepositoryCredentials(ctx, repo.Repo) - if err != nil { - return nil, err - } - repo.CopyCredentialsFrom(creds) - } - - err = s.testRepo(ctx, repo) + // check we can connect to the repo, copying any existing creds + repo := q.Repo.DeepCopy() + if !repo.HasCredentials() { + creds, err := s.db.GetRepositoryCredentials(ctx, repo.Repo) if err != nil { return nil, err } + repo.CopyCredentialsFrom(creds) + } + + err = s.testRepo(ctx, repo) + if err != nil { + return nil, err } r := q.Repo @@ -497,7 +494,6 @@ func (s *Server) ValidateAccess(ctx context.Context, q *repositorypkg.RepoAccess if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceRepositories, rbacpolicy.ActionCreate, createRBACObject(q.Project, q.Repo)); err != nil { return nil, err } - repo := &appsv1.Repository{ Repo: q.Repo, Type: q.Type, @@ -514,20 +510,33 @@ func (s *Server) ValidateAccess(ctx context.Context, q *repositorypkg.RepoAccess GithubAppInstallationId: q.GithubAppInstallationID, GitHubAppEnterpriseBaseURL: q.GithubAppEnterpriseBaseUrl, Proxy: q.Proxy, + ConnectionType: appsv1.ConnectionType(q.ConnectionType), } - // If repo does not have credentials, check if there are credentials stored - // for it and if yes, copy them - if !repo.HasCredentials() { - repoCreds, err := s.db.GetRepositoryCredentials(ctx, q.Repo) - if err != nil { - return nil, err - } - if repoCreds != nil { - repo.CopyCredentialsFrom(repoCreds) + // Get any existing credentials for the repo URL + existingRepoCreds, err := s.db.GetRepositoryCredentials(ctx, q.Repo) + if err != nil { + return nil, err + } + // Check for update mask list to identify which attributes have been updated + if q.UpdateMask != nil && len(q.UpdateMask.Paths) != 0 { + // adding repo to the path here because we need to test using the repo URL and not the template URL + q.UpdateMask.Paths = append(q.UpdateMask.Paths, "repo") + // creating a dummy repo object from the template + repoFromExistingCreds := createRepoFromCredentials(existingRepoCreds) + // copying over only select attributes from repo to repoFromExistingCreds which are present in the mask paths + grpc.Mask(protov1.MessageV2(repoFromExistingCreds), protov1.MessageV2(repo), fmutils.NestedMaskFromPaths(q.UpdateMask.Paths)) + repo = repoFromExistingCreds + } + + // If repo does not have credentials, check if there are credentials stored for it and if yes, copy them + // Repo with connection type HTTPS_ANONYMOUS do not have any credentials + if !repo.HasCredentials() && repo.ConnectionType != appsv1.HTTPS_ANONYMOUS { + if existingRepoCreds != nil { + repo.CopyCredentialsFrom(existingRepoCreds) } } - err := s.testRepo(ctx, repo) + err = s.testRepo(ctx, repo) if err != nil { return nil, err } @@ -597,3 +606,20 @@ func maskSecrets(repo *appsv1.Repository) { repo.Password = SecretMask } } + +func createRepoFromCredentials(repoCreds *appsv1.RepoCreds) *appsv1.Repository { + return &appsv1.Repository{ + Repo: repoCreds.URL, + Type: repoCreds.Type, + Username: repoCreds.Username, + Password: repoCreds.Password, + SSHPrivateKey: repoCreds.SSHPrivateKey, + TLSClientCertData: repoCreds.TLSClientCertData, + TLSClientCertKey: repoCreds.TLSClientCertKey, + EnableOCI: repoCreds.EnableOCI, + GithubAppPrivateKey: repoCreds.GithubAppPrivateKey, + GithubAppId: repoCreds.GithubAppId, + GithubAppInstallationId: repoCreds.GithubAppInstallationId, + GitHubAppEnterpriseBaseURL: repoCreds.GitHubAppEnterpriseBaseURL, + } +} diff --git a/server/repository/repository.proto b/server/repository/repository.proto index d461db18f797d..5b650a76d3650 100644 --- a/server/repository/repository.proto +++ b/server/repository/repository.proto @@ -81,7 +81,11 @@ message RepoAccessQuery { // HTTP/HTTPS proxy to access the repository string proxy = 16; // Reference between project and repository that allow you automatically to be added as item inside SourceRepos project entity - string project = 17; + string project = 17; + // Connection type of the repository + string connectionType = 18; + // A list of what fields have been updated in order to make an access request to the repo + google.protobuf.FieldMask updateMask = 19; } message RepoResponse {}