fix: editing secrets with value hidden

This commit is contained in:
Daniel Hougaard
2025-06-17 21:02:47 +04:00
parent a89bd08c08
commit 956f75eb43
6 changed files with 39 additions and 7 deletions
@@ -96,6 +96,10 @@ import { SecretOverviewSecretRotationRow } from "@app/pages/secret-manager/Overv
import { CreateDynamicSecretForm } from "../SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm"; import { CreateDynamicSecretForm } from "../SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm";
import { FolderForm } from "../SecretDashboardPage/components/ActionBar/FolderForm"; import { FolderForm } from "../SecretDashboardPage/components/ActionBar/FolderForm";
import {
HIDDEN_SECRET_VALUE,
HIDDEN_SECRET_VALUE_API_MASK
} from "../SecretDashboardPage/components/SecretListView/SecretItem";
import { CreateSecretForm } from "./components/CreateSecretForm"; import { CreateSecretForm } from "./components/CreateSecretForm";
import { FolderBreadCrumbs } from "./components/FolderBreadCrumbs"; import { FolderBreadCrumbs } from "./components/FolderBreadCrumbs";
import { SecretOverviewDynamicSecretRow } from "./components/SecretOverviewDynamicSecretRow"; import { SecretOverviewDynamicSecretRow } from "./components/SecretOverviewDynamicSecretRow";
@@ -509,15 +513,25 @@ export const OverviewPage = () => {
env: string, env: string,
key: string, key: string,
value: string, value: string,
secretValueHidden: boolean,
type = SecretType.Shared type = SecretType.Shared
) => { ) => {
let secretValue: string | undefined = value;
if (
secretValueHidden &&
(value === HIDDEN_SECRET_VALUE_API_MASK || value === HIDDEN_SECRET_VALUE)
) {
secretValue = undefined;
}
try { try {
const result = await updateSecretV3({ const result = await updateSecretV3({
environment: env, environment: env,
workspaceId, workspaceId,
secretPath, secretPath,
secretKey: key, secretKey: key,
secretValue: value, secretValue,
type type
}); });
@@ -50,6 +50,7 @@ type Props = {
env: string, env: string,
key: string, key: string,
value: string, value: string,
secretValueHidden: boolean,
type?: SecretType, type?: SecretType,
secretId?: string secretId?: string
) => Promise<void>; ) => Promise<void>;
@@ -147,6 +148,7 @@ export const SecretEditRow = ({
environment, environment,
secretName, secretName,
value, value,
secretValueHidden,
isOverride ? SecretType.Personal : SecretType.Shared, isOverride ? SecretType.Personal : SecretType.Shared,
secretId secretId
); );
@@ -166,6 +168,7 @@ export const SecretEditRow = ({
environment, environment,
secretName, secretName,
secretValue, secretValue,
secretValueHidden,
isOverride ? SecretType.Personal : SecretType.Shared, isOverride ? SecretType.Personal : SecretType.Shared,
secretId secretId
); );
@@ -257,7 +260,7 @@ export const SecretEditRow = ({
> >
{(isAllowed) => ( {(isAllowed) => (
<div> <div>
<Tooltip content="save"> <Tooltip content="Save">
<IconButton <IconButton
variant="plain" variant="plain"
ariaLabel="submit-value" ariaLabel="submit-value"
@@ -24,6 +24,7 @@ import { useToggle } from "@app/hooks";
import { SecretType, SecretV3RawSanitized } from "@app/hooks/api/secrets/types"; import { SecretType, SecretV3RawSanitized } from "@app/hooks/api/secrets/types";
import { WorkspaceEnv } from "@app/hooks/api/types"; import { WorkspaceEnv } from "@app/hooks/api/types";
import { getExpandedRowStyle } from "@app/pages/secret-manager/OverviewPage/components/utils"; import { getExpandedRowStyle } from "@app/pages/secret-manager/OverviewPage/components/utils";
import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem";
import { SecretEditRow } from "./SecretEditRow"; import { SecretEditRow } from "./SecretEditRow";
import SecretRenameRow from "./SecretRenameRow"; import SecretRenameRow from "./SecretRenameRow";
@@ -40,6 +41,7 @@ type Props = {
env: string, env: string,
key: string, key: string,
value: string, value: string,
secretValueHidden: boolean,
type?: SecretType, type?: SecretType,
secretId?: string secretId?: string
) => Promise<void>; ) => Promise<void>;
@@ -96,7 +98,7 @@ export const SecretOverviewTableRow = ({
); );
if (secret?.secretValueHidden && !secret?.valueOverride) { if (secret?.secretValueHidden && !secret?.valueOverride) {
return canEditSecretValue ? "******" : ""; return canEditSecretValue ? HIDDEN_SECRET_VALUE : "";
} }
return secret?.valueOverride || secret?.value || importedSecret?.secret?.value || ""; return secret?.valueOverride || secret?.value || importedSecret?.secret?.value || "";
}; };
@@ -62,6 +62,7 @@ import { hasSecretReadValueOrDescribePermission } from "@app/lib/fn/permission";
import { camelCaseToSpaces } from "@app/lib/fn/string"; import { camelCaseToSpaces } from "@app/lib/fn/string";
import { CreateReminderForm } from "./CreateReminderForm"; import { CreateReminderForm } from "./CreateReminderForm";
import { HIDDEN_SECRET_VALUE } from "./SecretItem";
import { formSchema, SecretActionType, TFormSchema } from "./SecretListView.utils"; import { formSchema, SecretActionType, TFormSchema } from "./SecretListView.utils";
type Props = { type Props = {
@@ -897,7 +898,9 @@ export const SecretDetailSidebar = ({
</button> </button>
</div> </div>
<span className="group-[.show-value]:hidden"> <span className="group-[.show-value]:hidden">
{secretValueHidden ? "******" : secretValue?.replace(/./g, "*")} {secretValueHidden
? HIDDEN_SECRET_VALUE
: secretValue?.replace(/./g, "*")}
<button <button
type="button" type="button"
className="ml-1 cursor-pointer" className="ml-1 cursor-pointer"
@@ -59,6 +59,7 @@ import {
import { CollapsibleSecretImports } from "./CollapsibleSecretImports"; import { CollapsibleSecretImports } from "./CollapsibleSecretImports";
export const HIDDEN_SECRET_VALUE = "******"; export const HIDDEN_SECRET_VALUE = "******";
export const HIDDEN_SECRET_VALUE_API_MASK = "<hidden-by-infisical>";
type Props = { type Props = {
secret: SecretV3RawSanitized; secret: SecretV3RawSanitized;
@@ -20,7 +20,7 @@ import { AddShareSecretModal } from "@app/pages/organization/SecretSharingPage/c
import { useSelectedSecretActions, useSelectedSecrets } from "../../SecretMainPage.store"; import { useSelectedSecretActions, useSelectedSecrets } from "../../SecretMainPage.store";
import { CollapsibleSecretImports } from "./CollapsibleSecretImports"; import { CollapsibleSecretImports } from "./CollapsibleSecretImports";
import { SecretDetailSidebar } from "./SecretDetailSidebar"; import { SecretDetailSidebar } from "./SecretDetailSidebar";
import { SecretItem } from "./SecretItem"; import { HIDDEN_SECRET_VALUE, HIDDEN_SECRET_VALUE_API_MASK, SecretItem } from "./SecretItem";
import { FontAwesomeSpriteSymbols } from "./SecretListView.utils"; import { FontAwesomeSpriteSymbols } from "./SecretListView.utils";
type Props = { type Props = {
@@ -168,7 +168,7 @@ export const SecretListView = ({
}, },
cb?: () => void cb?: () => void
) => { ) => {
const { key: oldKey } = orgSecret; const { key: oldKey, secretValueHidden } = orgSecret;
const { const {
key, key,
value, value,
@@ -235,8 +235,17 @@ export const SecretListView = ({
// shared secret change // shared secret change
if (!isSharedSecUnchanged && !personalAction) { if (!isSharedSecUnchanged && !personalAction) {
let secretValue = value;
if (
secretValueHidden &&
(value === HIDDEN_SECRET_VALUE_API_MASK || value === HIDDEN_SECRET_VALUE)
) {
secretValue = undefined;
}
await handleSecretOperation("update", SecretType.Shared, oldKey, { await handleSecretOperation("update", SecretType.Shared, oldKey, {
value, value: secretValue,
tags: tagIds, tags: tagIds,
comment, comment,
reminderRepeatDays, reminderRepeatDays,