Skip to content

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

feat(ui): ssh password rotation support complete

=c414885c7996
diff --git a/frontend/src/components/secret-rotations-v2/ReconcileSshPasswordRotationModal.tsx b/frontend/src/components/secret-rotations-v2/ReconcileSshPasswordRotationModal.tsx
new file mode 100644
index 0000000000..9b63f0c567
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/ReconcileSshPasswordRotationModal.tsx
@@ -0,0 +1,89 @@
+import { createNotification } from "@app/components/notifications";
+import { Button, Modal, ModalClose, ModalContent } from "@app/components/v2";
+import { SecretRotation, TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";
+import { useReconcileSshPasswordRotation } from "@app/hooks/api/secretRotationsV2/mutations";
+import { TSshPasswordRotation } from "@app/hooks/api/secretRotationsV2/types/ssh-password-rotation";
+
+type Props = {
+ secretRotation?: TSecretRotationV2;
+ isOpen: boolean;
+ onOpenChange: (isOpen: boolean) => void;
+};
+
+type ContentProps = {
+ secretRotation: TSshPasswordRotation;
+ onComplete: () => void;
+};
+
+const Content = ({ secretRotation, onComplete }: ContentProps) => {
+ const reconcileSshPassword = useReconcileSshPasswordRotation();
+
+ const { id: rotationId, projectId, folder } = secretRotation;
+
+ const handleReconcile = async () => {
+ const result = await reconcileSshPassword.mutateAsync({
+ rotationId,
+ projectId,
+ secretPath: folder.path
+ });
+
+ createNotification({
+ text: result.reconciled
+ ? "Successfully reconciled SSH password rotation"
+ : "SSH password rotation is already in sync",
+ type: "success"
+ });
+
+ onComplete();
+ };
+
+ return (
+ <div>
+ <p className="mb-4 text-sm text-mineshaft-200">
+ Reconciliation ensures the password stored in Infisical matches the actual password on the
+ SSH server.
+ </p>
+ <p className="mb-8 text-sm text-mineshaft-200">
+ Use this if you suspect the credentials are out of sync, for example after a failed rotation
+ or manual password change on the server.
+ </p>
+ <div className="mt-8 flex w-full items-center justify-between gap-2">
+ <ModalClose asChild>
+ <Button colorSchema="secondary" variant="plain">
+ Cancel
+ </Button>
+ </ModalClose>
+ <Button
+ onClick={handleReconcile}
+ isDisabled={reconcileSshPassword.isPending}
+ isLoading={reconcileSshPassword.isPending}
+ colorSchema="secondary"
+ >
+ Reconcile
+ </Button>
+ </div>
+ </div>
+ );
+};
+
+export const ReconcileSshPasswordRotationModal = ({
+ isOpen,
+ onOpenChange,
+ secretRotation
+}: Props) => {
+ if (!secretRotation || secretRotation.type !== SecretRotation.SshPassword) return null;
+
+ return (
+ <Modal isOpen={isOpen} onOpenChange={onOpenChange}>
+ <ModalContent
+ title="Reconcile SSH Password"
+ subTitle="Sync the SSH password between Infisical and the server."
+ >
+ <Content
+ secretRotation={secretRotation as TSshPasswordRotation}
+ onComplete={() => onOpenChange(false)}
+ />
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
index 066a621a46..78e774a5b5 100644
--- a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
@@ -25,6 +25,7 @@ import { ViewSqlCredentialsRotationGeneratedCredentials } from "./shared";
import { ViewAwsIamUserSecretRotationGeneratedCredentials } from "./ViewAwsIamUserSecretRotationGeneratedCredentials";
import { ViewOktaClientSecretRotationGeneratedCredentials } from "./ViewOktaClientSecretRotationGeneratedCredentials";
import { ViewRedisCredentialsRotationGeneratedCredentials } from "./ViewRedisCredentialsRotationGeneratedCredentials";
+import { ViewSshPasswordRotationGeneratedCredentials } from "./ViewSshPasswordRotationGeneratedCredentials";
type Props = {
secretRotation?: TSecretRotationV2;
@@ -124,6 +125,13 @@ const Content = ({ secretRotation }: ContentProps) => {
/>
);
break;
+ case SecretRotation.SshPassword:
+ Component = (
+ <ViewSshPasswordRotationGeneratedCredentials
+ generatedCredentialsResponse={generatedCredentialsResponse}
+ />
+ );
+ break;
default:
throw new Error("Unhandled View Generated Credential Rotation Type");
}
diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSshPasswordRotationGeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSshPasswordRotationGeneratedCredentials.tsx
new file mode 100644
index 0000000000..ba4cc724e8
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSshPasswordRotationGeneratedCredentials.tsx
@@ -0,0 +1,37 @@
+import { TSshPasswordRotationGeneratedCredentialsResponse } from "@app/hooks/api/secretRotationsV2/types/ssh-password-rotation";
+
+import { CredentialDisplay, ViewRotationGeneratedCredentialsDisplay } from "./shared";
+
+type Props = {
+ generatedCredentialsResponse: TSshPasswordRotationGeneratedCredentialsResponse;
+};
+
+export const ViewSshPasswordRotationGeneratedCredentials = ({
+ generatedCredentialsResponse: { generatedCredentials, activeIndex }
+}: Props) => {
+ const inactiveIndex = activeIndex === 0 ? 1 : 0;
+
+ const activeCredentials = generatedCredentials[activeIndex];
+ const inactiveCredentials = generatedCredentials[inactiveIndex];
+
+ return (
+ <ViewRotationGeneratedCredentialsDisplay
+ activeCredentials={
+ <>
+ <CredentialDisplay label="Username">{activeCredentials?.username}</CredentialDisplay>
+ <CredentialDisplay isSensitive label="Password">
+ {activeCredentials?.password}
+ </CredentialDisplay>
+ </>
+ }
+ inactiveCredentials={
+ <>
+ <CredentialDisplay label="Username">{inactiveCredentials?.username}</CredentialDisplay>
+ <CredentialDisplay isSensitive label="Password">
+ {inactiveCredentials?.password}
+ </CredentialDisplay>
+ </>
+ }
+ />
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
index fc8228d06b..4c0814c06a 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
@@ -12,6 +12,7 @@ import { MongoRotationParametersFields } from "./MongoRotationParametersFields";
import { OktaClientSecretRotationParametersFields } from "./OktaClientSecretRotationParametersFields";
import { RedisCredentialsRotationParametersFields } from "./RedisCredentialsRotationParametersFields";
import { SqlCredentialsRotationParametersFields } from "./shared";
+import { SshPasswordRotationParametersFields } from "./SshPasswordRotationParametersFields";
const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.PostgresCredentials]: SqlCredentialsRotationParametersFields,
@@ -26,7 +27,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.RedisCredentials]: RedisCredentialsRotationParametersFields,
[SecretRotation.MongoDBCredentials]: MongoRotationParametersFields,
[SecretRotation.DatabricksServicePrincipalSecret]:
- DatabricksServicePrincipalSecretRotationParametersFields
+ DatabricksServicePrincipalSecretRotationParametersFields,
+ [SecretRotation.SshPassword]: SshPasswordRotationParametersFields
};
export const SecretRotationV2ParametersFields = () => {
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SshPasswordRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SshPasswordRotationParametersFields.tsx
new file mode 100644
index 0000000000..91f4c7f494
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SshPasswordRotationParametersFields.tsx
@@ -0,0 +1,264 @@
+import { Controller, useFormContext } from "react-hook-form";
+
+import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
+import { DEFAULT_PASSWORD_REQUIREMENTS } from "@app/components/secret-rotations-v2/forms/schemas/shared";
+import { FormControl, Input, Select, SelectItem } from "@app/components/v2";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+import { SshPasswordRotationMethod } from "@app/hooks/api/secretRotationsV2/types/ssh-password-rotation";
+
+export const SshPasswordRotationParametersFields = () => {
+ const { control, watch, setValue } = useFormContext<
+ TSecretRotationV2Form & {
+ type: SecretRotation.SshPassword;
+ }
+ >();
+
+ const [id] = watch(["id"]);
+ const rotationMethod = watch(
+ "parameters.rotationMethod",
+ SshPasswordRotationMethod.LoginAsTarget
+ );
+ const isUpdate = Boolean(id);
+
+ return (
+ <>
+ <Controller
+ name="parameters.rotationMethod"
+ control={control}
+ defaultValue={SshPasswordRotationMethod.LoginAsTarget}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ tooltipText={
+ <>
+ <span>Determines how the rotation will be performed:</span>
+ <ul className="mt-2 ml-4 flex list-disc flex-col gap-2">
+ <li>
+ <span className="font-medium">Login as Root</span> - The SSH connection
+ credentials (admin) will be used to change the target user&#39;s password.
+ </li>
+ <li>
+ <span className="font-medium">Login as Target</span> - The target user will
+ authenticate with their own credentials and change their own password.
+ </li>
+ </ul>
+ </>
+ }
+ tooltipClassName="max-w-sm"
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Rotation Method"
+ helperText={
+ // eslint-disable-next-line no-nested-ternary
+ isUpdate
+ ? "Cannot be updated."
+ : value === SshPasswordRotationMethod.LoginAsRoot
+ ? "The SSH connection credentials will change the target user's password"
+ : "The target user will change their own password"
+ }
+ >
+ <Select
+ isDisabled={isUpdate}
+ value={value}
+ onValueChange={(val) => {
+ setValue("temporaryParameters", {
+ password: ""
+ });
+ onChange(val);
+ }}
+ className="w-full border border-mineshaft-500 capitalize"
+ position="popper"
+ dropdownContainerClassName="max-w-none"
+ >
+ {Object.values(SshPasswordRotationMethod).map((method) => {
+ return (
+ <SelectItem value={method} className="capitalize" key={method}>
+ {method.replace(/-/g, " ")}
+ </SelectItem>
+ );
+ })}
+ </Select>
+ </FormControl>
+ )}
+ />
+ <div className="flex gap-3">
+ <Controller
+ name="parameters.username"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ className="flex-1"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="Target Username"
+ tooltipText="The Unix/Linux username of the account to rotate the password for."
+ tooltipClassName="max-w-sm"
+ helperText={isUpdate ? "Cannot be updated." : undefined}
+ >
+ <Input
+ isDisabled={isUpdate}
+ value={value}
+ onChange={onChange}
+ placeholder="appuser"
+ />
+ </FormControl>
+ )}
+ />
+ {!isUpdate && rotationMethod === SshPasswordRotationMethod.LoginAsTarget && (
+ <Controller
+ name="temporaryParameters.password"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ className="flex-1"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="Current Password"
+ tooltipText="The current password of the target user. Required for initial rotation setup."
+ >
+ <Input
+ value={value}
+ onChange={onChange}
+ type="password"
+ placeholder="****************"
+ />
+ </FormControl>
+ )}
+ />
+ )}
+ </div>
+ <div className="flex flex-col gap-3">
+ <div className="w-full border-b border-mineshaft-600">
+ <span className="text-sm text-mineshaft-300">Password Requirements</span>
+ </div>
+ <div className="grid grid-cols-2 gap-x-3 gap-y-1 rounded-sm border border-mineshaft-600 bg-mineshaft-700 px-3 pt-3">
+ <Controller
+ control={control}
+ name="parameters.passwordRequirements.length"
+ defaultValue={DEFAULT_PASSWORD_REQUIREMENTS.length}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Password Length"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="The length of the password to generate"
+ >
+ <Input
+ type="number"
+ min={1}
+ max={250}
+ size="sm"
+ {...field}
+ onChange={(e) => field.onChange(Number(e.target.value))}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="parameters.passwordRequirements.required.digits"
+ defaultValue={DEFAULT_PASSWORD_REQUIREMENTS.required.digits}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Digit Count"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="Minimum number of digits"
+ >
+ <Input
+ type="number"
+ min={0}
+ size="sm"
+ {...field}
+ onChange={(e) => field.onChange(Number(e.target.value))}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="parameters.passwordRequirements.required.lowercase"
+ defaultValue={DEFAULT_PASSWORD_REQUIREMENTS.required.lowercase}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Lowercase Character Count"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="Minimum number of lowercase characters"
+ >
+ <Input
+ type="number"
+ min={0}
+ size="sm"
+ {...field}
+ onChange={(e) => field.onChange(Number(e.target.value))}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="parameters.passwordRequirements.required.uppercase"
+ defaultValue={DEFAULT_PASSWORD_REQUIREMENTS.required.uppercase}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Uppercase Character Count"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="Minimum number of uppercase characters"
+ >
+ <Input
+ type="number"
+ min={0}
+ size="sm"
+ {...field}
+ onChange={(e) => field.onChange(Number(e.target.value))}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="parameters.passwordRequirements.required.symbols"
+ defaultValue={DEFAULT_PASSWORD_REQUIREMENTS.required.symbols}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Symbol Count"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="Minimum number of symbols"
+ >
+ <Input
+ type="number"
+ min={0}
+ size="sm"
+ {...field}
+ onChange={(e) => field.onChange(Number(e.target.value))}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="parameters.passwordRequirements.allowedSymbols"
+ defaultValue={DEFAULT_PASSWORD_REQUIREMENTS.allowedSymbols}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Allowed Symbols"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="Symbols to use in generated password"
+ >
+ <Input
+ placeholder="-_.~!*"
+ size="sm"
+ {...field}
+ onChange={(e) => field.onChange(e.target.value)}
+ />
+ </FormControl>
+ )}
+ />
+ </div>
+ </div>
+ </>
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
index ec4b57153c..8b0bffbaba 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
@@ -14,6 +14,7 @@ import { LdapPasswordRotationReviewFields } from "./LdapPasswordRotationReviewFi
import { OktaClientSecretRotationReviewFields } from "./OktaClientSecretRotationReviewFields";
import { RedisCredentialsRotationReviewFields } from "./RedisCredentialsRotationReviewFields";
import { SqlCredentialsRotationReviewFields } from "./shared";
+import { SshPasswordRotationReviewFields } from "./SshPasswordRotationReviewFields";
const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.PostgresCredentials]: SqlCredentialsRotationReviewFields,
@@ -28,7 +29,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.RedisCredentials]: RedisCredentialsRotationReviewFields,
[SecretRotation.MongoDBCredentials]: SqlCredentialsRotationReviewFields,
[SecretRotation.DatabricksServicePrincipalSecret]:
- DatabricksServicePrincipalSecretRotationReviewFields
+ DatabricksServicePrincipalSecretRotationReviewFields,
+ [SecretRotation.SshPassword]: SshPasswordRotationReviewFields
};
export const SecretRotationV2ReviewFields = () => {
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SshPasswordRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SshPasswordRotationReviewFields.tsx
new file mode 100644
index 0000000000..e96105ab68
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SshPasswordRotationReviewFields.tsx
@@ -0,0 +1,51 @@
+import { useFormContext } from "react-hook-form";
+
+import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
+import { GenericFieldLabel } from "@app/components/v2";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+
+import { SecretRotationReviewSection } from "./shared";
+
+export const SshPasswordRotationReviewFields = () => {
+ const { watch } = useFormContext<
+ TSecretRotationV2Form & {
+ type: SecretRotation.SshPassword;
+ }
+ >();
+
+ const [parameters, { username, password }] = watch(["parameters", "secretsMapping"]);
+
+ const { passwordRequirements } = parameters;
+
+ return (
+ <>
+ <SecretRotationReviewSection label="Parameters">
+ <GenericFieldLabel label="Username">{parameters.username}</GenericFieldLabel>
+ </SecretRotationReviewSection>
+ {passwordRequirements && (
+ <SecretRotationReviewSection label="Password Requirements">
+ <GenericFieldLabel label="Length">{passwordRequirements.length}</GenericFieldLabel>
+ <GenericFieldLabel label="Minimum Digits">
+ {passwordRequirements.required.digits}
+ </GenericFieldLabel>
+ <GenericFieldLabel label="Minimum Lowercase Characters">
+ {passwordRequirements.required.lowercase}
+ </GenericFieldLabel>
+ <GenericFieldLabel label="Minimum Uppercase Characters">
+ {passwordRequirements.required.uppercase}
+ </GenericFieldLabel>
+ <GenericFieldLabel label="Minimum Symbols">
+ {passwordRequirements.required.symbols}
+ </GenericFieldLabel>
+ <GenericFieldLabel label="Allowed Symbols">
+ {passwordRequirements.allowedSymbols}
+ </GenericFieldLabel>
+ </SecretRotationReviewSection>
+ )}
+ <SecretRotationReviewSection label="Secrets Mapping">
+ <GenericFieldLabel label="Username">{username}</GenericFieldLabel>
+ <GenericFieldLabel label="Password">{password}</GenericFieldLabel>
+ </SecretRotationReviewSection>
+ </>
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
index 0df87039ac..722a53cda4 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
@@ -11,6 +11,7 @@ import { LdapPasswordRotationSecretsMappingFields } from "./LdapPasswordRotation
import { OktaClientSecretRotationSecretsMappingFields } from "./OktaClientSecretRotationSecretsMappingFields";
import { RedisCredentialsRotationSecretsMappingFields } from "./RedisCredentialsRotationSecretsMappingFields";
import { SqlCredentialsRotationSecretsMappingFields } from "./shared";
+import { SshPasswordRotationSecretsMappingFields } from "./SshPasswordRotationSecretsMappingFields";
const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.PostgresCredentials]: SqlCredentialsRotationSecretsMappingFields,
@@ -25,7 +26,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.RedisCredentials]: RedisCredentialsRotationSecretsMappingFields,
[SecretRotation.MongoDBCredentials]: SqlCredentialsRotationSecretsMappingFields,
[SecretRotation.DatabricksServicePrincipalSecret]:
- DatabricksServicePrincipalSecretRotationSecretsMappingFields
+ DatabricksServicePrincipalSecretRotationSecretsMappingFields,
+ [SecretRotation.SshPassword]: SshPasswordRotationSecretsMappingFields
};
export const SecretRotationV2SecretsMappingFields = () => {
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SshPasswordRotationSecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SshPasswordRotationSecretsMappingFields.tsx
new file mode 100644
index 0000000000..1bedf519e0
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SshPasswordRotationSecretsMappingFields.tsx
@@ -0,0 +1,58 @@
+import { Controller, useFormContext } from "react-hook-form";
+
+import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
+import { FormControl, Input } from "@app/components/v2";
+import { SecretRotation, useSecretRotationV2Option } from "@app/hooks/api/secretRotationsV2";
+
+import { SecretsMappingTable } from "./shared";
+
+export const SshPasswordRotationSecretsMappingFields = () => {
+ const { control } = useFormContext<
+ TSecretRotationV2Form & {
+ type: SecretRotation.SshPassword;
+ }
+ >();
+
+ const { rotationOption } = useSecretRotationV2Option(SecretRotation.SshPassword);
+
+ const items = [
+ {
+ name: "Username",
+ input: (
+ <Controller
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl isError={Boolean(error)} errorText={error?.message}>
+ <Input
+ value={value}
+ onChange={onChange}
+ placeholder={rotationOption?.template.secretsMapping.username}
+ />
+ </FormControl>
+ )}
+ control={control}
+ name="secretsMapping.username"
+ />
+ )
+ },
+ {
+ name: "Password",
+ input: (
+ <Controller
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl isError={Boolean(error)} errorText={error?.message}>
+ <Input
+ value={value}
+ onChange={onChange}
+ placeholder={rotationOption?.template.secretsMapping.password}
+ />
+ </FormControl>
+ )}
+ control={control}
+ name="secretsMapping.password"
+ />
+ )
+ }
+ ];
+
+ return <SecretsMappingTable items={items} />;
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
index c71adc084d..9b29e85c22 100644
--- a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
@@ -11,10 +11,12 @@ import { MySqlCredentialsRotationSchema } from "@app/components/secret-rotations
import { PostgresCredentialsRotationSchema } from "@app/components/secret-rotations-v2/forms/schemas/postgres-credentials-rotation-schema";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
import { LdapPasswordRotationMethod } from "@app/hooks/api/secretRotationsV2/types/ldap-password-rotation";
+import { SshPasswordRotationMethod } from "@app/hooks/api/secretRotationsV2/types/ssh-password-rotation";
import { OktaClientSecretRotationSchema } from "./okta-client-secret-rotation-schema";
import { OracleDBCredentialsRotationSchema } from "./oracledb-credentials-rotation-schema";
import { RedisCredentialsRotationSchema } from "./redis-credentials-rotation-schema";
+import { SshPasswordRotationSchema } from "./ssh-password-rotation-schema";
export const SecretRotationV2FormSchema = (isUpdate: boolean) =>
z
@@ -31,23 +33,39 @@ export const SecretRotationV2FormSchema = (isUpdate: boolean) =>
OktaClientSecretRotationSchema,
RedisCredentialsRotationSchema,
MongoDBCredentialsRotationSchema,
- DatabricksServicePrincipalSecretRotationSchema
+ DatabricksServicePrincipalSecretRotationSchema,
+ SshPasswordRotationSchema
]),
z.object({ id: z.string().optional() })
)
.superRefine((val, ctx) => {
- if (val.type !== SecretRotation.LdapPassword || isUpdate) return;
+ if (isUpdate) return;
// this has to go on union or breaks discrimination
- if (
- val.parameters.rotationMethod === LdapPasswordRotationMethod.TargetPrincipal &&
- !val.temporaryParameters?.password
- ) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: "Password required",
- path: ["temporaryParameters", "password"]
- });
+ if (val.type === SecretRotation.LdapPassword) {
+ if (
+ val.parameters.rotationMethod === LdapPasswordRotationMethod.TargetPrincipal &&
+ !val.temporaryParameters?.password
+ ) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: "Password required",
+ path: ["temporaryParameters", "password"]
+ });
+ }
+ }
+
+ if (val.type === SecretRotation.SshPassword) {
+ if (
+ val.parameters.rotationMethod === SshPasswordRotationMethod.LoginAsTarget &&
+ !val.temporaryParameters?.password
+ ) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: "Password required",
+ path: ["temporaryParameters", "password"]
+ });
+ }
}
});
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/ssh-password-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/ssh-password-rotation-schema.ts
new file mode 100644
index 0000000000..0db8c40c71
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/ssh-password-rotation-schema.ts
@@ -0,0 +1,26 @@
+import { z } from "zod";
+
+import { BaseSecretRotationSchema } from "@app/components/secret-rotations-v2/forms/schemas/base-secret-rotation-v2-schema";
+import { PasswordRequirementsSchema } from "@app/components/secret-rotations-v2/forms/schemas/shared";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+import { SshPasswordRotationMethod } from "@app/hooks/api/secretRotationsV2/types/ssh-password-rotation";
+
+export const SshPasswordRotationSchema = z
+ .object({
+ type: z.literal(SecretRotation.SshPassword),
+ parameters: z.object({
+ username: z.string().trim().min(1, "Username required"),
+ passwordRequirements: PasswordRequirementsSchema.optional(),
+ rotationMethod: z.nativeEnum(SshPasswordRotationMethod).optional()
+ }),
+ secretsMapping: z.object({
+ username: z.string().trim().min(1, "Username required"),
+ password: z.string().trim().min(1, "Password required")
+ }),
+ temporaryParameters: z
+ .object({
+ password: z.string().min(1, "Password required")
+ })
+ .optional()
+ })
+ .merge(BaseSecretRotationSchema);
diff --git a/frontend/src/helpers/secretRotationsV2.ts b/frontend/src/helpers/secretRotationsV2.ts
index 655ee82b88..9a2f9dfea5 100644
--- a/frontend/src/helpers/secretRotationsV2.ts
+++ b/frontend/src/helpers/secretRotationsV2.ts
@@ -64,6 +64,11 @@ export const SECRET_ROTATION_MAP: Record<
name: "Databricks Service Principal",
image: "Databricks.png",
size: 50
+ },
+ [SecretRotation.SshPassword]: {
+ name: "SSH Password",
+ image: "SSH.png",
+ size: 50
}
};
@@ -79,7 +84,8 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio
[SecretRotation.OktaClientSecret]: AppConnection.Okta,
[SecretRotation.RedisCredentials]: AppConnection.Redis,
[SecretRotation.MongoDBCredentials]: AppConnection.MongoDB,
- [SecretRotation.DatabricksServicePrincipalSecret]: AppConnection.Databricks
+ [SecretRotation.DatabricksServicePrincipalSecret]: AppConnection.Databricks,
+ [SecretRotation.SshPassword]: AppConnection.SSH
};
// if a rotation can potentially have downtime due to rotating a single credential set this to false
@@ -95,7 +101,8 @@ export const IS_ROTATION_DUAL_CREDENTIALS: Record<SecretRotation, boolean> = {
[SecretRotation.OktaClientSecret]: true,
[SecretRotation.RedisCredentials]: true,
[SecretRotation.MongoDBCredentials]: true,
- [SecretRotation.DatabricksServicePrincipalSecret]: true
+ [SecretRotation.DatabricksServicePrincipalSecret]: true,
+ [SecretRotation.SshPassword]: false
};
export const getRotateAtLocal = ({ hours, minutes }: TSecretRotationV2["rotateAtUtc"]) => {
diff --git a/frontend/src/hooks/api/secretRotationsV2/enums.ts b/frontend/src/hooks/api/secretRotationsV2/enums.ts
index a7d08b31e4..2ce43eb68d 100644
--- a/frontend/src/hooks/api/secretRotationsV2/enums.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/enums.ts
@@ -10,7 +10,8 @@ export enum SecretRotation {
OktaClientSecret = "okta-client-secret",
RedisCredentials = "redis-credentials",
MongoDBCredentials = "mongodb-credentials",
- DatabricksServicePrincipalSecret = "databricks-service-principal-secret"
+ DatabricksServicePrincipalSecret = "databricks-service-principal-secret",
+ SshPassword = "ssh-password"
}
export enum SecretRotationStatus {
diff --git a/frontend/src/hooks/api/secretRotationsV2/index.ts b/frontend/src/hooks/api/secretRotationsV2/index.ts
index fa5e33d2a7..f49a872a5a 100644
--- a/frontend/src/hooks/api/secretRotationsV2/index.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/index.ts
@@ -1,3 +1,4 @@
export * from "./enums";
+export * from "./mutations";
export * from "./queries";
export * from "./types";
diff --git a/frontend/src/hooks/api/secretRotationsV2/mutations.tsx b/frontend/src/hooks/api/secretRotationsV2/mutations.tsx
index 8343b6768b..fab75dba59 100644
--- a/frontend/src/hooks/api/secretRotationsV2/mutations.tsx
+++ b/frontend/src/hooks/api/secretRotationsV2/mutations.tsx
@@ -2,9 +2,12 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { dashboardKeys } from "@app/hooks/api/dashboard/queries";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2/enums";
import {
TCreateSecretRotationV2DTO,
TDeleteSecretRotationV2DTO,
+ TReconcileSshPasswordRotationDTO,
+ TReconcileSshPasswordRotationResponse,
TRotateSecretRotationV2DTO,
TSecretRotationV2Response,
TUpdateSecretRotationV2DTO
@@ -89,3 +92,24 @@ export const useDeleteSecretRotationV2 = () => {
})
});
};
+
+export const useReconcileSshPasswordRotation = () => {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: async ({ rotationId }: TReconcileSshPasswordRotationDTO) => {
+ const { data } = await apiRequest.post<TReconcileSshPasswordRotationResponse>(
+ `/api/v2/secret-rotations/${SecretRotation.SshPassword}/${rotationId}/reconcile`
+ );
+
+ return data;
+ },
+ onSuccess: (_, { projectId, secretPath }) =>
+ queryClient.invalidateQueries({
+ queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
+ }),
+ onError: (_, { projectId, secretPath }) =>
+ queryClient.invalidateQueries({
+ queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
+ })
+ });
+};
diff --git a/frontend/src/hooks/api/secretRotationsV2/types/index.ts b/frontend/src/hooks/api/secretRotationsV2/types/index.ts
index 724f3ddcbd..4ba83397ab 100644
--- a/frontend/src/hooks/api/secretRotationsV2/types/index.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/types/index.ts
@@ -59,6 +59,11 @@ import {
TRedisCredentialsRotationGeneratedCredentialsResponse,
TRedisCredentialsRotationOption
} from "./redis-credentials-rotation";
+import {
+ TSshPasswordRotation,
+ TSshPasswordRotationGeneratedCredentialsResponse,
+ TSshPasswordRotationOption
+} from "./ssh-password-rotation";
export type TSecretRotationV2 = (
| TPostgresCredentialsRotation
@@ -73,6 +78,7 @@ export type TSecretRotationV2 = (
| TRedisCredentialsRotation
| TMongoDBCredentialsRotation
| TDatabricksServicePrincipalSecretRotation
+ | TSshPasswordRotation
) & {
secrets: (SecretV3RawSanitized | null)[];
};
@@ -86,7 +92,8 @@ export type TSecretRotationV2Option =
| TOktaClientSecretRotationOption
| TRedisCredentialsRotationOption
| TMongoDBCredentialsRotationOption
- | TDatabricksServicePrincipalSecretRotationOption;
+ | TDatabricksServicePrincipalSecretRotationOption
+ | TSshPasswordRotationOption;
export type TListSecretRotationV2Options = { secretRotationOptions: TSecretRotationV2Option[] };
@@ -104,7 +111,8 @@ export type TViewSecretRotationGeneratedCredentialsResponse =
| TOktaClientSecretRotationGeneratedCredentialsResponse
| TRedisCredentialsRotationGeneratedCredentialsResponse
| TMongoDBCredentialsRotationGeneratedCredentialsResponse
- | TDatabricksServicePrincipalSecretRotationGeneratedCredentialsResponse;
+ | TDatabricksServicePrincipalSecretRotationGeneratedCredentialsResponse
+ | TSshPasswordRotationGeneratedCredentialsResponse;
export type TCreateSecretRotationV2DTO = DiscriminativePick<
TSecretRotationV2,
@@ -160,6 +168,7 @@ export type TSecretRotationOptionMap = {
[SecretRotation.RedisCredentials]: TRedisCredentialsRotationOption;
[SecretRotation.MongoDBCredentials]: TMongoDBCredentialsRotationOption;
[SecretRotation.DatabricksServicePrincipalSecret]: TDatabricksServicePrincipalSecretRotationOption;
+ [SecretRotation.SshPassword]: TSshPasswordRotationOption;
};
export type TSecretRotationGeneratedCredentialsResponseMap = {
@@ -175,4 +184,18 @@ export type TSecretRotationGeneratedCredentialsResponseMap = {
[SecretRotation.RedisCredentials]: TRedisCredentialsRotationGeneratedCredentialsResponse;
[SecretRotation.MongoDBCredentials]: TMongoDBCredentialsRotationGeneratedCredentialsResponse;
[SecretRotation.DatabricksServicePrincipalSecret]: TDatabricksServicePrincipalSecretRotationGeneratedCredentialsResponse;
+ [SecretRotation.SshPassword]: TSshPasswordRotationGeneratedCredentialsResponse;
+};
+
+export type TReconcileSshPasswordRotationDTO = {
+ rotationId: string;
+ // required for query invalidation
+ secretPath: string;
+ projectId: string;
+};
+
+export type TReconcileSshPasswordRotationResponse = {
+ message: string;
+ reconciled: boolean;
+ secretRotation: TSshPasswordRotation;
};
diff --git a/frontend/src/hooks/api/secretRotationsV2/types/ssh-password-rotation.ts b/frontend/src/hooks/api/secretRotationsV2/types/ssh-password-rotation.ts
new file mode 100644
index 0000000000..b06157f67d
--- /dev/null
+++ b/frontend/src/hooks/api/secretRotationsV2/types/ssh-password-rotation.ts
@@ -0,0 +1,45 @@
+import { TPasswordRequirements } from "@app/components/secret-rotations-v2/forms/schemas/shared";
+import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+import {
+ TSecretRotationV2Base,
+ TSecretRotationV2GeneratedCredentialsResponseBase
+} from "@app/hooks/api/secretRotationsV2/types/shared";
+
+export enum SshPasswordRotationMethod {
+ LoginAsTarget = "login-as-target",
+ LoginAsRoot = "login-as-root"
+}
+
+export type TSshPasswordRotation = TSecretRotationV2Base & {
+ type: SecretRotation.SshPassword;
+ parameters: {
+ username: string;
+ rotationMethod?: SshPasswordRotationMethod;
+ passwordRequirements?: TPasswordRequirements;
+ };
+ secretsMapping: {
+ username: string;
+ password: string;
+ };
+};
+
+export type TSshPasswordRotationGeneratedCredentials = {
+ username: string;
+ password: string;
+};
+
+export type TSshPasswordRotationGeneratedCredentialsResponse =
+ TSecretRotationV2GeneratedCredentialsResponseBase<
+ SecretRotation.SshPassword,
+ TSshPasswordRotationGeneratedCredentials
+ >;
+
+export type TSshPasswordRotationOption = {
+ name: string;
+ type: SecretRotation.SshPassword;
+ connection: AppConnection.SSH;
+ template: {
+ secretsMapping: TSshPasswordRotation["secretsMapping"];
+ };
+};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
index a7c9bf223e..41ca79bef8 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
@@ -31,6 +31,7 @@ import { ProjectPermissionCan } from "@app/components/permissions";
import { CreateSecretRotationV2Modal } from "@app/components/secret-rotations-v2";
import { DeleteSecretRotationV2Modal } from "@app/components/secret-rotations-v2/DeleteSecretRotationV2Modal";
import { EditSecretRotationV2Modal } from "@app/components/secret-rotations-v2/EditSecretRotationV2Modal";
+import { ReconcileSshPasswordRotationModal } from "@app/components/secret-rotations-v2/ReconcileSshPasswordRotationModal";
import { RotateSecretRotationV2Modal } from "@app/components/secret-rotations-v2/RotateSecretRotationV2Modal";
import { ViewSecretRotationV2GeneratedCredentialsModal } from "@app/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials";
import {
@@ -99,7 +100,10 @@ import { OrderByDirection } from "@app/hooks/api/generic/types";
import { ProjectType, ProjectVersion } from "@app/hooks/api/projects/types";
import { useUpdateFolderBatch } from "@app/hooks/api/secretFolders/queries";
import { TUpdateFolderBatchDTO } from "@app/hooks/api/secretFolders/types";
-import { TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";
+import {
+ SecretRotation as SecretRotationV2,
+ TSecretRotationV2
+} from "@app/hooks/api/secretRotationsV2";
import { ProjectEnv, SecretType, SecretV3RawSanitized, TSecretFolder } from "@app/hooks/api/types";
import {
useDynamicSecretOverview,
@@ -403,7 +407,8 @@ export const OverviewPage = () => {
"rotateSecretRotation",
"viewSecretRotationGeneratedCredentials",
"deleteSecretRotation",
- "upgradePlan"
+ "upgradePlan",
+ "reconcileSecretRotation"
] as const);
const handleFolderCreate = async (folderName: string, description: string | null) => {
@@ -1535,6 +1540,9 @@ export const OverviewPage = () => {
onRotate={(secretRotation) =>
handlePopUpOpen("rotateSecretRotation", secretRotation)
}
+ onReconcile={(secretRotation) =>
+ handlePopUpOpen("reconcileSecretRotation", secretRotation)
+ }
onViewGeneratedCredentials={(secretRotation) =>
handlePopUpOpen("viewSecretRotationGeneratedCredentials", secretRotation)
}
@@ -1719,6 +1727,15 @@ export const OverviewPage = () => {
secretRotation={popUp.rotateSecretRotation.data as TSecretRotationV2}
onOpenChange={(isOpen) => handlePopUpToggle("rotateSecretRotation", isOpen)}
/>
+ <ReconcileSshPasswordRotationModal
+ isOpen={
+ popUp.reconcileSecretRotation.isOpen &&
+ (popUp.reconcileSecretRotation.data as TSecretRotationV2)?.type ===
+ SecretRotationV2.SshPassword
+ }
+ secretRotation={popUp.reconcileSecretRotation.data as TSecretRotationV2}
+ onOpenChange={(isOpen) => handlePopUpToggle("reconcileSecretRotation", isOpen)}
+ />
<ViewSecretRotationV2GeneratedCredentialsModal
isOpen={popUp.viewSecretRotationGeneratedCredentials.isOpen}
secretRotation={popUp.viewSecretRotationGeneratedCredentials.data as TSecretRotationV2}
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewSecretRotationRow/SecretOverviewSecretRotationRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewSecretRotationRow/SecretOverviewSecretRotationRow.tsx
index 8952c9cf56..fdfba0e6f1 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewSecretRotationRow/SecretOverviewSecretRotationRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewSecretRotationRow/SecretOverviewSecretRotationRow.tsx
@@ -6,6 +6,7 @@ import {
faEdit,
faEye,
faEyeSlash,
+ faHandshake,
faInfoCircle,
faRotate,
faXmark
@@ -24,7 +25,12 @@ import {
} from "@app/context/ProjectPermissionContext/types";
import { SECRET_ROTATION_MAP } from "@app/helpers/secretRotationsV2";
import { useToggle } from "@app/hooks";
-import { SecretRotationStatus, TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";
+import {
+ SecretRotation,
+ SecretRotationStatus,
+ TSecretRotationV2
+} from "@app/hooks/api/secretRotationsV2";
+import { SshPasswordRotationMethod } from "@app/hooks/api/secretRotationsV2/types/ssh-password-rotation";
import { getExpandedRowStyle } from "@app/pages/secret-manager/OverviewPage/components/utils";
import { SecretOverviewRotationSecretRow } from "./SecretOverviewRotationSecretRow";
@@ -38,6 +44,7 @@ type Props = {
scrollOffset: number;
onEdit: (secretRotation: TSecretRotationV2) => void;
onRotate: (secretRotation: TSecretRotationV2) => void;
+ onReconcile: (secretRotation: TSecretRotationV2) => void;
onViewGeneratedCredentials: (secretRotation: TSecretRotationV2) => void;
onDelete: (secretRotation: TSecretRotationV2) => void;
};
@@ -52,7 +59,8 @@ export const SecretOverviewSecretRotationRow = ({
onEdit,
onRotate,
onViewGeneratedCredentials,
- onDelete
+ onDelete,
+ onReconcile
}: Props) => {
const [isExpanded, setIsExpanded] = useToggle(false);
const [isSecretVisible, setIsSecretVisible] = useToggle();
@@ -203,6 +211,31 @@ export const SecretOverviewSecretRotationRow = ({
</IconButton>
)}
</ProjectPermissionCan>
+ {secretRotation.type === SecretRotation.SshPassword &&
+ secretRotation.parameters.rotationMethod ===
+ SshPasswordRotationMethod.LoginAsTarget && (
+ <ProjectPermissionCan
+ I={ProjectPermissionSecretRotationActions.RotateSecrets}
+ a={subject(ProjectPermissionSub.SecretRotation, {
+ environment: environment.slug,
+ secretPath: folder.path
+ })}
+ renderTooltip
+ allowedLabel="Reconcile Secret"
+ >
+ {(isAllowed) => (
+ <IconButton
+ ariaLabel="Reconcile secret"
+ variant="plain"
+ size="sm"
+ isDisabled={!isAllowed}
+ onClick={() => onReconcile(secretRotation)}
+ >
+ <FontAwesomeIcon icon={faHandshake} />
+ </IconButton>
+ )}
+ </ProjectPermissionCan>
+ )}
<ProjectPermissionCan
I={ProjectPermissionSecretRotationActions.Edit}
a={subject(ProjectPermissionSub.SecretRotation, {
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsx
index 9764959e30..6517d16ee0 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsx
@@ -3,6 +3,7 @@ import { subject } from "@casl/ability";
import {
faAsterisk,
faEdit,
+ faHandshake,
faInfoCircle,
faKey,
faRotate,
@@ -19,7 +20,8 @@ import { ProjectPermissionSub } from "@app/context";
import { ProjectPermissionSecretRotationActions } from "@app/context/ProjectPermissionContext/types";
import { SECRET_ROTATION_MAP } from "@app/helpers/secretRotationsV2";
import { UsedBySecretSyncs } from "@app/hooks/api/dashboard/types";
-import { TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";
+import { SecretRotation, TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";
+import { SshPasswordRotationMethod } from "@app/hooks/api/secretRotationsV2/types/ssh-password-rotation";
import { SecretV3RawSanitized, WsTag } from "@app/hooks/api/types";
import { SecretListView } from "../SecretListView";
@@ -29,6 +31,7 @@ type Props = {
secretRotation: TSecretRotationV2;
onEdit: () => void;
onRotate: () => void;
+ onReconcile: () => void;
onViewGeneratedCredentials: () => void;
onDelete: () => void;
projectId: string;
@@ -54,6 +57,7 @@ export const SecretRotationItem = ({
secretRotation,
onEdit,
onRotate,
+ onReconcile,
onViewGeneratedCredentials,
onDelete,
projectId,
@@ -180,6 +184,35 @@ export const SecretRotationItem = ({
</IconButton>
)}
</ProjectPermissionCan>
+ {secretRotation.type === SecretRotation.SshPassword &&
+ secretRotation.parameters.rotationMethod ===
+ SshPasswordRotationMethod.LoginAsTarget && (
+ <ProjectPermissionCan
+ I={ProjectPermissionSecretRotationActions.RotateSecrets}
+ a={subject(ProjectPermissionSub.SecretRotation, {
+ environment: environment.slug,
+ secretPath: folder.path
+ })}
+ renderTooltip
+ allowedLabel="Reconcile Secret"
+ >
+ {(isAllowed) => (
+ <IconButton
+ ariaLabel="Reconcile secret"
+ variant="plain"
+ size="sm"
+ isDisabled={!isAllowed}
+ className="w-0 overflow-hidden p-0 group-hover:w-5"
+ onClick={(e) => {
+ e.stopPropagation();
+ onReconcile();
+ }}
+ >
+ <FontAwesomeIcon icon={faHandshake} />
+ </IconButton>
+ )}
+ </ProjectPermissionCan>
+ )}
</div>
</div>
<AnimatePresence mode="wait">
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationListView.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationListView.tsx
index 1de6aa2015..c2218a328e 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationListView.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationListView.tsx
@@ -1,10 +1,11 @@
import { DeleteSecretRotationV2Modal } from "@app/components/secret-rotations-v2/DeleteSecretRotationV2Modal";
import { EditSecretRotationV2Modal } from "@app/components/secret-rotations-v2/EditSecretRotationV2Modal";
+import { ReconcileSshPasswordRotationModal } from "@app/components/secret-rotations-v2/ReconcileSshPasswordRotationModal";
import { RotateSecretRotationV2Modal } from "@app/components/secret-rotations-v2/RotateSecretRotationV2Modal";
import { ViewSecretRotationV2GeneratedCredentialsModal } from "@app/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials";
import { usePopUp } from "@app/hooks";
import { UsedBySecretSyncs } from "@app/hooks/api/dashboard/types";
-import { TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";
+import { SecretRotation, TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";
import { SecretV3RawSanitized, WsTag } from "@app/hooks/api/types";
import { SecretRotationItem } from "./SecretRotationItem";
@@ -45,7 +46,8 @@ export const SecretRotationListView = ({
"editSecretRotation",
"rotateSecretRotation",
"viewSecretRotationGeneratedCredentials",
- "deleteSecretRotation"
+ "deleteSecretRotation",
+ "reconcileSecretRotation"
] as const);
return (
@@ -56,6 +58,7 @@ export const SecretRotationListView = ({
secretRotation={secretRotation}
onEdit={() => handlePopUpOpen("editSecretRotation", secretRotation)}
onRotate={() => handlePopUpOpen("rotateSecretRotation", secretRotation)}
+ onReconcile={() => handlePopUpOpen("reconcileSecretRotation", secretRotation)}
onViewGeneratedCredentials={() =>
handlePopUpOpen("viewSecretRotationGeneratedCredentials", secretRotation)
}
@@ -80,6 +83,16 @@ export const SecretRotationListView = ({
secretRotation={popUp.rotateSecretRotation.data as TSecretRotationV2}
onOpenChange={(isOpen) => handlePopUpToggle("rotateSecretRotation", isOpen)}
/>
+ <ReconcileSshPasswordRotationModal
+ isOpen={
+ popUp.reconcileSecretRotation.isOpen &&
+ (popUp.reconcileSecretRotation.data as TSecretRotationV2)?.type ===
+ SecretRotation.SshPassword
+ }
+ secretRotation={popUp.reconcileSecretRotation.data as TSecretRotationV2}
+ onOpenChange={(isOpen) => handlePopUpToggle("reconcileSecretRotation", isOpen)}
+ />
+
<ViewSecretRotationV2GeneratedCredentialsModal
isOpen={popUp.viewSecretRotationGeneratedCredentials.isOpen}
secretRotation={popUp.viewSecretRotationGeneratedCredentials.data as TSecretRotationV2}