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
@@ -62,6 +62,7 @@ import { hasSecretReadValueOrDescribePermission } from "@app/lib/fn/permission";
import { camelCaseToSpaces } from "@app/lib/fn/string";
import { CreateReminderForm } from "./CreateReminderForm";
import { HIDDEN_SECRET_VALUE } from "./SecretItem";
import { formSchema, SecretActionType, TFormSchema } from "./SecretListView.utils";
type Props = {
@@ -897,7 +898,9 @@ export const SecretDetailSidebar = ({
</button>
</div>
<span className="group-[.show-value]:hidden">
{secretValueHidden ? "******" : secretValue?.replace(/./g, "*")}
{secretValueHidden
? HIDDEN_SECRET_VALUE
: secretValue?.replace(/./g, "*")}
<button
type="button"
className="ml-1 cursor-pointer"
@@ -59,6 +59,7 @@ import {
import { CollapsibleSecretImports } from "./CollapsibleSecretImports";
export const HIDDEN_SECRET_VALUE = "******";
export const HIDDEN_SECRET_VALUE_API_MASK = "<hidden-by-infisical>";
type Props = {
secret: SecretV3RawSanitized;
@@ -20,7 +20,7 @@ import { AddShareSecretModal } from "@app/pages/organization/SecretSharingPage/c
import { useSelectedSecretActions, useSelectedSecrets } from "../../SecretMainPage.store";
import { CollapsibleSecretImports } from "./CollapsibleSecretImports";
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";
type Props = {
@@ -168,7 +168,7 @@ export const SecretListView = ({
},
cb?: () => void
) => {
const { key: oldKey } = orgSecret;
const { key: oldKey, secretValueHidden } = orgSecret;
const {
key,
value,
@@ -235,8 +235,17 @@ export const SecretListView = ({
// shared secret change
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, {
value,
value: secretValue,
tags: tagIds,
comment,
reminderRepeatDays,