diff --git a/services/integration/api/credentials/api.go b/services/integration/api/credentials/api.go index f85930b58..236137b58 100644 --- a/services/integration/api/credentials/api.go +++ b/services/integration/api/credentials/api.go @@ -166,7 +166,23 @@ func (h API) UpdateCredential(c echo.Context) error { h.logger.Error("failed to encrypt secret", zap.Error(err)) return echo.NewHTTPError(http.StatusInternalServerError, "failed to encrypt config") } - err = h.database.UpdateCredential(credentialId, secret) + masked := make(map[string]any) + for key, value := range req.Credentials { + strValue, ok := value.(string) // Ensure the value is a string + if !ok { + // If it's not a string, just skip masking + masked[key] = "not available" + continue + } + + // Get the last 5 characters, or the full string if it's shorter + if len(strValue) > 5 { + masked[key] = "*****" + strValue[len(strValue)-5:] + } else { + masked[key] = "*****" + strValue + } + } + err = h.database.UpdateCredential(credentialId, secret,masked,req.Description) if err != nil { h.logger.Error("failed to update credential", zap.Error(err)) return echo.NewHTTPError(http.StatusInternalServerError, "failed to update credential") diff --git a/services/integration/api/integrations/api.go b/services/integration/api/integrations/api.go index ac6b261e7..2badc867a 100644 --- a/services/integration/api/integrations/api.go +++ b/services/integration/api/integrations/api.go @@ -199,17 +199,45 @@ func (h API) DiscoverIntegrations(c echo.Context) error { h.logger.Error("failed to encrypt secret", zap.Error(err)) return echo.NewHTTPError(http.StatusInternalServerError, "failed to encrypt config") } + masked := make(map[string]any) + for key, value := range req.Credentials { + strValue, ok := value.(string) // Ensure the value is a string + if !ok { + // If it's not a string, just skip masking + masked[key] = "not available" + continue + } + + // Get the last 5 characters, or the full string if it's shorter + if len(strValue) > 5 { + masked[key] = "*****" + strValue[len(strValue)-5:] + } else { + masked[key] = "*****" + strValue + } + } + // convert to jsonb + maskedSecreyJsonData, err := json.Marshal(masked) + maskedSecretJsonb := pgtype.JSONB{} + err = maskedSecretJsonb.Set(maskedSecreyJsonData) + if err != nil { + h.logger.Error("failed to set masked secret", zap.Error(err)) + return echo.NewHTTPError(http.StatusInternalServerError, "failed to set masked secret") + } + credentialID := uuid.New() metadata := make(map[string]string) metadataJsonData, err := json.Marshal(metadata) credentialMetadataJsonb := pgtype.JSONB{} + err = credentialMetadataJsonb.Set(metadataJsonData) err = h.database.CreateCredential(&models2.Credential{ ID: credentialID, IntegrationType: req.IntegrationType, CredentialType: req.CredentialType, + Description: req.Description, + MaskedSecret: maskedSecretJsonb, Secret: secret, Metadata: credentialMetadataJsonb, }) @@ -338,6 +366,8 @@ func (h API) AddIntegrations(c echo.Context) error { for _, i := range integrationTypeIntegrations { integrationTypeIntegrationsMap[i.ProviderID] = true } + // + var count = 0 for _, i := range integrations { if _, ok := providerIDs[i.ProviderID]; !ok { @@ -387,7 +417,11 @@ func (h API) AddIntegrations(c echo.Context) error { h.logger.Error("failed to create integration", zap.Error(err)) return echo.NewHTTPError(http.StatusInternalServerError, "failed to create integration") } + count++ + // update credentials } + err= h.database.UpdateCredentialIntegrationCount(req.CredentialID,count) + return c.NoContent(http.StatusOK) } @@ -789,12 +823,29 @@ func (h API) Update(c echo.Context) error { h.logger.Error("failed to encrypt secret", zap.Error(err)) return echo.NewHTTPError(http.StatusInternalServerError, "failed to encrypt config") } + masked := make(map[string]any) + for key, value := range req.Credentials { + strValue, ok := value.(string) // Ensure the value is a string + if !ok { + // If it's not a string, just skip masking + masked[key] = "not available" + continue + } + + // Get the last 5 characters, or the full string if it's shorter + if len(strValue) > 5 { + masked[key] = "*****" + strValue[len(strValue)-5:] + } else { + masked[key] = "*****" + strValue + } + } - err = h.database.UpdateCredential(integration.CredentialID.String(), secret) + err = h.database.UpdateCredential(integration.CredentialID.String(), secret,masked,req.Description) if err != nil { h.logger.Error("failed to update credential", zap.Error(err)) return echo.NewHTTPError(http.StatusInternalServerError, "failed to update credential") } + return c.NoContent(http.StatusOK) } diff --git a/services/integration/api/models/credential.go b/services/integration/api/models/credential.go index 6798c1dff..8047b6d3d 100644 --- a/services/integration/api/models/credential.go +++ b/services/integration/api/models/credential.go @@ -11,6 +11,9 @@ type Credential struct { IntegrationType integration.Type `json:"integration_type"` CredentialType string `json:"credential_type"` Metadata map[string]string `json:"metadata"` + IntegrationCount int `json:"integration_count"` + MaskedSecret map[string]string `json:"masked_secret"` + Description string `json:"description"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } @@ -22,6 +25,7 @@ type ListCredentialsRequest struct { type UpdateCredentialRequest struct { Credentials map[string]any `json:"credentials"` + Description string `json:"description"` } type ListCredentialsResponse struct { diff --git a/services/integration/api/models/integration.go b/services/integration/api/models/integration.go index 61ebaf8b4..de80e5aa3 100644 --- a/services/integration/api/models/integration.go +++ b/services/integration/api/models/integration.go @@ -17,6 +17,7 @@ const ( type DiscoverIntegrationRequest struct { IntegrationType integration.Type `json:"integration_type"` CredentialType string `json:"credential_type"` + Description string `json:"description"` CredentialID *string `json:"credential_id"` Credentials map[string]any `json:"credentials"` } @@ -34,6 +35,7 @@ type AddIntegrationsRequest struct { type UpdateRequest struct { Credentials map[string]any `json:"credentials"` + Description string `json:"description"` } type Integration struct { diff --git a/services/integration/db/credential.go b/services/integration/db/credential.go index 7a6aae677..4df97798b 100644 --- a/services/integration/db/credential.go +++ b/services/integration/db/credential.go @@ -1,7 +1,10 @@ package db import ( + "encoding/json" "fmt" + + "github.com/jackc/pgtype" "github.com/opengovern/opencomply/services/integration/models" "gorm.io/gorm/clause" ) @@ -83,10 +86,16 @@ func (db Database) GetCredential(id string) (*models.Credential, error) { return &credential, nil } -func (db Database) UpdateCredential(id string, secret string) error { +func (db Database) UpdateCredential(id string, secret string,masked map[string]any,description string) error { + maskedSecreyJsonData, err := json.Marshal(masked) + maskedSecretJsonb := pgtype.JSONB{} + err = maskedSecretJsonb.Set(maskedSecreyJsonData) + if err != nil { + return err + } tx := db.Orm. Model(&models.Credential{}). - Where("id = ?", id).Update("secret", secret) + Where("id = ?", id).Update("secret", secret).Update("masked_secret", maskedSecretJsonb).Update("description", description) if tx.Error != nil { return tx.Error @@ -94,3 +103,17 @@ func (db Database) UpdateCredential(id string, secret string) error { return nil } + +// update descripion and integration count +func (db Database) UpdateCredentialIntegrationCount(id string, count int) error { + tx:= db.Orm. + Model(&models.Credential{}). + Where("id = ?", id). + Update("integration_count", count) + + if tx.Error != nil { + return tx.Error + } + return nil +} + diff --git a/services/integration/integration-type/ui-specs/aws-cloud-account.json b/services/integration/integration-type/ui-specs/aws-cloud-account.json index 771a7fe5c..ddd9dbc0b 100644 --- a/services/integration/integration-type/ui-specs/aws-cloud-account.json +++ b/services/integration/integration-type/ui-specs/aws-cloud-account.json @@ -229,17 +229,19 @@ "sortable": true, "filterable": true, "info": "ID.", - "detail": true, + "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was created.", + "show": true, + "info": "Description of the credential.", "detail": true, "detail_order": 2 }, @@ -250,23 +252,35 @@ "order": 3, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was last updated.", - "detail": true, + "show": true, + "info": "Timestamp when the credential was last updated.", + "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, - "info": "Type of Credential used (Single Account/Multi-Account).", + "order": 5, + "show": false, + "info": "Type of Credential used (Classic PAT).", "valueMap": { - "aws_single_account": "Single Account", - "aws_multi_account": "Multi-Account" + "classic_pat": "Classic Personal Access Token (PAT)" }, "detail": true, - "detail_order": 3 + "detail_order": 5 } ] }, diff --git a/services/integration/integration-type/ui-specs/azure-subscription.json b/services/integration/integration-type/ui-specs/azure-subscription.json index 4aa2b94cf..a46c41aa3 100644 --- a/services/integration/integration-type/ui-specs/azure-subscription.json +++ b/services/integration/integration-type/ui-specs/azure-subscription.json @@ -252,17 +252,19 @@ "sortable": true, "filterable": true, "info": "ID.", - "detail": true, + "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was created.", + "show": true, + "info": "Description of the credential.", "detail": true, "detail_order": 2 }, @@ -273,23 +275,35 @@ "order": 3, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was last updated.", - "detail": true, + "show": true, + "info": "Timestamp when the credential was last updated.", + "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, - "info": "Type of Credential used (SPN Password Based/SPN Certificate).", + "order": 5, + "show": false, + "info": "Type of Credential used (Classic PAT).", "valueMap": { - "spn_password_based": "SPN Password Based", - "spn_certificate": "SPN Certificate" + "classic_pat": "Classic Personal Access Token (PAT)" }, - "detail": false, - "detail_order": 4 + "detail": true, + "detail_order": 5 } ] }, diff --git a/services/integration/integration-type/ui-specs/cloudflare-account.json b/services/integration/integration-type/ui-specs/cloudflare-account.json index c5c68423f..74a5e8d1a 100644 --- a/services/integration/integration-type/ui-specs/cloudflare-account.json +++ b/services/integration/integration-type/ui-specs/cloudflare-account.json @@ -131,17 +131,19 @@ "filterable": true, "info": "ID.", "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the credential was created.", - "detail": false, + "show": true, + "info": "Description of the credential.", + "detail": true, "detail_order": 2 }, { @@ -151,22 +153,35 @@ "order": 3, "sortable": true, "filterable": true, + "show": true, "info": "Timestamp when the credential was last updated.", "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, - "info": "Type of Credential used (API Token).", + "order": 5, + "show": false, + "info": "Type of Credential used (Classic PAT).", "valueMap": { - "api_token": "API Token" + "classic_pat": "Classic Personal Access Token (PAT)" }, - "detail": false, - "detail_order": 4 + "detail": true, + "detail_order": 5 } ] }, diff --git a/services/integration/integration-type/ui-specs/cohereai-project.json b/services/integration/integration-type/ui-specs/cohereai-project.json index 4fc045454..0fb725e3c 100644 --- a/services/integration/integration-type/ui-specs/cohereai-project.json +++ b/services/integration/integration-type/ui-specs/cohereai-project.json @@ -60,17 +60,19 @@ "sortable": true, "filterable": true, "info": "ID.", - "detail": true, + "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was created.", + "show": true, + "info": "Description of the credential.", "detail": true, "detail_order": 2 }, @@ -81,23 +83,35 @@ "order": 3, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was last updated.", - "detail": true, + "show": true, + "info": "Timestamp when the credential was last updated.", + "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, - "info": "Type of Credential used (Single Account/Multi-Account).", + "order": 5, + "show": false, + "info": "Type of Credential used (Classic PAT).", "valueMap": { - "aws_single_account": "Single Account", - "aws_multi_account": "Multi-Account" + "classic_pat": "Classic Personal Access Token (PAT)" }, "detail": true, - "detail_order": 3 + "detail_order": 5 } ] }, diff --git a/services/integration/integration-type/ui-specs/digitalocean-team.json b/services/integration/integration-type/ui-specs/digitalocean-team.json index 89d08e08d..9ab56a041 100644 --- a/services/integration/integration-type/ui-specs/digitalocean-team.json +++ b/services/integration/integration-type/ui-specs/digitalocean-team.json @@ -49,17 +49,19 @@ "sortable": true, "filterable": true, "info": "ID.", - "detail": true, + "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was created.", + "show": true, + "info": "Description of the credential.", "detail": true, "detail_order": 2 }, @@ -70,23 +72,35 @@ "order": 3, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was last updated.", - "detail": true, + "show": true, + "info": "Timestamp when the credential was last updated.", + "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, - "info": "Type of Credential used (Single Account/Multi-Account).", + "order": 5, + "show": false, + "info": "Type of Credential used (Classic PAT).", "valueMap": { - "aws_single_account": "Single Account", - "aws_multi_account": "Multi-Account" + "classic_pat": "Classic Personal Access Token (PAT)" }, "detail": true, - "detail_order": 3 + "detail_order": 5 } ] }, diff --git a/services/integration/integration-type/ui-specs/doppler-account.json b/services/integration/integration-type/ui-specs/doppler-account.json index 5e62faa84..4bff69acf 100644 --- a/services/integration/integration-type/ui-specs/doppler-account.json +++ b/services/integration/integration-type/ui-specs/doppler-account.json @@ -49,17 +49,19 @@ "sortable": true, "filterable": true, "info": "ID.", - "detail": true, + "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was created.", + "show": true, + "info": "Description of the credential.", "detail": true, "detail_order": 2 }, @@ -70,23 +72,35 @@ "order": 3, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was last updated.", - "detail": true, + "show": true, + "info": "Timestamp when the credential was last updated.", + "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, - "info": "Type of Credential used (Single Account/Multi-Account).", + "order": 5, + "show": false, + "info": "Type of Credential used (Classic PAT).", "valueMap": { - "aws_single_account": "Single Account", - "aws_multi_account": "Multi-Account" + "classic_pat": "Classic Personal Access Token (PAT)" }, "detail": true, - "detail_order": 3 + "detail_order": 5 } ] }, diff --git a/services/integration/integration-type/ui-specs/entraid-directory.json b/services/integration/integration-type/ui-specs/entraid-directory.json index 6c643b3f1..cc0e24a2e 100644 --- a/services/integration/integration-type/ui-specs/entraid-directory.json +++ b/services/integration/integration-type/ui-specs/entraid-directory.json @@ -252,17 +252,19 @@ "sortable": true, "filterable": true, "info": "ID.", - "detail": true, + "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was created.", + "show": true, + "info": "Description of the credential.", "detail": true, "detail_order": 2 }, @@ -273,23 +275,35 @@ "order": 3, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was last updated.", - "detail": true, + "show": true, + "info": "Timestamp when the credential was last updated.", + "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, - "info": "Type of Credential used (SPN Password Based/SPN Certificate).", + "order": 5, + "show": false, + "info": "Type of Credential used (Classic PAT).", "valueMap": { - "spn_password_based": "SPN Password Based", - "spn_certificate": "SPN Certificate" + "classic_pat": "Classic Personal Access Token (PAT)" }, "detail": true, - "detail_order": 4 + "detail_order": 5 } ] }, diff --git a/services/integration/integration-type/ui-specs/github-account.json b/services/integration/integration-type/ui-specs/github-account.json index 54dbc0b2b..e7b1ffc06 100644 --- a/services/integration/integration-type/ui-specs/github-account.json +++ b/services/integration/integration-type/ui-specs/github-account.json @@ -118,17 +118,19 @@ "filterable": true, "info": "ID.", "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the credential was created.", - "detail": false, + "show": true, + "info": "Description of the credential.", + "detail": true, "detail_order": 2 }, { @@ -138,22 +140,35 @@ "order": 3, "sortable": true, "filterable": true, + "show": true, "info": "Timestamp when the credential was last updated.", "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, + "order": 5, + "show": false, "info": "Type of Credential used (Classic PAT).", "valueMap": { "classic_pat": "Classic Personal Access Token (PAT)" }, - "detail": false, - "detail_order": 4 + "detail": true, + "detail_order": 5 } ] }, diff --git a/services/integration/integration-type/ui-specs/google-workspace-account.json b/services/integration/integration-type/ui-specs/google-workspace-account.json index b31e9b392..93ca20453 100644 --- a/services/integration/integration-type/ui-specs/google-workspace-account.json +++ b/services/integration/integration-type/ui-specs/google-workspace-account.json @@ -65,17 +65,19 @@ "sortable": true, "filterable": true, "info": "ID.", - "detail": true, + "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was created.", + "show": true, + "info": "Description of the credential.", "detail": true, "detail_order": 2 }, @@ -86,23 +88,35 @@ "order": 3, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was last updated.", - "detail": true, + "show": true, + "info": "Timestamp when the credential was last updated.", + "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, - "info": "Type of Credential used (Single Account/Multi-Account).", + "order": 5, + "show": false, + "info": "Type of Credential used (Classic PAT).", "valueMap": { - "aws_single_account": "Single Account", - "aws_multi_account": "Multi-Account" + "classic_pat": "Classic Personal Access Token (PAT)" }, "detail": true, - "detail_order": 3 + "detail_order": 5 } ] }, diff --git a/services/integration/integration-type/ui-specs/linode-account.json b/services/integration/integration-type/ui-specs/linode-account.json index 2d61513df..55be708ab 100644 --- a/services/integration/integration-type/ui-specs/linode-account.json +++ b/services/integration/integration-type/ui-specs/linode-account.json @@ -49,17 +49,19 @@ "sortable": true, "filterable": true, "info": "ID.", - "detail": true, + "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was created.", + "show": true, + "info": "Description of the credential.", "detail": true, "detail_order": 2 }, @@ -70,23 +72,35 @@ "order": 3, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was last updated.", - "detail": true, + "show": true, + "info": "Timestamp when the credential was last updated.", + "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, - "info": "Type of Credential used (Single Account/Multi-Account).", + "order": 5, + "show": false, + "info": "Type of Credential used (Classic PAT).", "valueMap": { - "aws_single_account": "Single Account", - "aws_multi_account": "Multi-Account" + "classic_pat": "Classic Personal Access Token (PAT)" }, "detail": true, - "detail_order": 3 + "detail_order": 5 } ] }, diff --git a/services/integration/integration-type/ui-specs/openai-integration.json b/services/integration/integration-type/ui-specs/openai-integration.json index 84c5b26c5..ca18d2a70 100644 --- a/services/integration/integration-type/ui-specs/openai-integration.json +++ b/services/integration/integration-type/ui-specs/openai-integration.json @@ -90,17 +90,19 @@ "sortable": true, "filterable": true, "info": "ID.", - "detail": true, + "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was created.", + "show": true, + "info": "Description of the credential.", "detail": true, "detail_order": 2 }, @@ -111,23 +113,35 @@ "order": 3, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was last updated.", - "detail": true, + "show": true, + "info": "Timestamp when the credential was last updated.", + "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, - "info": "Type of Credential used (Single Account/Multi-Account).", + "order": 5, + "show": false, + "info": "Type of Credential used (Classic PAT).", "valueMap": { - "aws_single_account": "Single Account", - "aws_multi_account": "Multi-Account" + "classic_pat": "Classic Personal Access Token (PAT)" }, "detail": true, - "detail_order": 3 + "detail_order": 5 } ] }, diff --git a/services/integration/integration-type/ui-specs/render-account.json b/services/integration/integration-type/ui-specs/render-account.json index e32156ccb..ffcdec8b3 100644 --- a/services/integration/integration-type/ui-specs/render-account.json +++ b/services/integration/integration-type/ui-specs/render-account.json @@ -49,17 +49,19 @@ "sortable": true, "filterable": true, "info": "ID.", - "detail": true, + "detail": false, + "show": true, "detail_order": 1 }, { - "name": "created_at", - "label": "Created At", - "fieldType": "date", + "name": "description", + "label": "Description", + "fieldType": "text", "order": 2, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was created.", + "show": true, + "info": "Description of the credential.", "detail": true, "detail_order": 2 }, @@ -70,23 +72,35 @@ "order": 3, "sortable": true, "filterable": true, - "info": "Timestamp when the integration was last updated.", - "detail": true, + "show": true, + "info": "Timestamp when the credential was last updated.", + "detail": false, "detail_order": 3 }, + { + "name": "integration_count", + "label": "Integration Count", + "fieldType": "text", + "order": 4, + "sortable": true, + "filterable": true, + "show": true, + "info": "Number of active integrations using this credential.", + "detail": true, + "detail_order": 4 + }, { "name": "credential_type", "label": "Credential Type", "fieldType": "text", - "required": true, - "order": 4, - "info": "Type of Credential used (Single Account/Multi-Account).", + "order": 5, + "show": false, + "info": "Type of Credential used (Classic PAT).", "valueMap": { - "aws_single_account": "Single Account", - "aws_multi_account": "Multi-Account" + "classic_pat": "Classic Personal Access Token (PAT)" }, "detail": true, - "detail_order": 3 + "detail_order": 5 } ] }, diff --git a/services/integration/models/credential.go b/services/integration/models/credential.go index 9cc411bd6..f3de79894 100644 --- a/services/integration/models/credential.go +++ b/services/integration/models/credential.go @@ -17,6 +17,9 @@ type Credential struct { CredentialType string Secret string Metadata pgtype.JSONB + IntegrationCount int `gorm:"default:0"` + MaskedSecret pgtype.JSONB + Description string CreatedAt time.Time UpdatedAt time.Time @@ -30,12 +33,21 @@ func (c *Credential) ToApi(returnSecret bool) (*models.Credential, error) { fmt.Println("could not unmarshal metadata", err) } } + var maskedMetadata map[string]string + if c.MaskedSecret.Status == pgtype.Present { + if err := json.Unmarshal(c.MaskedSecret.Bytes, &maskedMetadata); err != nil { + fmt.Println("could not unmarshal masked metadata", err) + } + } credential := &models.Credential{ ID: c.ID.String(), IntegrationType: c.IntegrationType, CredentialType: c.CredentialType, Metadata: metadata, + IntegrationCount: c.IntegrationCount, + MaskedSecret: maskedMetadata, + Description: c.Description, CreatedAt: c.CreatedAt, UpdatedAt: c.UpdatedAt, }