Skip to content

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

fix(frontend): require an allow list for AWS and GCP identity auth

Calvin42b9f75e8a58
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx
index 91a39e5e3c..4435be921a 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx
@@ -6,6 +6,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Field,
+ FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -48,7 +49,15 @@ const buildSchema = (maxAccessTokenTTL: number) =>
accessTokenTrustedIps: trustedIpsSchema
})
.required()
- .superRefine(superRefineAccessTokenTtl);
+ .superRefine(superRefineAccessTokenTtl)
+ .superRefine((data, ctx) => {
+ if (!data.allowedPrincipalArns.trim() && !data.allowedAccountIds.trim()) {
+ const message = "Configure at least one allowed AWS account ID or principal ARN.";
+ ["allowedPrincipalArns", "allowedAccountIds"].forEach((path) =>
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: [path], message })
+ );
+ }
+ });
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -207,9 +216,7 @@ export const IdentityAwsAuthForm = ({
name="allowedPrincipalArns"
render={({ field, fieldState: { error } }) => (
<Field>
- <FieldLabel htmlFor="allowedPrincipalArns">
- Allowed Principal ARNs (optional)
- </FieldLabel>
+ <FieldLabel htmlFor="allowedPrincipalArns">Allowed Principal ARNs</FieldLabel>
<Input
{...field}
id="allowedPrincipalArns"
@@ -217,6 +224,9 @@ export const IdentityAwsAuthForm = ({
type="text"
isError={Boolean(error)}
/>
+ <FieldDescription>
+ At least one of allowed principal ARNs or allowed account IDs is required.
+ </FieldDescription>
<FieldError>{error?.message}</FieldError>
</Field>
)}
@@ -226,15 +236,16 @@ export const IdentityAwsAuthForm = ({
name="allowedAccountIds"
render={({ field, fieldState: { error } }) => (
<Field>
- <FieldLabel htmlFor="allowedAccountIds">
- Allowed Account IDs (optional)
- </FieldLabel>
+ <FieldLabel htmlFor="allowedAccountIds">Allowed Account IDs</FieldLabel>
<Input
{...field}
id="allowedAccountIds"
placeholder="123456789012, ..."
isError={Boolean(error)}
/>
+ <FieldDescription>
+ At least one of allowed principal ARNs or allowed account IDs is required.
+ </FieldDescription>
<FieldError>{error?.message}</FieldError>
</Field>
)}
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx
index 02d3c78c73..e7e9d66616 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx
@@ -6,6 +6,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Field,
+ FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -54,7 +55,19 @@ const buildSchema = (maxAccessTokenTTL: number) =>
accessTokenTrustedIps: trustedIpsSchema
})
.required()
- .superRefine(superRefineAccessTokenTtl);
+ .superRefine(superRefineAccessTokenTtl)
+ .superRefine((data, ctx) => {
+ const hasServiceAccounts = Boolean(data.allowedServiceAccounts.trim());
+ const hasProjects = data.type === "gce" && Boolean(data.allowedProjects.trim());
+ if (!hasServiceAccounts && !hasProjects) {
+ const message =
+ "Configure at least one allowed GCP service account, or for GCE identities an allowed project.";
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["allowedServiceAccounts"], message });
+ if (data.type === "gce") {
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["allowedProjects"], message });
+ }
+ }
+ });
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -247,7 +260,7 @@ export const IdentityGcpAuthForm = ({
render={({ field, fieldState: { error } }) => (
<Field>
<FieldLabel htmlFor="allowedServiceAccounts">
- Allowed Service Account Emails (optional)
+ Allowed Service Account Emails
</FieldLabel>
<Input
{...field}
@@ -256,6 +269,11 @@ export const IdentityGcpAuthForm = ({
type="text"
isError={Boolean(error)}
/>
+ <FieldDescription>
+ {watchedType === "gce"
+ ? "At least one of allowed service account emails or allowed projects is required."
+ : "Required for GCP IAM Auth."}
+ </FieldDescription>
<FieldError>{error?.message}</FieldError>
</Field>
)}
@@ -266,13 +284,17 @@ export const IdentityGcpAuthForm = ({
name="allowedProjects"
render={({ field, fieldState: { error } }) => (
<Field>
- <FieldLabel htmlFor="allowedProjects">Allowed Projects (optional)</FieldLabel>
+ <FieldLabel htmlFor="allowedProjects">Allowed Projects</FieldLabel>
<Input
{...field}
id="allowedProjects"
placeholder="my-gcp-project, ..."
isError={Boolean(error)}
/>
+ <FieldDescription>
+ At least one of allowed service account emails or allowed projects is
+ required.
+ </FieldDescription>
<FieldError>{error?.message}</FieldError>
</Field>
)}