mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 18:27:36 +00:00
refactor(pam): update AwsIamAccountForm to use structured submit data
- Changed the onSubmit prop type to accept a structured SubmitData type, enhancing type safety. - Updated the form submission logic to align with the new data structure, ensuring proper handling of form fields.
This commit is contained in:
+14
-4
@@ -30,11 +30,20 @@ import { GenericAccountFields, genericAccountFieldsSchema } from "./GenericAccou
|
|||||||
const AWS_STS_MIN_SESSION_DURATION = 900; // 15 minutes
|
const AWS_STS_MIN_SESSION_DURATION = 900; // 15 minutes
|
||||||
const AWS_STS_MAX_SESSION_DURATION_ROLE_CHAINING = 3600; // 1 hour
|
const AWS_STS_MAX_SESSION_DURATION_ROLE_CHAINING = 3600; // 1 hour
|
||||||
|
|
||||||
|
type SubmitData = {
|
||||||
|
name: string;
|
||||||
|
description?: string | null;
|
||||||
|
credentials: {
|
||||||
|
targetRoleArn: string;
|
||||||
|
defaultSessionDuration: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
account?: TAwsIamAccount;
|
account?: TAwsIamAccount;
|
||||||
resourceId?: string;
|
resourceId?: string;
|
||||||
resourceType?: PamResourceType;
|
resourceType?: PamResourceType;
|
||||||
onSubmit: (formData: FormData) => Promise<void>;
|
onSubmit: (formData: SubmitData) => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const arnRoleRegex = /^arn:aws:iam::\d{12}:role\/[\w+=,.@/-]+$/;
|
const arnRoleRegex = /^arn:aws:iam::\d{12}:role\/[\w+=,.@/-]+$/;
|
||||||
@@ -152,12 +161,13 @@ export const AwsIamAccountForm = ({ account, resourceId, resourceType, onSubmit
|
|||||||
const durationSeconds = Math.floor(durationMs / 1000);
|
const durationSeconds = Math.floor(durationMs / 1000);
|
||||||
|
|
||||||
await onSubmit({
|
await onSubmit({
|
||||||
...formData,
|
name: formData.name,
|
||||||
|
description: formData.description,
|
||||||
credentials: {
|
credentials: {
|
||||||
...formData.credentials,
|
targetRoleArn: formData.credentials.targetRoleArn,
|
||||||
defaultSessionDuration: durationSeconds
|
defaultSessionDuration: durationSeconds
|
||||||
}
|
}
|
||||||
} as any);
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user