Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

add button to check is the credentials of a secret rotation are valid

adilson8a21355c3ed8
diff --git a/frontend/src/hooks/api/secretRotationsV2/mutations.tsx b/frontend/src/hooks/api/secretRotationsV2/mutations.tsx
index 491eb8703f..b14300ffcf 100644
--- a/frontend/src/hooks/api/secretRotationsV2/mutations.tsx
+++ b/frontend/src/hooks/api/secretRotationsV2/mutations.tsx
@@ -3,6 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { dashboardKeys } from "@app/hooks/api/dashboard/queries";
import {
+ TCheckSecretRotationV2CredentialsDTO,
TCreateSecretRotationV2DTO,
TDeleteSecretRotationV2DTO,
TMoveSecretRotationV2DTO,
@@ -146,3 +147,13 @@ export const useReconcileLocalAccountRotation = () => {
})
});
};
+
+export const useCheckSecretRotationV2Credentials = () => {
+ return useMutation({
+ mutationFn: async ({ type, rotationId }: TCheckSecretRotationV2CredentialsDTO) => {
+ await apiRequest.post(
+ `/api/v2/secret-rotations/${type}/${rotationId}/check-credentials`
+ );
+ }
+ });
+};
diff --git a/frontend/src/hooks/api/secretRotationsV2/types/index.ts b/frontend/src/hooks/api/secretRotationsV2/types/index.ts
index dc4807a439..e6c58bfcd1 100644
--- a/frontend/src/hooks/api/secretRotationsV2/types/index.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/types/index.ts
@@ -265,3 +265,8 @@ export type TReconcileLocalAccountRotationResponse = {
reconciled: boolean;
secretRotation: TUnixLinuxLocalAccountRotation | TWindowsLocalAccountRotation | THpIloRotation;
};
+
+export type TCheckSecretRotationV2CredentialsDTO = {
+ rotationId: string;
+ type: SecretRotation;
+};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
index cd97c348ea..928d200ad0 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
@@ -165,6 +165,7 @@ import {
SecretRotation as SecretRotationV2,
TSecretRotationV2
} from "@app/hooks/api/secretRotationsV2";
+import { useCheckSecretRotationV2Credentials } from "@app/hooks/api/secretRotationsV2/mutations";
import { useCreateCommit } from "@app/hooks/api/secrets/mutations";
import { fetchProjectSecrets, secretKeys } from "@app/hooks/api/secrets/queries";
import {
@@ -677,6 +678,7 @@ const OverviewPageContent = () => {
const { mutateAsync: deleteSecretImport } = useDeleteSecretImport();
const { mutate: updateSecretImport } = useUpdateSecretImport();
const { mutateAsync: deleteWsEnvironment } = useDeleteWsEnvironment();
+ const { mutateAsync: checkSecretRotationCredentials } = useCheckSecretRotationV2Credentials();
// Batch mode state and hooks
const [isOverviewBatchMode, setIsOverviewBatchMode] = useState(
@@ -3154,6 +3156,12 @@ const OverviewPageContent = () => {
onDelete={(secretRotation) =>
handlePopUpOpen("deleteSecretRotation", secretRotation)
}
+ onCheckActiveCredentials={async (secretRotation) => {
+ await checkSecretRotationCredentials({
+ rotationId: secretRotation.id,
+ type: secretRotation.type
+ });
+ }}
/>
))}
{honeyTokenNames.map((honeyTokenName, index) => (
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretRotationTableRow/SecretRotationTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretRotationTableRow/SecretRotationTableRow.tsx
index ae58f0d960..64231f9705 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretRotationTableRow/SecretRotationTableRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretRotationTableRow/SecretRotationTableRow.tsx
@@ -1,6 +1,8 @@
+import { useState } from "react";
import { subject } from "@casl/ability";
import {
AsteriskIcon,
+ Check,
ChevronDownIcon,
EditIcon,
HandshakeIcon,
@@ -58,6 +60,7 @@ type Props = {
onReconcile: (secretRotation: TSecretRotationV2) => void;
onViewGeneratedCredentials: (secretRotation: TSecretRotationV2) => void;
onDelete: (secretRotation: TSecretRotationV2) => void;
+ onCheckActiveCredentials: (secretRotation: TSecretRotationV2) => Promise<void> | void;
};
const shouldShowReconciliationButton = (secretRotation: TSecretRotationV2) =>
@@ -82,9 +85,21 @@ export const SecretRotationTableRow = ({
onRotate,
onViewGeneratedCredentials,
onDelete,
- onReconcile
+ onReconcile,
+ onCheckActiveCredentials
}: Props) => {
const [isExpanded, setIsExpanded] = useToggle(false);
+ const [checkingRotationId, setCheckingRotationId] = useState<string | null>(null);
+
+ const handleCheckActiveCredentials = async (secretRotation: TSecretRotationV2) => {
+ if (checkingRotationId) return;
+ setCheckingRotationId(secretRotation.id);
+ try {
+ await onCheckActiveCredentials(secretRotation);
+ } finally {
+ setCheckingRotationId(null);
+ }
+ };
const isSingleEnvView = environments.length === 1;
const totalCols = environments.length + 2; // secret key row + icon
@@ -110,6 +125,39 @@ export const SecretRotationTableRow = ({
"group-hover:pointer-events-auto group-hover:gap-1 group-hover:opacity-100"
)}
>
+ <ProjectPermissionCan
+ I={ProjectPermissionSecretRotationActions.ReadGeneratedCredentials}
+ a={subject(ProjectPermissionSub.SecretRotation, {
+ environment: environment.slug,
+ secretPath: folder.path,
+ ...(secretRotation.connectionId && {
+ connectionId: secretRotation.connectionId
+ })
+ })}
+ >
+ {(isAllowed) => {
+ const isCheckingThisRotation = checkingRotationId === secretRotation.id;
+ return (
+ <Tooltip>
+ <TooltipTrigger>
+ <IconButton
+ variant="ghost"
+ size="xs"
+ className={twMerge(
+ "w-0 overflow-hidden border-0 transition-all duration-300 group-hover:w-7",
+ isCheckingThisRotation && "w-7 animate-spin"
+ )}
+ isDisabled={!isAllowed || Boolean(checkingRotationId)}
+ onClick={() => handleCheckActiveCredentials(secretRotation)}
+ >
+ <Check />
+ </IconButton>
+ </TooltipTrigger>
+ <TooltipContent>Check Credentials</TooltipContent>
+ </Tooltip>
+ );
+ }}
+ </ProjectPermissionCan>
<ProjectPermissionCan
I={ProjectPermissionSecretRotationActions.ReadGeneratedCredentials}
a={subject(ProjectPermissionSub.SecretRotation, {
@@ -326,8 +374,8 @@ export const SecretRotationTableRow = ({
className={twMerge(
"ml-auto flex items-center transition-[margin] duration-300",
shouldShowReconciliationButton(singleEnvRotation)
- ? "group-hover:mr-40"
- : "group-hover:mr-32"
+ ? "group-hover:mr-48"
+ : "group-hover:mr-40"
)}
>
<SecretRotationV2StatusBadge secretRotation={singleEnvRotation} />
@@ -424,7 +472,7 @@ export const SecretRotationTableRow = ({
<div
className={twMerge(
"ml-auto flex items-center transition-[margin] duration-300",
- showReconcileButton ? "group-hover:mr-40" : "group-hover:mr-32"
+ showReconcileButton ? "group-hover:mr-48" : "group-hover:mr-40"
)}
>
<SecretRotationV2StatusBadge secretRotation={secretRotation} />