Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

Commit 380bd4f

Browse files
committed
feat(schema-form): mask access/secret keys in application forms
Wires the sensitive-field detector into SchemaForm's uiSchema pipeline and registers the toggle widget under the customWidgets map. As a result, fields like postgres' s3AccessKey and s3SecretKey on the application order/edit screens render as bullets with a click-to-reveal control instead of plain text. Detection is purely additive and does not override widgets bound by earlier detectors. Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent de81358 commit 380bd4f

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎apps/console/src/components/SchemaForm.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Form from "@rjsf/core"
33
import validator from "@rjsf/validator-ajv8"
44
import type { RJSFSchema, UiSchema, TemplatesType } from "@rjsf/utils"
55
import { keysOrderToUiSchema, sanitizeSchema } from "../lib/keys-order.ts"
6+
import { addSensitiveStringWidgets } from "../lib/sensitive-fields.ts"
67
import { customTemplates, customWidgets } from "./rjsf-templates.tsx"
78
import { AdditionalPropertiesField } from "./AdditionalPropertiesField.tsx"
89
import { ResourceQuotasField } from "./ResourceQuotasField.tsx"
@@ -187,18 +188,21 @@ export function SchemaForm({
187188
// Automatically add AdditionalPropertiesField for fields with additionalProperties schema
188189
const withAdditionalProps = addAdditionalPropertiesWidgets(schema, withVMDisk)
189190

191+
// Mask credential-shaped string fields (access/secret keys, passwords, tokens).
192+
const withSensitive = addSensitiveStringWidgets(schema, withAdditionalProps)
193+
190194
// Override resourceQuotas field with structured quota editor.
191195
// Scoped to schemas where resourceQuotas has additionalProperties: {type: "string"}
192196
// (the cozystack-tenants chart shape) to avoid activating on unrelated CRDs.
193197
const rqSchema = (schema as any).properties?.resourceQuotas
194198
if (rqSchema && rqSchema.additionalProperties?.type === "string") {
195-
withAdditionalProps.resourceQuotas = {
196-
...withAdditionalProps.resourceQuotas,
199+
withSensitive.resourceQuotas = {
200+
...withSensitive.resourceQuotas,
197201
"ui:field": "ResourceQuotasField",
198202
}
199203
}
200204

201-
return withAdditionalProps
205+
return withSensitive
202206
}, [keysOrder, schema])
203207

204208
const customFields = useMemo(

‎apps/console/src/components/rjsf-templates.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { StorageClassWidget } from "./StorageClassWidget.tsx"
1313
import { AdditionalPropertiesWidget } from "./AdditionalPropertiesWidget.tsx"
1414
import { VMDiskWidget } from "./VMDiskWidget.tsx"
1515
import { BackupClassWidget } from "./BackupClassWidget.tsx"
16+
import { SensitiveStringWidget } from "./SensitiveStringWidget.tsx"
1617

1718
function IconButton<
1819
T = any,
@@ -93,4 +94,5 @@ export const customWidgets = {
9394
AdditionalPropertiesWidget: AdditionalPropertiesWidget,
9495
VMDiskWidget: VMDiskWidget,
9596
BackupClassWidget: BackupClassWidget,
97+
SensitiveStringWidget: SensitiveStringWidget,
9698
}

0 commit comments

Comments
 (0)