mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 19:44:52 +00:00
Remove service account JSON requirement from GCP Auth
This commit is contained in:
@@ -181,7 +181,6 @@ export const useAddIdentityGcpAuth = () => {
|
||||
return useMutation<IdentityGcpAuth, {}, AddIdentityGcpAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
credentials,
|
||||
type,
|
||||
allowedServiceAccounts,
|
||||
allowedProjects,
|
||||
@@ -196,7 +195,6 @@ export const useAddIdentityGcpAuth = () => {
|
||||
} = await apiRequest.post<{ identityGcpAuth: IdentityGcpAuth }>(
|
||||
`/api/v1/auth/gcp-auth/identities/${identityId}`,
|
||||
{
|
||||
credentials,
|
||||
type,
|
||||
allowedServiceAccounts,
|
||||
allowedProjects,
|
||||
@@ -221,7 +219,6 @@ export const useUpdateIdentityGcpAuth = () => {
|
||||
return useMutation<IdentityGcpAuth, {}, UpdateIdentityGcpAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
credentials,
|
||||
type,
|
||||
allowedServiceAccounts,
|
||||
allowedProjects,
|
||||
@@ -236,7 +233,6 @@ export const useUpdateIdentityGcpAuth = () => {
|
||||
} = await apiRequest.patch<{ identityGcpAuth: IdentityGcpAuth }>(
|
||||
`/api/v1/auth/gcp-auth/identities/${identityId}`,
|
||||
{
|
||||
credentials,
|
||||
type,
|
||||
allowedServiceAccounts,
|
||||
allowedProjects,
|
||||
|
||||
@@ -115,7 +115,6 @@ export type UpdateIdentityUniversalAuthDTO = {
|
||||
|
||||
export type IdentityGcpAuth = {
|
||||
identityId: string;
|
||||
credentials: string;
|
||||
type: "iam" | "gce";
|
||||
allowedServiceAccounts: string;
|
||||
allowedProjects: string;
|
||||
@@ -129,7 +128,6 @@ export type IdentityGcpAuth = {
|
||||
export type AddIdentityGcpAuthDTO = {
|
||||
organizationId: string;
|
||||
identityId: string;
|
||||
credentials: string;
|
||||
type: "iam" | "gce";
|
||||
allowedServiceAccounts: string;
|
||||
allowedProjects: string;
|
||||
@@ -145,7 +143,6 @@ export type AddIdentityGcpAuthDTO = {
|
||||
export type UpdateIdentityGcpAuthDTO = {
|
||||
organizationId: string;
|
||||
identityId: string;
|
||||
credentials?: string;
|
||||
type?: "iam" | "gce";
|
||||
allowedServiceAccounts?: string;
|
||||
allowedProjects?: string;
|
||||
|
||||
+21
-42
@@ -6,15 +6,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
import {
|
||||
Button,
|
||||
FormControl,
|
||||
IconButton,
|
||||
Input,
|
||||
Select,
|
||||
SelectItem,
|
||||
TextArea
|
||||
} from "@app/components/v2";
|
||||
import { Button, FormControl, IconButton, Input, Select, SelectItem } from "@app/components/v2";
|
||||
import { useOrganization, useSubscription } from "@app/context";
|
||||
import {
|
||||
useAddIdentityGcpAuth,
|
||||
@@ -27,7 +19,6 @@ import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||
|
||||
const schema = z
|
||||
.object({
|
||||
credentials: z.string(),
|
||||
type: z.enum(["iam", "gce"]),
|
||||
allowedServiceAccounts: z.string(),
|
||||
allowedProjects: z.string(),
|
||||
@@ -83,8 +74,7 @@ export const IdentityGcpAuthForm = ({
|
||||
} = useForm<FormData>({
|
||||
resolver: zodResolver(schema),
|
||||
defaultValues: {
|
||||
credentials: "",
|
||||
type: "iam",
|
||||
type: "gce",
|
||||
allowedServiceAccounts: "",
|
||||
allowedProjects: "",
|
||||
allowedZones: "",
|
||||
@@ -106,7 +96,6 @@ export const IdentityGcpAuthForm = ({
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
reset({
|
||||
credentials: data.credentials,
|
||||
type: data.type,
|
||||
allowedServiceAccounts: data.allowedServiceAccounts,
|
||||
allowedProjects: data.allowedProjects,
|
||||
@@ -137,7 +126,6 @@ export const IdentityGcpAuthForm = ({
|
||||
}, [data]);
|
||||
|
||||
const onFormSubmit = async ({
|
||||
credentials,
|
||||
type,
|
||||
allowedServiceAccounts,
|
||||
allowedProjects,
|
||||
@@ -154,7 +142,6 @@ export const IdentityGcpAuthForm = ({
|
||||
await updateMutateAsync({
|
||||
identityId: identityAuthMethodData.identityId,
|
||||
organizationId: orgId,
|
||||
credentials,
|
||||
type,
|
||||
allowedServiceAccounts,
|
||||
allowedProjects,
|
||||
@@ -168,7 +155,6 @@ export const IdentityGcpAuthForm = ({
|
||||
await addMutateAsync({
|
||||
identityId: identityAuthMethodData.identityId,
|
||||
organizationId: orgId,
|
||||
credentials,
|
||||
type,
|
||||
allowedServiceAccounts: allowedServiceAccounts || "",
|
||||
allowedProjects: allowedProjects || "",
|
||||
@@ -211,36 +197,23 @@ export const IdentityGcpAuthForm = ({
|
||||
onValueChange={(e) => onChange(e)}
|
||||
className="w-full"
|
||||
>
|
||||
<SelectItem value="gce" key="gcp-type-gce">
|
||||
GCP ID Token Auth (Recommended)
|
||||
</SelectItem>
|
||||
<SelectItem value="iam" key="gcpiam">
|
||||
GCP IAM Auth
|
||||
</SelectItem>
|
||||
<SelectItem value="gce" key="gcp-type-gce">
|
||||
GCP GCE Auth
|
||||
</SelectItem>
|
||||
</Select>
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
control={control}
|
||||
name="credentials"
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<FormControl
|
||||
label="Service Account JSON"
|
||||
errorText={error?.message}
|
||||
isError={Boolean(error)}
|
||||
>
|
||||
<TextArea {...field} placeholder="" />
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
control={control}
|
||||
defaultValue="2592000"
|
||||
name="allowedServiceAccounts"
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<FormControl
|
||||
label="Allowed Service Accounts"
|
||||
label="Allowed Service Account Emails"
|
||||
isError={Boolean(error)}
|
||||
errorText={error?.message}
|
||||
>
|
||||
@@ -252,15 +225,21 @@ export const IdentityGcpAuthForm = ({
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
control={control}
|
||||
name="allowedProjects"
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<FormControl label="Allowed Projects" isError={Boolean(error)} errorText={error?.message}>
|
||||
<Input {...field} placeholder="my-gcp-project, ..." />
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
{watchedType === "gce" && (
|
||||
<Controller
|
||||
control={control}
|
||||
name="allowedProjects"
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<FormControl
|
||||
label="Allowed Projects"
|
||||
isError={Boolean(error)}
|
||||
errorText={error?.message}
|
||||
>
|
||||
<Input {...field} placeholder="my-gcp-project, ..." />
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
{watchedType === "gce" && (
|
||||
<Controller
|
||||
control={control}
|
||||
|
||||
Reference in New Issue
Block a user