Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix: allow viewing local secret value when editing secret but no read value permission
Scott Wilson17d199ae9456
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsxindex d2ba62852c..a2dafb58f7 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx@@ -62,13 +62,12 @@ import { usePopUp, useToggle } from "@app/hooks";import { useUpdateSecretV3 } from "@app/hooks/api";import { useGetSecretValue } from "@app/hooks/api/dashboard/queries";import { Reminder } from "@app/hooks/api/reminders/types";+import { PendingAction } from "@app/hooks/api/secretFolders/types";import { ProjectEnv, SecretType, SecretV3RawSanitized, WsTag } from "@app/hooks/api/types";import { hasSecretReadValueOrDescribePermission } from "@app/lib/fn/permission";import { AddShareSecretModal } from "@app/pages/organization/SecretSharingPage/components/ShareSecret/AddShareSecretModal";import { CollapsibleSecretImports } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/CollapsibleSecretImports";import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem";--import { PendingAction } from "@app/hooks/api/secretFolders/types";import { useBatchStoreApi } from "@app/pages/secret-manager/SecretDashboardPage/SecretMainPage.store";import { SecretAccessInsights } from "./SecretAccessInsights";@@ -278,23 +277,6 @@ export const SecretEditTableRow = ({}}, [sharedValueData]);- // Keep original refs for comment/tags/metadata in sync with server data.- // Without this, after a batch commit clears pending changes, the form reset- // (line ~514) would revert to stale values from initial mount instead of- // the freshly committed server data.- useEffect(() => {- if (!isSingleEnvView || hasPendingChange) return;-- originalCommentRef.current = comment ?? "";- originalTagsRef.current = tags?.map((t) => ({ id: t.id, slug: t.slug })) ?? [];- originalMetadataRef.current =- secretMetadata?.map((m) => ({- key: m.key,- value: m.value,- isEncrypted: m.isEncrypted ?? false- })) ?? [];- }, [comment, tags, secretMetadata, isSingleEnvView, hasPendingChange]);-const { permission } = useProjectPermission();const { mutateAsync: updateSecretV3, isPending: isUpdatingMultiline } = useUpdateSecretV3();@@ -323,6 +305,23 @@ export const SecretEditTableRow = ({})) ?? []);+ // Keep original refs for comment/tags/metadata in sync with server data.+ // Without this, after a batch commit clears pending changes, the form reset+ // (line ~514) would revert to stale values from initial mount instead of+ // the freshly committed server data.+ useEffect(() => {+ if (!isSingleEnvView || hasPendingChange) return;++ originalCommentRef.current = comment ?? "";+ originalTagsRef.current = tags?.map((t) => ({ id: t.id, slug: t.slug })) ?? [];+ originalMetadataRef.current =+ secretMetadata?.map((m) => ({+ key: m.key,+ value: m.value,+ isEncrypted: m.isEncrypted ?? false+ })) ?? [];+ }, [comment, tags, secretMetadata, isSingleEnvView, hasPendingChange]);+// Stable callbacks for child components to avoid resetting their debounce timers on re-renderconst handleCommentChange = useCallback((newComment: string) => setValue("comment", newComment),@@ -901,14 +900,16 @@ export const SecretEditTableRow = ({{...field}isReadOnly={isReadOnly}value={- secretValueHidden || isFetchingSharedValue- ? HIDDEN_SECRET_VALUE- : isErrorFetchingSharedValue- ? "Error fetching secret value..."- : (field.value as string)+ secretValueHidden+ ? ((field.value as string) ?? "")+ : isFetchingSharedValue+ ? HIDDEN_SECRET_VALUE+ : isErrorFetchingSharedValue+ ? "Error fetching secret value..."+ : (field.value as string)}key="secret-input-shared"- isVisible={isVisible && !secretValueHidden}+ isVisible={isVisible}secretPath={secretPath}environment={environment}isImport={isImportedSecret}diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsxindex 614fc34f40..0c62bcaf32 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx@@ -338,9 +338,7 @@ const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState>(state.existingSecretKeys.has(change.secretKey) &&!isServerKeyFreed(change.secretKey)) ||newChanges.secrets.some(- (s) =>- effectiveKey(s) === change.secretKey &&- s.type !== PendingAction.Create+ (s) => effectiveKey(s) === change.secretKey && s.type !== PendingAction.Create);if (change.type === PendingAction.Create && existingSecret) {@@ -358,8 +356,7 @@ const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState>((state.existingSecretKeys.has(change.newSecretName) &&!isServerKeyFreed(change.newSecretName)) ||newChanges.secrets.some(- (s) =>- s.id !== change.id && effectiveKey(s) === change.newSecretName+ (s) => s.id !== change.id && effectiveKey(s) === change.newSecretName));if (existingNewSecretName) {diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsxindex 83f94358d5..0257c0bd00 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx@@ -182,7 +182,7 @@ const RenderSecretChanges = ({version: 2, // placeholder, not usedsecretKey: change.newSecretName ?? existingSecret.key,secretValue: newSecretValue,- secretValueHidden: change.existingSecret.secretValueHidden,+ secretValueHidden: change.existingSecret.secretValueHidden && !hasValueChange,tags:change.tags?.map((tag) => tag.slug) ??existingSecret.tags?.map((tag) => tag.slug) ??