Skip to content

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

feat: resolved breaking dev

=701eb7cfc619
diff --git a/frontend-v2/src/components/organization/CreateOrgModal/CreateOrgModal.tsx b/frontend-v2/src/components/organization/CreateOrgModal/CreateOrgModal.tsx
new file mode 100644
index 0000000000..c01d30dcaa
--- /dev/null
+++ b/frontend-v2/src/components/organization/CreateOrgModal/CreateOrgModal.tsx
@@ -0,0 +1,115 @@
+import { FC } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import z from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2";
+import { useCreateOrg, useSelectOrganization } from "@app/hooks/api";
+import { ProjectType } from "@app/hooks/api/workspace/types";
+import { useNavigate } from "@tanstack/react-router";
+
+const schema = z
+ .object({
+ name: z.string().nonempty({ message: "Name is required" })
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+interface CreateOrgModalProps {
+ isOpen: boolean;
+ onClose: () => void;
+}
+
+export const CreateOrgModal: FC<CreateOrgModalProps> = ({ isOpen, onClose }) => {
+ const navigate = useNavigate();
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ name: ""
+ }
+ });
+
+ const { mutateAsync: createOrg } = useCreateOrg({
+ invalidate: false
+ });
+ const { mutateAsync: selectOrg } = useSelectOrganization();
+
+ const onFormSubmit = async ({ name }: FormData) => {
+ try {
+ const organization = await createOrg({
+ name
+ });
+
+ await selectOrg({
+ organizationId: organization.id
+ });
+
+ createNotification({
+ text: "Successfully created organization",
+ type: "success"
+ });
+
+ navigate({
+ to: `/organization/$organizationId/${ProjectType.SecretManager}` as const,
+ params: {
+ organizationId: organization.id
+ }
+ });
+
+ localStorage.setItem("orgData.id", organization.id);
+
+ reset();
+ onClose();
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to created organization",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <Modal isOpen={isOpen}>
+ <ModalContent
+ title="Create Organization"
+ subTitle="Looks like you're not part of any organizations. Create one to start using Infisical"
+ >
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Name" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} placeholder="Acme Corp" />
+ </FormControl>
+ )}
+ />
+ <div className="flex w-full gap-4">
+ <Button
+ className=""
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Create
+ </Button>
+ <Button className="" size="sm" variant="outline_bg" type="button" onClick={onClose}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/components/organization/CreateOrgModal/index.tsx b/frontend-v2/src/components/organization/CreateOrgModal/index.tsx
new file mode 100644
index 0000000000..7b794731ab
--- /dev/null
+++ b/frontend-v2/src/components/organization/CreateOrgModal/index.tsx
@@ -0,0 +1 @@
+export { CreateOrgModal } from "./CreateOrgModal";
diff --git a/frontend-v2/src/hooks/api/secretScanning/index.tsx b/frontend-v2/src/hooks/api/secretScanning/index.tsx
new file mode 100644
index 0000000000..a7f4c2a766
--- /dev/null
+++ b/frontend-v2/src/hooks/api/secretScanning/index.tsx
@@ -0,0 +1,10 @@
+export {
+ useCreateNewInstallationSession,
+ useLinkGitAppInstallationWithOrg,
+ useUpdateRiskStatus
+} from "./mutation";
+export {
+ secretScanningQueryKeys,
+ useGetSecretScanningInstallationStatus,
+ useGetSecretScanningRisks
+} from "./queries";
diff --git a/frontend-v2/src/hooks/api/secretScanning/mutation.ts b/frontend-v2/src/hooks/api/secretScanning/mutation.ts
new file mode 100644
index 0000000000..f469c872c5
--- /dev/null
+++ b/frontend-v2/src/hooks/api/secretScanning/mutation.ts
@@ -0,0 +1,45 @@
+import { useMutation } from "@tanstack/react-query";
+
+import { apiRequest } from "@app/config/request";
+
+import { RiskStatus, TGitAppOrg, TSecretScanningGitRisks } from "./types";
+
+export const useCreateNewInstallationSession = () => {
+ return useMutation<{ sessionId: string }, object, { organizationId: string }>({
+ mutationFn: async (opt) => {
+ const { data } = await apiRequest.post(
+ "/api/v1/secret-scanning/create-installation-session/organization",
+ opt
+ );
+ return data;
+ }
+ });
+};
+
+export const useUpdateRiskStatus = () => {
+ return useMutation<
+ TSecretScanningGitRisks,
+ object,
+ { organizationId: string; riskId: string; status: RiskStatus }
+ >({
+ mutationFn: async (opt) => {
+ const { data } = await apiRequest.post<TSecretScanningGitRisks>(
+ `/api/v1/secret-scanning/organization/${opt.organizationId}/risks/${opt.riskId}/status`,
+ { status: opt.status }
+ );
+ return data;
+ }
+ });
+};
+
+export const useLinkGitAppInstallationWithOrg = () => {
+ return useMutation<TGitAppOrg, object, { sessionId: string; installationId: string }>({
+ mutationFn: async (opt) => {
+ const { data } = await apiRequest.post<TGitAppOrg>(
+ "/api/v1/secret-scanning/link-installation",
+ opt
+ );
+ return data;
+ }
+ });
+};
diff --git a/frontend-v2/src/hooks/api/secretScanning/queries.ts b/frontend-v2/src/hooks/api/secretScanning/queries.ts
new file mode 100644
index 0000000000..84ad6dedac
--- /dev/null
+++ b/frontend-v2/src/hooks/api/secretScanning/queries.ts
@@ -0,0 +1,34 @@
+import { apiRequest } from "@app/config/request";
+import { useQuery } from "@tanstack/react-query";
+import { TSecretScanningGitRisks } from "./types";
+
+export const secretScanningQueryKeys = {
+ getInstallationStatus: (orgId: string) => ["secret-scanning-installation-status", { orgId }],
+ getRisksByOrganizatio: (orgId: string) => ["secret-scanning-risks", { orgId }]
+};
+
+const fetchSecretScanningInstallationStatus = async (organizationId: string) => {
+ const { data } = await apiRequest.get<{ appInstallationCompleted: boolean }>(
+ `/api/v1/secret-scanning/installation-status/organization/${organizationId}`
+ );
+ return data;
+};
+
+export const useGetSecretScanningInstallationStatus = (orgId: string) =>
+ useQuery({
+ queryKey: secretScanningQueryKeys.getInstallationStatus(orgId),
+ queryFn: () => fetchSecretScanningInstallationStatus(orgId)
+ });
+
+const fetchSecretScanningRisksByOrgId = async (oranizationId: string) => {
+ const { data } = await apiRequest.get<TSecretScanningGitRisks[]>(
+ `/api/v1/secret-scanning/organization/${oranizationId}/risks`
+ );
+ return data;
+};
+
+export const useGetSecretScanningRisks = (orgId: string) =>
+ useQuery({
+ queryKey: secretScanningQueryKeys.getRisksByOrganizatio(orgId),
+ queryFn: () => fetchSecretScanningRisksByOrgId(orgId)
+ });
diff --git a/frontend-v2/src/hooks/api/secretScanning/types.ts b/frontend-v2/src/hooks/api/secretScanning/types.ts
new file mode 100644
index 0000000000..7c2cdc6526
--- /dev/null
+++ b/frontend-v2/src/hooks/api/secretScanning/types.ts
@@ -0,0 +1,51 @@
+export enum RiskStatus {
+ RESOLVED_FALSE_POSITIVE = "RESOLVED_FALSE_POSITIVE",
+ RESOLVED_REVOKED = "RESOLVED_REVOKED",
+ RESOLVED_NOT_REVOKED = "RESOLVED_NOT_REVOKED",
+ UNRESOLVED = "UNRESOLVED"
+}
+
+export type TSecretScanningGitRisks = {
+ id: string;
+ description: string;
+ startLine: string;
+ endLine: string;
+ startColumn: string;
+ endColumn: string;
+ match: string;
+ secret: string;
+ file: string;
+ symlinkFile: string;
+ commit: string;
+ entropy: string;
+ author: string;
+ email: string;
+ date: string;
+ message: string;
+ tags: string[];
+ ruleID: string;
+ fingerprint: string;
+ status: string;
+ isFalsePositive: boolean; // New field for marking risks as false positives
+ isResolved: boolean; // New field for marking risks as resolved
+ riskOwner: string | null; // New field for setting a risk owner (nullable string)
+ installationId: string;
+ repositoryId: string;
+ repositoryLink: string;
+ repositoryFullName: string;
+ pusher: {
+ name: string;
+ email: string;
+ };
+ createdAt: string;
+ orgId: string;
+};
+
+export type TGitAppOrg = {
+ id: string;
+ installationId: string;
+ userId: string;
+ orgId: string;
+ createdAt: Date;
+ updatedAt: Date;
+};
diff --git a/frontend-v2/src/layouts/OrganizationLayout/OrganizationLayout.tsx b/frontend-v2/src/layouts/OrganizationLayout/OrganizationLayout.tsx
index 63604d224c..b178f1dc2f 100644
--- a/frontend-v2/src/layouts/OrganizationLayout/OrganizationLayout.tsx
+++ b/frontend-v2/src/layouts/OrganizationLayout/OrganizationLayout.tsx
@@ -5,6 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link, Outlet } from "@tanstack/react-router";
import { Mfa } from "@app/components/auth/Mfa";
+import { CreateOrgModal } from "@app/components/organization/CreateOrgModal";
import SecurityClient from "@app/components/utilities/SecurityClient";
import { Menu, MenuItem } from "@app/components/v2";
import { useOrganization, useUser } from "@app/context";
@@ -189,12 +190,10 @@ export const OrganizationLayout = () => {
<SidebarFooter />
</nav>
</aside>
- {
- // <CreateOrgModal
- // isOpen={popUp?.createOrg?.isOpen}
- // onClose={() => handlePopUpToggle("createOrg", false)}
- // />
- }
+ <CreateOrgModal
+ isOpen={popUp?.createOrg?.isOpen}
+ onClose={() => handlePopUpToggle("createOrg", false)}
+ />
<main className="flex-1 overflow-y-auto overflow-x-hidden bg-bunker-800 dark:[color-scheme:dark]">
<Outlet />
</main>
diff --git a/frontend-v2/src/routeTree.gen.ts b/frontend-v2/src/routeTree.gen.ts
index 0c3b32964f..ce5de828fb 100644
--- a/frontend-v2/src/routeTree.gen.ts
+++ b/frontend-v2/src/routeTree.gen.ts
@@ -35,8 +35,22 @@ import { Route as authenticatePersonalSettingsIndexImport } from './routes/_auth
import { Route as RestrictloginsignupLoginProviderSuccessImport } from './routes/_restrict_login_signup/login/provider/success'
import { Route as RestrictloginsignupLoginProviderErrorImport } from './routes/_restrict_login_signup/login/provider/error'
import { Route as authenticateOrgdetailsOrganizationIndexImport } from './routes/_authenticate/_org_details/organization/index'
-import { Route as authenticateOrgdetailsOrganizationOrganizationIdIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/index'
-import { Route as authenticateOrgdetailsOrganizationOrganizationIdSecretManagerImport } from './routes/_authenticate/_org_details/organization/$organizationId/secret-manager'
+import { Route as authenticateOrgdetailsOrganizationNoneIndexImport } from './routes/_authenticate/_org_details/organization/none/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdSettingsIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/settings/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdSecretSharingIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdSecretScanningIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdOverviewIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/overview/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdMembersIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/members/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdBillingIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/billing/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdAuditLogsIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/audit-logs/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdAdminIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/admin/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdSecretManagerOverviewImport } from './routes/_authenticate/_org_details/organization/$organizationId/secret-manager/overview'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdKmsOverviewImport } from './routes/_authenticate/_org_details/organization/$organizationId/kms/overview'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdCertManagerOverviewImport } from './routes/_authenticate/_org_details/organization/$organizationId/cert-manager/overview'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdRolesRoleIdIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdMembershipsMembershipIdIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdIdentitiesIdentityIdIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/index'
+import { Route as authenticateOrgdetailsOrganizationOrganizationIdGroupsGroupIdIndexImport } from './routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/index'
// Create Virtual Routes
@@ -197,20 +211,134 @@ const authenticateOrgdetailsOrganizationIndexRoute =
getParentRoute: () => authenticateOrgdetailsLayoutRoute,
} as any)
-const authenticateOrgdetailsOrganizationOrganizationIdIndexRoute =
- authenticateOrgdetailsOrganizationOrganizationIdIndexImport.update({
- id: '/organization/$organizationId/',
- path: '/organization/$organizationId/',
+const authenticateOrgdetailsOrganizationNoneIndexRoute =
+ authenticateOrgdetailsOrganizationNoneIndexImport.update({
+ id: '/organization/none/',
+ path: '/organization/none/',
getParentRoute: () => authenticateOrgdetailsLayoutRoute,
} as any)
-const authenticateOrgdetailsOrganizationOrganizationIdSecretManagerRoute =
- authenticateOrgdetailsOrganizationOrganizationIdSecretManagerImport.update({
- id: '/organization/$organizationId/secret-manager',
- path: '/organization/$organizationId/secret-manager',
+const authenticateOrgdetailsOrganizationOrganizationIdSettingsIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdSettingsIndexImport.update({
+ id: '/organization/$organizationId/settings/',
+ path: '/organization/$organizationId/settings/',
getParentRoute: () => authenticateOrgdetailsLayoutRoute,
} as any)
+const authenticateOrgdetailsOrganizationOrganizationIdSecretSharingIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdSecretSharingIndexImport.update(
+ {
+ id: '/organization/$organizationId/secret-sharing/',
+ path: '/organization/$organizationId/secret-sharing/',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any,
+ )
+
+const authenticateOrgdetailsOrganizationOrganizationIdSecretScanningIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdSecretScanningIndexImport.update(
+ {
+ id: '/organization/$organizationId/secret-scanning/',
+ path: '/organization/$organizationId/secret-scanning/',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any,
+ )
+
+const authenticateOrgdetailsOrganizationOrganizationIdOverviewIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdOverviewIndexImport.update({
+ id: '/organization/$organizationId/overview/',
+ path: '/organization/$organizationId/overview/',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any)
+
+const authenticateOrgdetailsOrganizationOrganizationIdMembersIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdMembersIndexImport.update({
+ id: '/organization/$organizationId/members/',
+ path: '/organization/$organizationId/members/',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any)
+
+const authenticateOrgdetailsOrganizationOrganizationIdBillingIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdBillingIndexImport.update({
+ id: '/organization/$organizationId/billing/',
+ path: '/organization/$organizationId/billing/',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any)
+
+const authenticateOrgdetailsOrganizationOrganizationIdAuditLogsIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdAuditLogsIndexImport.update({
+ id: '/organization/$organizationId/audit-logs/',
+ path: '/organization/$organizationId/audit-logs/',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any)
+
+const authenticateOrgdetailsOrganizationOrganizationIdAdminIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdAdminIndexImport.update({
+ id: '/organization/$organizationId/admin/',
+ path: '/organization/$organizationId/admin/',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any)
+
+const authenticateOrgdetailsOrganizationOrganizationIdSecretManagerOverviewRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdSecretManagerOverviewImport.update(
+ {
+ id: '/organization/$organizationId/secret-manager/overview',
+ path: '/organization/$organizationId/secret-manager/overview',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any,
+ )
+
+const authenticateOrgdetailsOrganizationOrganizationIdKmsOverviewRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdKmsOverviewImport.update({
+ id: '/organization/$organizationId/kms/overview',
+ path: '/organization/$organizationId/kms/overview',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any)
+
+const authenticateOrgdetailsOrganizationOrganizationIdCertManagerOverviewRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdCertManagerOverviewImport.update(
+ {
+ id: '/organization/$organizationId/cert-manager/overview',
+ path: '/organization/$organizationId/cert-manager/overview',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any,
+ )
+
+const authenticateOrgdetailsOrganizationOrganizationIdRolesRoleIdIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdRolesRoleIdIndexImport.update(
+ {
+ id: '/organization/$organizationId/roles/$roleId/',
+ path: '/organization/$organizationId/roles/$roleId/',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any,
+ )
+
+const authenticateOrgdetailsOrganizationOrganizationIdMembershipsMembershipIdIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdMembershipsMembershipIdIndexImport.update(
+ {
+ id: '/organization/$organizationId/memberships/$membershipId/',
+ path: '/organization/$organizationId/memberships/$membershipId/',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any,
+ )
+
+const authenticateOrgdetailsOrganizationOrganizationIdIdentitiesIdentityIdIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdIdentitiesIdentityIdIndexImport.update(
+ {
+ id: '/organization/$organizationId/identities/$identityId/',
+ path: '/organization/$organizationId/identities/$identityId/',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any,
+ )
+
+const authenticateOrgdetailsOrganizationOrganizationIdGroupsGroupIdIndexRoute =
+ authenticateOrgdetailsOrganizationOrganizationIdGroupsGroupIdIndexImport.update(
+ {
+ id: '/organization/$organizationId/groups/$groupId/',
+ path: '/organization/$organizationId/groups/$groupId/',
+ getParentRoute: () => authenticateOrgdetailsLayoutRoute,
+ } as any,
+ )
+
// Populate the FileRoutesByPath interface
declare module '@tanstack/react-router' {
@@ -376,18 +504,116 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof authenticateOrgdetailsOrganizationIndexImport
parentRoute: typeof authenticateOrgdetailsLayoutImport
}
- '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager': {
- id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager'
- path: '/organization/$organizationId/secret-manager'
- fullPath: '/organization/$organizationId/secret-manager'
- preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdSecretManagerImport
+ '/_authenticate/_org_details/_org-layout/organization/none/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/none/'
+ path: '/organization/none'
+ fullPath: '/organization/none'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationNoneIndexImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/cert-manager/overview': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/cert-manager/overview'
+ path: '/organization/$organizationId/cert-manager/overview'
+ fullPath: '/organization/$organizationId/cert-manager/overview'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdCertManagerOverviewImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/kms/overview': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/kms/overview'
+ path: '/organization/$organizationId/kms/overview'
+ fullPath: '/organization/$organizationId/kms/overview'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdKmsOverviewImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager/overview': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager/overview'
+ path: '/organization/$organizationId/secret-manager/overview'
+ fullPath: '/organization/$organizationId/secret-manager/overview'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdSecretManagerOverviewImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/admin/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/admin/'
+ path: '/organization/$organizationId/admin'
+ fullPath: '/organization/$organizationId/admin'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdAdminIndexImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/audit-logs/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/audit-logs/'
+ path: '/organization/$organizationId/audit-logs'
+ fullPath: '/organization/$organizationId/audit-logs'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdAuditLogsIndexImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/billing/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/billing/'
+ path: '/organization/$organizationId/billing'
+ fullPath: '/organization/$organizationId/billing'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdBillingIndexImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/members/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/members/'
+ path: '/organization/$organizationId/members'
+ fullPath: '/organization/$organizationId/members'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdMembersIndexImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/overview/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/overview/'
+ path: '/organization/$organizationId/overview'
+ fullPath: '/organization/$organizationId/overview'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdOverviewIndexImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-scanning/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-scanning/'
+ path: '/organization/$organizationId/secret-scanning'
+ fullPath: '/organization/$organizationId/secret-scanning'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdSecretScanningIndexImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-sharing/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-sharing/'
+ path: '/organization/$organizationId/secret-sharing'
+ fullPath: '/organization/$organizationId/secret-sharing'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdSecretSharingIndexImport
parentRoute: typeof authenticateOrgdetailsLayoutImport
}
- '/_authenticate/_org_details/_org-layout/organization/$organizationId/': {
- id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/'
- path: '/organization/$organizationId'
- fullPath: '/organization/$organizationId'
- preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdIndexImport
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/settings/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/settings/'
+ path: '/organization/$organizationId/settings'
+ fullPath: '/organization/$organizationId/settings'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdSettingsIndexImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/groups/$groupId/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/groups/$groupId/'
+ path: '/organization/$organizationId/groups/$groupId'
+ fullPath: '/organization/$organizationId/groups/$groupId'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdGroupsGroupIdIndexImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/identities/$identityId/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/identities/$identityId/'
+ path: '/organization/$organizationId/identities/$identityId'
+ fullPath: '/organization/$organizationId/identities/$identityId'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdIdentitiesIdentityIdIndexImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/memberships/$membershipId/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/memberships/$membershipId/'
+ path: '/organization/$organizationId/memberships/$membershipId'
+ fullPath: '/organization/$organizationId/memberships/$membershipId'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdMembershipsMembershipIdIndexImport
+ parentRoute: typeof authenticateOrgdetailsLayoutImport
+ }
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/roles/$roleId/': {
+ id: '/_authenticate/_org_details/_org-layout/organization/$organizationId/roles/$roleId/'
+ path: '/organization/$organizationId/roles/$roleId'
+ fullPath: '/organization/$organizationId/roles/$roleId'
+ preLoaderRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdRolesRoleIdIndexImport
parentRoute: typeof authenticateOrgdetailsLayoutImport
}
}
@@ -397,18 +623,60 @@ declare module '@tanstack/react-router' {
interface authenticateOrgdetailsLayoutRouteChildren {
authenticateOrgdetailsOrganizationIndexRoute: typeof authenticateOrgdetailsOrganizationIndexRoute
- authenticateOrgdetailsOrganizationOrganizationIdSecretManagerRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdSecretManagerRoute
- authenticateOrgdetailsOrganizationOrganizationIdIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdIndexRoute
+ authenticateOrgdetailsOrganizationNoneIndexRoute: typeof authenticateOrgdetailsOrganizationNoneIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdCertManagerOverviewRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdCertManagerOverviewRoute
+ authenticateOrgdetailsOrganizationOrganizationIdKmsOverviewRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdKmsOverviewRoute
+ authenticateOrgdetailsOrganizationOrganizationIdSecretManagerOverviewRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdSecretManagerOverviewRoute
+ authenticateOrgdetailsOrganizationOrganizationIdAdminIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdAdminIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdAuditLogsIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdAuditLogsIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdBillingIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdBillingIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdMembersIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdMembersIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdOverviewIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdOverviewIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdSecretScanningIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdSecretScanningIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdSecretSharingIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdSecretSharingIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdSettingsIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdSettingsIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdGroupsGroupIdIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdGroupsGroupIdIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdIdentitiesIdentityIdIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdIdentitiesIdentityIdIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdMembershipsMembershipIdIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdMembershipsMembershipIdIndexRoute
+ authenticateOrgdetailsOrganizationOrganizationIdRolesRoleIdIndexRoute: typeof authenticateOrgdetailsOrganizationOrganizationIdRolesRoleIdIndexRoute
}
const authenticateOrgdetailsLayoutRouteChildren: authenticateOrgdetailsLayoutRouteChildren =
{
authenticateOrgdetailsOrganizationIndexRoute:
authenticateOrgdetailsOrganizationIndexRoute,
- authenticateOrgdetailsOrganizationOrganizationIdSecretManagerRoute:
- authenticateOrgdetailsOrganizationOrganizationIdSecretManagerRoute,
- authenticateOrgdetailsOrganizationOrganizationIdIndexRoute:
- authenticateOrgdetailsOrganizationOrganizationIdIndexRoute,
+ authenticateOrgdetailsOrganizationNoneIndexRoute:
+ authenticateOrgdetailsOrganizationNoneIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdCertManagerOverviewRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdCertManagerOverviewRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdKmsOverviewRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdKmsOverviewRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdSecretManagerOverviewRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdSecretManagerOverviewRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdAdminIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdAdminIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdAuditLogsIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdAuditLogsIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdBillingIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdBillingIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdMembersIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdMembersIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdOverviewIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdOverviewIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdSecretScanningIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdSecretScanningIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdSecretSharingIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdSecretSharingIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdSettingsIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdSettingsIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdGroupsGroupIdIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdGroupsGroupIdIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdIdentitiesIdentityIdIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdIdentitiesIdentityIdIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdMembershipsMembershipIdIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdMembershipsMembershipIdIndexRoute,
+ authenticateOrgdetailsOrganizationOrganizationIdRolesRoleIdIndexRoute:
+ authenticateOrgdetailsOrganizationOrganizationIdRolesRoleIdIndexRoute,
}
const authenticateOrgdetailsLayoutRouteWithChildren =
@@ -540,8 +808,22 @@ export interface FileRoutesByFullPath {
'/login/sso': typeof RestrictloginsignupLoginSsoIndexRoute
'/signup/sso': typeof RestrictloginsignupSignupSsoIndexRoute
'/organization': typeof authenticateOrgdetailsOrganizationIndexRoute
- '/organization/$organizationId/secret-manager': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretManagerRoute
- '/organization/$organizationId': typeof authenticateOrgdetailsOrganizationOrganizationIdIndexRoute
+ '/organization/none': typeof authenticateOrgdetailsOrganizationNoneIndexRoute
+ '/organization/$organizationId/cert-manager/overview': typeof authenticateOrgdetailsOrganizationOrganizationIdCertManagerOverviewRoute
+ '/organization/$organizationId/kms/overview': typeof authenticateOrgdetailsOrganizationOrganizationIdKmsOverviewRoute
+ '/organization/$organizationId/secret-manager/overview': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretManagerOverviewRoute
+ '/organization/$organizationId/admin': typeof authenticateOrgdetailsOrganizationOrganizationIdAdminIndexRoute
+ '/organization/$organizationId/audit-logs': typeof authenticateOrgdetailsOrganizationOrganizationIdAuditLogsIndexRoute
+ '/organization/$organizationId/billing': typeof authenticateOrgdetailsOrganizationOrganizationIdBillingIndexRoute
+ '/organization/$organizationId/members': typeof authenticateOrgdetailsOrganizationOrganizationIdMembersIndexRoute
+ '/organization/$organizationId/overview': typeof authenticateOrgdetailsOrganizationOrganizationIdOverviewIndexRoute
+ '/organization/$organizationId/secret-scanning': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretScanningIndexRoute
+ '/organization/$organizationId/secret-sharing': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretSharingIndexRoute
+ '/organization/$organizationId/settings': typeof authenticateOrgdetailsOrganizationOrganizationIdSettingsIndexRoute
+ '/organization/$organizationId/groups/$groupId': typeof authenticateOrgdetailsOrganizationOrganizationIdGroupsGroupIdIndexRoute
+ '/organization/$organizationId/identities/$identityId': typeof authenticateOrgdetailsOrganizationOrganizationIdIdentitiesIdentityIdIndexRoute
+ '/organization/$organizationId/memberships/$membershipId': typeof authenticateOrgdetailsOrganizationOrganizationIdMembershipsMembershipIdIndexRoute
+ '/organization/$organizationId/roles/$roleId': typeof authenticateOrgdetailsOrganizationOrganizationIdRolesRoleIdIndexRoute
}
export interface FileRoutesByTo {
@@ -563,8 +845,22 @@ export interface FileRoutesByTo {
'/login/sso': typeof RestrictloginsignupLoginSsoIndexRoute
'/signup/sso': typeof RestrictloginsignupSignupSsoIndexRoute
'/organization': typeof authenticateOrgdetailsOrganizationIndexRoute
- '/organization/$organizationId/secret-manager': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretManagerRoute
- '/organization/$organizationId': typeof authenticateOrgdetailsOrganizationOrganizationIdIndexRoute
+ '/organization/none': typeof authenticateOrgdetailsOrganizationNoneIndexRoute
+ '/organization/$organizationId/cert-manager/overview': typeof authenticateOrgdetailsOrganizationOrganizationIdCertManagerOverviewRoute
+ '/organization/$organizationId/kms/overview': typeof authenticateOrgdetailsOrganizationOrganizationIdKmsOverviewRoute
+ '/organization/$organizationId/secret-manager/overview': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretManagerOverviewRoute
+ '/organization/$organizationId/admin': typeof authenticateOrgdetailsOrganizationOrganizationIdAdminIndexRoute
+ '/organization/$organizationId/audit-logs': typeof authenticateOrgdetailsOrganizationOrganizationIdAuditLogsIndexRoute
+ '/organization/$organizationId/billing': typeof authenticateOrgdetailsOrganizationOrganizationIdBillingIndexRoute
+ '/organization/$organizationId/members': typeof authenticateOrgdetailsOrganizationOrganizationIdMembersIndexRoute
+ '/organization/$organizationId/overview': typeof authenticateOrgdetailsOrganizationOrganizationIdOverviewIndexRoute
+ '/organization/$organizationId/secret-scanning': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretScanningIndexRoute
+ '/organization/$organizationId/secret-sharing': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretSharingIndexRoute
+ '/organization/$organizationId/settings': typeof authenticateOrgdetailsOrganizationOrganizationIdSettingsIndexRoute
+ '/organization/$organizationId/groups/$groupId': typeof authenticateOrgdetailsOrganizationOrganizationIdGroupsGroupIdIndexRoute
+ '/organization/$organizationId/identities/$identityId': typeof authenticateOrgdetailsOrganizationOrganizationIdIdentitiesIdentityIdIndexRoute
+ '/organization/$organizationId/memberships/$membershipId': typeof authenticateOrgdetailsOrganizationOrganizationIdMembershipsMembershipIdIndexRoute
+ '/organization/$organizationId/roles/$roleId': typeof authenticateOrgdetailsOrganizationOrganizationIdRolesRoleIdIndexRoute
}
export interface FileRoutesById {
@@ -592,8 +888,22 @@ export interface FileRoutesById {
'/_restrict_login_signup/login/sso/': typeof RestrictloginsignupLoginSsoIndexRoute
'/_restrict_login_signup/signup/sso/': typeof RestrictloginsignupSignupSsoIndexRoute
'/_authenticate/_org_details/_org-layout/organization/': typeof authenticateOrgdetailsOrganizationIndexRoute
- '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretManagerRoute
- '/_authenticate/_org_details/_org-layout/organization/$organizationId/': typeof authenticateOrgdetailsOrganizationOrganizationIdIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/none/': typeof authenticateOrgdetailsOrganizationNoneIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/cert-manager/overview': typeof authenticateOrgdetailsOrganizationOrganizationIdCertManagerOverviewRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/kms/overview': typeof authenticateOrgdetailsOrganizationOrganizationIdKmsOverviewRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager/overview': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretManagerOverviewRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/admin/': typeof authenticateOrgdetailsOrganizationOrganizationIdAdminIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/audit-logs/': typeof authenticateOrgdetailsOrganizationOrganizationIdAuditLogsIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/billing/': typeof authenticateOrgdetailsOrganizationOrganizationIdBillingIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/members/': typeof authenticateOrgdetailsOrganizationOrganizationIdMembersIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/overview/': typeof authenticateOrgdetailsOrganizationOrganizationIdOverviewIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-scanning/': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretScanningIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-sharing/': typeof authenticateOrgdetailsOrganizationOrganizationIdSecretSharingIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/settings/': typeof authenticateOrgdetailsOrganizationOrganizationIdSettingsIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/groups/$groupId/': typeof authenticateOrgdetailsOrganizationOrganizationIdGroupsGroupIdIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/identities/$identityId/': typeof authenticateOrgdetailsOrganizationOrganizationIdIdentitiesIdentityIdIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/memberships/$membershipId/': typeof authenticateOrgdetailsOrganizationOrganizationIdMembershipsMembershipIdIndexRoute
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/roles/$roleId/': typeof authenticateOrgdetailsOrganizationOrganizationIdRolesRoleIdIndexRoute
}
export interface FileRouteTypes {
@@ -618,8 +928,22 @@ export interface FileRouteTypes {
| '/login/sso'
| '/signup/sso'
| '/organization'
- | '/organization/$organizationId/secret-manager'
- | '/organization/$organizationId'
+ | '/organization/none'
+ | '/organization/$organizationId/cert-manager/overview'
+ | '/organization/$organizationId/kms/overview'
+ | '/organization/$organizationId/secret-manager/overview'
+ | '/organization/$organizationId/admin'
+ | '/organization/$organizationId/audit-logs'
+ | '/organization/$organizationId/billing'
+ | '/organization/$organizationId/members'
+ | '/organization/$organizationId/overview'
+ | '/organization/$organizationId/secret-scanning'
+ | '/organization/$organizationId/secret-sharing'
+ | '/organization/$organizationId/settings'
+ | '/organization/$organizationId/groups/$groupId'
+ | '/organization/$organizationId/identities/$identityId'
+ | '/organization/$organizationId/memberships/$membershipId'
+ | '/organization/$organizationId/roles/$roleId'
fileRoutesByTo: FileRoutesByTo
to:
| '/'
@@ -640,8 +964,22 @@ export interface FileRouteTypes {
| '/login/sso'
| '/signup/sso'
| '/organization'
- | '/organization/$organizationId/secret-manager'
- | '/organization/$organizationId'
+ | '/organization/none'
+ | '/organization/$organizationId/cert-manager/overview'
+ | '/organization/$organizationId/kms/overview'
+ | '/organization/$organizationId/secret-manager/overview'
+ | '/organization/$organizationId/admin'
+ | '/organization/$organizationId/audit-logs'
+ | '/organization/$organizationId/billing'
+ | '/organization/$organizationId/members'
+ | '/organization/$organizationId/overview'
+ | '/organization/$organizationId/secret-scanning'
+ | '/organization/$organizationId/secret-sharing'
+ | '/organization/$organizationId/settings'
+ | '/organization/$organizationId/groups/$groupId'
+ | '/organization/$organizationId/identities/$identityId'
+ | '/organization/$organizationId/memberships/$membershipId'
+ | '/organization/$organizationId/roles/$roleId'
id:
| '__root__'
| '/'
@@ -667,8 +1005,22 @@ export interface FileRouteTypes {
| '/_restrict_login_signup/login/sso/'
| '/_restrict_login_signup/signup/sso/'
| '/_authenticate/_org_details/_org-layout/organization/'
- | '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager'
- | '/_authenticate/_org_details/_org-layout/organization/$organizationId/'
+ | '/_authenticate/_org_details/_org-layout/organization/none/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/cert-manager/overview'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/kms/overview'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager/overview'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/admin/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/audit-logs/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/billing/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/members/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/overview/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-scanning/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-sharing/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/settings/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/groups/$groupId/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/identities/$identityId/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/memberships/$membershipId/'
+ | '/_authenticate/_org_details/_org-layout/organization/$organizationId/roles/$roleId/'
fileRoutesById: FileRoutesById
}
@@ -764,8 +1116,22 @@ export const routeTree = rootRoute
"parent": "/_authenticate/_org_details",
"children": [
"/_authenticate/_org_details/_org-layout/organization/",
- "/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager",
- "/_authenticate/_org_details/_org-layout/organization/$organizationId/"
+ "/_authenticate/_org_details/_org-layout/organization/none/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/cert-manager/overview",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/kms/overview",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager/overview",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/admin/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/audit-logs/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/billing/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/members/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/overview/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-scanning/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-sharing/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/settings/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/groups/$groupId/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/identities/$identityId/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/memberships/$membershipId/",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/roles/$roleId/"
]
},
"/_authenticate/personal-settings": {
@@ -822,12 +1188,68 @@ export const routeTree = rootRoute
"filePath": "_authenticate/_org_details/organization/index.tsx",
"parent": "/_authenticate/_org_details/_org-layout"
},
- "/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager": {
- "filePath": "_authenticate/_org_details/organization/$organizationId/secret-manager.tsx",
+ "/_authenticate/_org_details/_org-layout/organization/none/": {
+ "filePath": "_authenticate/_org_details/organization/none/index.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/cert-manager/overview": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/cert-manager/overview.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/kms/overview": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/kms/overview.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager/overview": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/secret-manager/overview.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/admin/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/admin/index.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/audit-logs/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/audit-logs/index.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/billing/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/billing/index.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/members/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/members/index.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/overview/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/overview/index.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-scanning/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/secret-scanning/index.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-sharing/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/secret-sharing/index.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/settings/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/settings/index.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/groups/$groupId/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/groups/$groupId/index.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/identities/$identityId/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/identities/$identityId/index.tsx",
+ "parent": "/_authenticate/_org_details/_org-layout"
+ },
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/memberships/$membershipId/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/index.tsx",
"parent": "/_authenticate/_org_details/_org-layout"
},
- "/_authenticate/_org_details/_org-layout/organization/$organizationId/": {
- "filePath": "_authenticate/_org_details/organization/$organizationId/index.tsx",
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/roles/$roleId/": {
+ "filePath": "_authenticate/_org_details/organization/$organizationId/roles/$roleId/index.tsx",
"parent": "/_authenticate/_org_details/_org-layout"
}
}
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/admin/-components/OrgAdminProjects/OrgAdminProjects.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/admin/-components/OrgAdminProjects/OrgAdminProjects.tsx
new file mode 100644
index 0000000000..164c37a186
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/admin/-components/OrgAdminProjects/OrgAdminProjects.tsx
@@ -0,0 +1,168 @@
+import { useState } from "react";
+import { faEllipsis, faMagnifyingGlass, faSignIn } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { format } from "date-fns";
+import { motion } from "framer-motion";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ EmptyState,
+ Input,
+ Pagination,
+ Spinner,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import {
+ OrgPermissionAdminConsoleAction,
+ OrgPermissionSubjects
+} from "@app/context/OrgPermissionContext/types";
+import { withPermission } from "@app/hoc";
+import { useDebounce } from "@app/hooks";
+import { useOrgAdminAccessProject, useOrgAdminGetProjects } from "@app/hooks/api";
+import { useNavigate } from "@tanstack/react-router";
+import { ProjectType } from "@app/hooks/api/workspace/types";
+
+export const OrgAdminProjects = withPermission(
+ () => {
+ const [page, setPage] = useState(1);
+ const [search, setSearch] = useState("");
+ const [debouncedSearch] = useDebounce(search);
+ const [perPage, setPerPage] = useState(25);
+ const navigate = useNavigate();
+ const orgAdminAccessProject = useOrgAdminAccessProject();
+
+ const { data, isLoading: isProjectsLoading } = useOrgAdminGetProjects({
+ offset: (page - 1) * perPage,
+ limit: perPage,
+ search: debouncedSearch || undefined
+ });
+
+ const projects = data?.projects || [];
+ const projectCount = data?.count || 0;
+ const isEmpty = !isProjectsLoading && projects.length === 0;
+
+ const handleAccessProject = async (type: ProjectType, projectId: string) => {
+ try {
+ await orgAdminAccessProject.mutateAsync({
+ projectId
+ });
+ await navigate({
+ to: `/${type}/$projectId/secrets/overview` as const,
+ params: {
+ projectId
+ }
+ });
+ } catch {
+ createNotification({
+ text: "Failed to access project",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <motion.div
+ key="panel-projects"
+ transition={{ duration: 0.15 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: 30 }}
+ >
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="mb-4 flex justify-between">
+ <p className="text-xl font-semibold text-mineshaft-100">Projects</p>
+ </div>
+ <div>
+ <Input
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search by project name"
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Name</Th>
+ <Th>Slug</Th>
+ <Th>Created At</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isProjectsLoading && <TableSkeleton columns={4} innerKey="projects" />}
+ {!isProjectsLoading &&
+ projects?.map(({ name, slug, createdAt, type, id }) => (
+ <Tr key={`project-${id}`} className="group w-full">
+ <Td>{name}</Td>
+ <Td>{slug}</Td>
+ <Td>{format(new Date(createdAt), "yyyy-MM-dd, hh:mm aaa")}</Td>
+ <Td>
+ <div>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <Button
+ variant="link"
+ className="text-bunker-300 hover:text-primary-400 data-[state=open]:text-primary-400"
+ >
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+ e.preventDefault();
+ handleAccessProject(type, id);
+ }}
+ icon={<FontAwesomeIcon icon={faSignIn} />}
+ disabled={
+ orgAdminAccessProject.variables?.projectId === id &&
+ orgAdminAccessProject.isLoading
+ }
+ >
+ Access{" "}
+ {orgAdminAccessProject.variables?.projectId === id &&
+ orgAdminAccessProject.isLoading && <Spinner size="xs" />}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </Td>
+ </Tr>
+ ))}
+ </TBody>
+ </Table>
+ {!isProjectsLoading && (
+ <Pagination
+ count={projectCount}
+ page={page}
+ perPage={perPage}
+ onChangePage={(newPage) => setPage(newPage)}
+ onChangePerPage={(newPerPage) => setPerPage(newPerPage)}
+ />
+ )}
+ {isEmpty && <EmptyState title="No projects found" />}
+ </TableContainer>
+ </div>
+ </div>
+ </motion.div>
+ );
+ },
+ {
+ action: OrgPermissionAdminConsoleAction.AccessAllProjects,
+ subject: OrgPermissionSubjects.AdminConsole
+ }
+);
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/admin/-components/OrgAdminProjects/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/admin/-components/OrgAdminProjects/index.tsx
new file mode 100644
index 0000000000..b331589a44
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/admin/-components/OrgAdminProjects/index.tsx
@@ -0,0 +1 @@
+export { OrgAdminProjects } from "./OrgAdminProjects";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/admin/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/admin/index.tsx
new file mode 100644
index 0000000000..fd28684218
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/admin/index.tsx
@@ -0,0 +1,53 @@
+import { useState } from 'react'
+import { Helmet } from 'react-helmet'
+import { useTranslation } from 'react-i18next'
+import { createFileRoute } from '@tanstack/react-router'
+
+import { Tab, TabList, TabPanel, Tabs } from '@app/components/v2'
+
+import { OrgAdminProjects } from './-components/OrgAdminProjects'
+
+enum TabSections {
+ Projects = 'projects',
+}
+
+const OrgAdminPage = () => {
+ const { t } = useTranslation()
+ const [activeTab, setActiveTab] = useState<TabSections>(TabSections.Projects)
+ return (
+ <>
+ <Helmet>
+ <title>
+ {t('common.head-title', { title: t('settings.org.title') })}
+ </title>
+ <link rel="icon" href="/infisical.ico" />
+ </Helmet>
+ <div className="flex w-full justify-center bg-bunker-800 py-6 text-white">
+ <div className="w-full max-w-6xl px-6">
+ <div className="mb-4">
+ <p className="text-3xl font-semibold text-gray-200">
+ Organization Admin Console
+ </p>
+ </div>
+ <Tabs
+ value={activeTab}
+ onValueChange={(el) => setActiveTab(el as TabSections)}
+ >
+ <TabList>
+ <Tab value={TabSections.Projects}>Projects</Tab>
+ </TabList>
+ <TabPanel value={TabSections.Projects}>
+ <OrgAdminProjects />
+ </TabPanel>
+ </Tabs>
+ </div>
+ </div>
+ </>
+ )
+}
+
+export const Route = createFileRoute(
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/admin/',
+)({
+ component: OrgAdminPage,
+})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsFilter.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsFilter.tsx
new file mode 100644
index 0000000000..1c644b8217
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsFilter.tsx
@@ -0,0 +1,325 @@
+/* eslint-disable no-nested-ternary */
+import { useEffect, useState } from "react";
+import { Control, Controller, UseFormReset, UseFormSetValue, UseFormWatch } from "react-hook-form";
+import { faCaretDown, faCheckCircle, faFilterCircleXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { twMerge } from "tailwind-merge";
+
+import {
+ Button,
+ DatePicker,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ FilterableSelect,
+ FormControl,
+ Select,
+ SelectItem
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useGetAuditLogActorFilterOpts, useGetUserWorkspaces } from "@app/hooks/api";
+import { eventToNameMap, userAgentTTypeoNameMap } from "@app/hooks/api/auditLogs/constants";
+import { ActorType, EventType } from "@app/hooks/api/auditLogs/enums";
+import { Actor } from "@app/hooks/api/auditLogs/types";
+
+import { AuditLogFilterFormData } from "./types";
+
+const eventTypes = Object.entries(eventToNameMap).map(([value, label]) => ({ label, value }));
+const userAgentTypes = Object.entries(userAgentTTypeoNameMap).map(([value, label]) => ({
+ label,
+ value
+}));
+
+type Props = {
+ presets?: {
+ actorId?: string;
+ eventType?: EventType[];
+ };
+ className?: string;
+ isOrgAuditLogs?: boolean;
+ setValue: UseFormSetValue<AuditLogFilterFormData>;
+ control: Control<AuditLogFilterFormData>;
+ reset: UseFormReset<AuditLogFilterFormData>;
+ watch: UseFormWatch<AuditLogFilterFormData>;
+};
+
+export const LogsFilter = ({
+ presets,
+ isOrgAuditLogs,
+ className,
+ control,
+ setValue,
+ reset,
+ watch
+}: Props) => {
+ const [isStartDatePickerOpen, setIsStartDatePickerOpen] = useState(false);
+ const [isEndDatePickerOpen, setIsEndDatePickerOpen] = useState(false);
+
+ const { data: workspaces = [] } = useGetUserWorkspaces();
+ const { currentOrg } = useOrganization();
+
+ const workspacesInOrg = workspaces.filter((ws) => ws.orgId === currentOrg?.id);
+
+ const { data, isLoading } = useGetAuditLogActorFilterOpts(workspaces?.[0]?.id ?? "");
+
+ useEffect(() => {
+ if (workspacesInOrg.length) {
+ setValue("project", workspacesInOrg[0]);
+ }
+ }, [workspaces]);
+
+ const renderActorSelectItem = (actor: Actor) => {
+ switch (actor.type) {
+ case ActorType.USER:
+ return (
+ <SelectItem
+ value={`${actor.type}-${actor.metadata.userId}`}
+ key={`user-actor-filter-${actor.metadata.userId}`}
+ >
+ {actor.metadata.email}
+ </SelectItem>
+ );
+ case ActorType.SERVICE:
+ return (
+ <SelectItem
+ value={`${actor.type}-${actor.metadata.serviceId}`}
+ key={`service-actor-filter-${actor.metadata.serviceId}`}
+ >
+ {actor.metadata.name}
+ </SelectItem>
+ );
+ case ActorType.IDENTITY:
+ return (
+ <SelectItem
+ value={`${actor.type}-${actor.metadata.identityId}`}
+ key={`identity-filter-${actor.metadata.identityId}`}
+ >
+ {actor.metadata.name}
+ </SelectItem>
+ );
+ default:
+ return (
+ <SelectItem value="actor-none" key="actor-none">
+ N/A
+ </SelectItem>
+ );
+ }
+ };
+
+ const selectedEventTypes = watch("eventType") as EventType[] | undefined;
+
+ return (
+ <div
+ className={twMerge(
+ "sticky top-20 z-10 flex flex-wrap items-center justify-between bg-bunker-800",
+ className
+ )}
+ >
+ {isOrgAuditLogs && workspacesInOrg.length > 0 && (
+ <Controller
+ control={control}
+ name="project"
+ render={({ field: { onChange, value }, fieldState: { error } }) => (
+ <FormControl
+ label="Project"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ className="mr-12 w-64"
+ >
+ <FilterableSelect
+ value={value}
+ onChange={onChange}
+ placeholder="Select a project..."
+ options={workspacesInOrg.map(({ name, id }) => ({ name, id }))}
+ getOptionValue={(option) => option.id}
+ getOptionLabel={(option) => option.name}
+ />
+ </FormControl>
+ )}
+ />
+ )}
+ <div className="mt-1 flex items-center space-x-2">
+ <Controller
+ control={control}
+ name="eventType"
+ render={({ field }) => (
+ <FormControl label="Events">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <div className="inline-flex w-full cursor-pointer items-center justify-between whitespace-nowrap rounded-md border border-mineshaft-500 bg-mineshaft-700 px-3 py-2 font-inter text-sm font-normal text-bunker-200 outline-none data-[placeholder]:text-mineshaft-200">
+ {selectedEventTypes?.length === 1
+ ? eventTypes.find((eventType) => eventType.value === selectedEventTypes[0])
+ ?.label
+ : selectedEventTypes?.length === 0
+ ? "All events"
+ : `${selectedEventTypes?.length} events selected`}
+ <FontAwesomeIcon icon={faCaretDown} className="ml-2 text-xs" />
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="z-[100] max-h-80 overflow-hidden">
+ <div className="max-h-80 overflow-y-auto">
+ {eventTypes && eventTypes.length > 0 ? (
+ eventTypes.map((eventType) => {
+ const isSelected = selectedEventTypes?.includes(
+ eventType.value as EventType
+ );
+
+ return (
+ <DropdownMenuItem
+ onSelect={(event) => eventTypes.length > 1 && event.preventDefault()}
+ onClick={() => {
+ if (selectedEventTypes?.includes(eventType.value as EventType)) {
+ field.onChange(
+ selectedEventTypes?.filter((e: string) => e !== eventType.value)
+ );
+ } else {
+ field.onChange([...(selectedEventTypes || []), eventType.value]);
+ }
+ }}
+ key={`event-type-${eventType.value}`}
+ icon={
+ isSelected ? (
+ <FontAwesomeIcon
+ icon={faCheckCircle}
+ className="pr-0.5 text-primary"
+ />
+ ) : (
+ <div className="pl-[1.01rem]" />
+ )
+ }
+ iconPos="left"
+ className="w-[28.4rem] text-sm"
+ >
+ {eventType.label}
+ </DropdownMenuItem>
+ );
+ })
+ ) : (
+ <div />
+ )}
+ </div>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </FormControl>
+ )}
+ />
+
+ {!isLoading && data && data.length > 0 && !presets?.actorId && (
+ <Controller
+ control={control}
+ name="actor"
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl
+ label="Actor"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ className="w-40"
+ >
+ <Select
+ {...(field.value ? { value: field.value } : { placeholder: "Select" })}
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ className="w-full border border-mineshaft-500 bg-mineshaft-700 text-mineshaft-100"
+ >
+ {data.map((actor) => renderActorSelectItem(actor))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ )}
+ <Controller
+ control={control}
+ name="userAgentType"
+ render={({ field: { onChange, value, ...field }, fieldState: { error } }) => (
+ <FormControl
+ label="Source"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ className="w-40"
+ >
+ <Select
+ value={value === undefined ? "all" : value}
+ {...field}
+ onValueChange={(e) => {
+ if (e === "all") onChange(undefined);
+ else onChange(e);
+ }}
+ className={twMerge("w-full border border-mineshaft-500 bg-mineshaft-700")}
+ >
+ <SelectItem value="all" key="all">
+ All sources
+ </SelectItem>
+ {userAgentTypes.map(({ label, value: userAgent }) => (
+ <SelectItem value={userAgent} key={label}>
+ {label}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="startDate"
+ control={control}
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => {
+ return (
+ <FormControl label="Start date" errorText={error?.message} isError={Boolean(error)}>
+ <DatePicker
+ value={field.value || undefined}
+ onChange={onChange}
+ dateFormat="P"
+ popUpProps={{
+ open: isStartDatePickerOpen,
+ onOpenChange: setIsStartDatePickerOpen
+ }}
+ popUpContentProps={{}}
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <Controller
+ name="endDate"
+ control={control}
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => {
+ return (
+ <FormControl label="End date" errorText={error?.message} isError={Boolean(error)}>
+ <DatePicker
+ value={field.value || undefined}
+ onChange={onChange}
+ dateFormat="P"
+ popUpProps={{
+ open: isEndDatePickerOpen,
+ onOpenChange: setIsEndDatePickerOpen
+ }}
+ popUpContentProps={{}}
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <Button
+ isLoading={false}
+ colorSchema="primary"
+ variant="outline_bg"
+ className="mt-[0.45rem]"
+ type="submit"
+ leftIcon={<FontAwesomeIcon icon={faFilterCircleXmark} />}
+ onClick={() =>
+ reset({
+ eventType: presets?.eventType || [],
+ actor: presets?.actorId,
+ userAgentType: undefined,
+ startDate: undefined,
+ endDate: undefined,
+ project: null
+ })
+ }
+ >
+ Clear filters
+ </Button>
+ </div>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsSection.tsx
new file mode 100644
index 0000000000..4ee8956490
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsSection.tsx
@@ -0,0 +1,115 @@
+import { useEffect } from "react";
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+
+import { UpgradePlanModal } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
+import { withPermission } from "@app/hoc";
+import { ActorType, EventType, UserAgentType } from "@app/hooks/api/auditLogs/enums";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { LogsFilter } from "./LogsFilter";
+import { LogsTable, TAuditLogTableHeader } from "./LogsTable";
+import { AuditLogFilterFormData, auditLogFilterFormSchema } from "./types";
+
+type Props = {
+ presets?: {
+ actorId?: string;
+ eventType?: EventType[];
+ actorType?: ActorType;
+ startDate?: Date;
+ endDate?: Date;
+ eventMetadata?: Record<string, string>;
+ };
+
+ showFilters?: boolean;
+ filterClassName?: string;
+ isOrgAuditLogs?: boolean;
+ showActorColumn?: boolean;
+ remappedHeaders?: Partial<Record<TAuditLogTableHeader, string>>;
+ refetchInterval?: number;
+};
+
+export const LogsSection = withPermission(
+ ({
+ presets,
+ filterClassName,
+ remappedHeaders,
+ isOrgAuditLogs,
+ showActorColumn,
+ refetchInterval,
+ showFilters
+ }: Props) => {
+ const { subscription } = useSubscription();
+
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["upgradePlan"] as const);
+
+ const { control, reset, watch, setValue } = useForm<AuditLogFilterFormData>({
+ resolver: zodResolver(auditLogFilterFormSchema),
+ defaultValues: {
+ project: null,
+ actor: presets?.actorId,
+ eventType: presets?.eventType || [],
+ page: 1,
+ perPage: 10,
+ startDate: presets?.startDate ?? new Date(new Date().setDate(new Date().getDate() - 1)), // day before today
+ endDate: presets?.endDate ?? new Date(new Date(Date.now()).setHours(23, 59, 59, 999)) // end of today
+ }
+ });
+
+ useEffect(() => {
+ if (subscription && !subscription.auditLogs) {
+ handlePopUpOpen("upgradePlan");
+ }
+ }, [subscription]);
+
+ const eventType = watch("eventType") as EventType[] | undefined;
+ const userAgentType = watch("userAgentType") as UserAgentType | undefined;
+ const actor = watch("actor");
+ const projectId = watch("project")?.id;
+
+ const startDate = watch("startDate");
+ const endDate = watch("endDate");
+
+ return (
+ <div>
+ {showFilters && (
+ <LogsFilter
+ isOrgAuditLogs
+ className={filterClassName}
+ presets={presets}
+ control={control}
+ setValue={setValue}
+ watch={watch}
+ reset={reset}
+ />
+ )}
+ <LogsTable
+ refetchInterval={refetchInterval}
+ remappedHeaders={remappedHeaders}
+ isOrgAuditLogs={isOrgAuditLogs}
+ showActorColumn={!!showActorColumn}
+ filter={{
+ eventMetadata: presets?.eventMetadata,
+ projectId,
+ actorType: presets?.actorType,
+ limit: 15,
+ eventType,
+ userAgentType,
+ startDate,
+ endDate,
+ actor
+ }}
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("upgradePlan", isOpen);
+ }}
+ text="You can use audit logs if you switch to a paid Infisical plan."
+ />
+ </div>
+ );
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.AuditLogs }
+);
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsTable.tsx
new file mode 100644
index 0000000000..350b477dd4
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsTable.tsx
@@ -0,0 +1,119 @@
+import { Fragment } from "react";
+import { faFile } from "@fortawesome/free-solid-svg-icons";
+
+import {
+ Button,
+ EmptyState,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useGetAuditLogs } from "@app/hooks/api";
+import { TGetAuditLogsFilter } from "@app/hooks/api/auditLogs/types";
+
+import { LogsTableRow } from "./LogsTableRow";
+
+type Props = {
+ isOrgAuditLogs?: boolean;
+ showActorColumn: boolean;
+ filter?: TGetAuditLogsFilter;
+ remappedHeaders?: Partial<Record<TAuditLogTableHeader, string>>;
+ refetchInterval?: number;
+};
+
+const AUDIT_LOG_LIMIT = 15;
+
+const TABLE_HEADERS = ["Timestamp", "Event", "Project", "Actor", "Source", "Metadata"] as const;
+export type TAuditLogTableHeader = (typeof TABLE_HEADERS)[number];
+
+export const LogsTable = ({
+ showActorColumn,
+ isOrgAuditLogs,
+ filter,
+ remappedHeaders,
+ refetchInterval
+}: Props) => {
+ // TODO(rbr): check this again, there was a filter with current workspace id
+ // Determine the project ID for filtering
+ const filterProjectId =
+ // Use the projectId from the filter if it exists
+ filter?.projectId || null;
+
+ const { data, isLoading, isFetchingNextPage, hasNextPage, fetchNextPage } = useGetAuditLogs(
+ {
+ ...filter,
+ limit: AUDIT_LOG_LIMIT
+ },
+ filterProjectId,
+ {
+ refetchInterval
+ }
+ );
+
+ const isEmpty = !isLoading && !data?.pages?.[0].length;
+
+ return (
+ <div>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ {TABLE_HEADERS.map((header, idx) => {
+ if (
+ (header === "Project" && !isOrgAuditLogs) ||
+ (header === "Actor" && !showActorColumn)
+ ) {
+ return null;
+ }
+
+ return (
+ <Th key={`table-header-${idx + 1}`}>{remappedHeaders?.[header] || header}</Th>
+ );
+ })}
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ data?.pages?.map((group, i) => (
+ <Fragment key={`audit-log-fragment-${i + 1}`}>
+ {group.map((auditLog) => (
+ <LogsTableRow
+ showActorColumn={showActorColumn}
+ isOrgAuditLogs={isOrgAuditLogs}
+ auditLog={auditLog}
+ key={`audit-log-${auditLog.id}`}
+ />
+ ))}
+ </Fragment>
+ ))}
+ {isLoading && <TableSkeleton innerKey="logs-table" columns={5} key="logs" />}
+ {isEmpty && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No audit logs on file" icon={faFile} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ {!isEmpty && (
+ <Button
+ className="mb-20 mt-4 px-4 py-3 text-sm"
+ isFullWidth
+ variant="star"
+ isLoading={isFetchingNextPage}
+ isDisabled={isFetchingNextPage || !hasNextPage}
+ onClick={() => fetchNextPage()}
+ >
+ {hasNextPage ? "Load More" : "End of logs"}
+ </Button>
+ )}
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsTableRow.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsTableRow.tsx
new file mode 100644
index 0000000000..4da98613e0
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/LogsTableRow.tsx
@@ -0,0 +1,101 @@
+import { Td, Tr } from "@app/components/v2";
+import { eventToNameMap, userAgentTTypeoNameMap } from "@app/hooks/api/auditLogs/constants";
+import { ActorType, EventType } from "@app/hooks/api/auditLogs/enums";
+import { Actor, AuditLog } from "@app/hooks/api/auditLogs/types";
+
+type Props = {
+ auditLog: AuditLog;
+ isOrgAuditLogs?: boolean;
+ showActorColumn: boolean;
+};
+
+export const LogsTableRow = ({ auditLog, isOrgAuditLogs, showActorColumn }: Props) => {
+ const renderActor = (actor: Actor) => {
+ if (!actor) {
+ return <Td />;
+ }
+
+ switch (actor.type) {
+ case ActorType.USER:
+ return (
+ <Td>
+ <p>{actor.metadata.email}</p>
+ <p>User</p>
+ </Td>
+ );
+ case ActorType.SERVICE:
+ return (
+ <Td>
+ <p>{`${actor.metadata.name}`}</p>
+ <p>Service token</p>
+ </Td>
+ );
+ case ActorType.IDENTITY:
+ return (
+ <Td>
+ <p>{`${actor.metadata.name}`}</p>
+ <p>Machine Identity</p>
+ </Td>
+ );
+ default:
+ return <Td />;
+ }
+ };
+
+ const formatDate = (dateToFormat: string) => {
+ const date = new Date(dateToFormat);
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, "0");
+ const day = String(date.getDate()).padStart(2, "0");
+
+ let hours = date.getHours();
+ const minutes = String(date.getMinutes()).padStart(2, "0");
+
+ // convert from 24h to 12h format
+ const period = hours >= 12 ? "PM" : "AM";
+ hours %= 12;
+ hours = hours || 12; // the hour '0' should be '12'
+
+ const formattedDate = `${day}-${month}-${year} at ${hours}:${minutes} ${period}`;
+ return formattedDate;
+ };
+
+ const renderSource = () => {
+ const { event, actor } = auditLog;
+
+ if (event.type === EventType.INTEGRATION_SYNCED) {
+ if (actor.type === ActorType.USER) {
+ return (
+ <Td>
+ <p>Manually triggered by {actor.metadata.email}</p>
+ </Td>
+ );
+ }
+
+ // Platform / automatic syncs
+ return (
+ <Td>
+ <p>Automatically synced by Infisical</p>
+ </Td>
+ );
+ }
+
+ return (
+ <Td>
+ <p>{userAgentTTypeoNameMap[auditLog.userAgentType]}</p>
+ <p>{auditLog.ipAddress}</p>
+ </Td>
+ );
+ };
+
+ return (
+ <Tr className={`log-${auditLog.id} h-10 border-x-0 border-b border-t-0`}>
+ <Td>{formatDate(auditLog.createdAt)}</Td>
+ <Td>{`${eventToNameMap[auditLog.event.type]}`}</Td>
+ {isOrgAuditLogs && <Td>{auditLog?.projectName ?? auditLog?.projectId ?? "N/A"}</Td>}
+ {showActorColumn && renderActor(auditLog.actor)}
+ {renderSource()}
+ <Td className="max-w-xs break-all">{JSON.stringify(auditLog.event.metadata || {})}</Td>
+ </Tr>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/index.tsx
new file mode 100644
index 0000000000..e15301e9bc
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/index.tsx
@@ -0,0 +1 @@
+export { LogsSection } from "./LogsSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/types.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/types.tsx
new file mode 100644
index 0000000000..c1c1ef921f
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/-components/types.tsx
@@ -0,0 +1,37 @@
+import { z } from "zod";
+
+import { EventType, UserAgentType } from "@app/hooks/api/auditLogs/enums";
+
+// TODO(rbr): test this schema
+export const auditLogFilterFormSchema = z
+ .object({
+ eventMetadata: z.object({}).optional(),
+ project: z.object({ id: z.string(), name: z.string() }).optional().nullable(),
+ eventType: z.nativeEnum(EventType).array(),
+ actor: z.string().optional(),
+ userAgentType: z.nativeEnum(UserAgentType),
+ startDate: z.date().optional(),
+ endDate: z.date().optional(),
+ page: z.coerce.number().optional(),
+ perPage: z.coerce.number().optional()
+ })
+ .superRefine((el, ctx) => {
+ if (el.endDate && el.startDate && el.endDate < el.startDate) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ path: ["endDate"],
+ message: "End date cannot be before start date"
+ });
+ }
+ });
+
+export type AuditLogFilterFormData = z.infer<typeof auditLogFilterFormSchema>;
+
+export type SetValueType = (
+ name: keyof AuditLogFilterFormData,
+ value: any,
+ options?: {
+ shouldValidate?: boolean;
+ shouldDirty?: boolean;
+ }
+) => void;
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/index.tsx
new file mode 100644
index 0000000000..229bb97175
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/audit-logs/index.tsx
@@ -0,0 +1,31 @@
+import { Helmet } from "react-helmet";
+import { createFileRoute } from "@tanstack/react-router";
+
+import { LogsSection } from "./-components";
+
+const AuditLogsPage = () => {
+ return (
+ <div className="h-full bg-bunker-800">
+ <Helmet>
+ <title>Infisical | Audit Logs</title>
+ <link rel="icon" href="/infisical.ico" />
+ <meta property="og:image" content="/images/message.png" />
+ </Helmet>
+ <div className="flex h-full w-full justify-center bg-bunker-800 text-white">
+ <div className="w-full max-w-7xl px-6">
+ <div className="bg-bunker-800 py-6">
+ <p className="text-3xl font-semibold text-gray-200">Audit Logs</p>
+ <div />
+ </div>
+ <LogsSection filterClassName="static py-2" showFilters isOrgAuditLogs showActorColumn />
+ </div>
+ </div>
+ </div>
+ );
+};
+
+export const Route = createFileRoute(
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/audit-logs/"
+)({
+ component: AuditLogsPage
+});
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/BillingCloudTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/BillingCloudTab.tsx
new file mode 100644
index 0000000000..6085b90c64
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/BillingCloudTab.tsx
@@ -0,0 +1,11 @@
+import { CurrentPlanSection } from "./CurrentPlanSection";
+import { PreviewSection } from "./PreviewSection";
+
+export const BillingCloudTab = () => {
+ return (
+ <div>
+ <PreviewSection />
+ <CurrentPlanSection />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/CurrentPlanSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/CurrentPlanSection.tsx
new file mode 100644
index 0000000000..a3135d85f0
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/CurrentPlanSection.tsx
@@ -0,0 +1,72 @@
+import { faCircleCheck, faCircleXmark, faFileInvoice } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import {
+ EmptyState,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useGetOrgPlanTable } from "@app/hooks/api";
+
+export const CurrentPlanSection = () => {
+ const { currentOrg } = useOrganization();
+ const { data, isLoading } = useGetOrgPlanTable(currentOrg?.id ?? "");
+
+ const displayCell = (value: null | number | string | boolean) => {
+ if (value === null) return "-";
+
+ if (typeof value === "boolean") {
+ if (value) return <FontAwesomeIcon icon={faCircleCheck} color="#2ecc71" />;
+
+ return <FontAwesomeIcon icon={faCircleXmark} color="#e74c3c" />;
+ }
+
+ return value;
+ };
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <h2 className="mb-8 flex-1 text-xl font-semibold text-white">Current usage</h2>
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="w-1/3">Feature</Th>
+ <Th className="w-1/3">Allowed</Th>
+ <Th className="w-1/3">Used</Th>
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ data &&
+ data?.rows?.length > 0 &&
+ data.rows.map(({ name, allowed, used }) => {
+ return (
+ <Tr key={`current-plan-row-${name}`} className="h-12">
+ <Td>{name}</Td>
+ <Td>{displayCell(allowed)}</Td>
+ <Td>{used}</Td>
+ </Tr>
+ );
+ })}
+ {isLoading && <TableSkeleton columns={5} innerKey="invoices" />}
+ {!isLoading && data && data?.rows?.length === 0 && (
+ <Tr>
+ <Td colSpan={3}>
+ <EmptyState title="No plan details found" icon={faFileInvoice} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/ManagePlansModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/ManagePlansModal.tsx
new file mode 100644
index 0000000000..453404d35b
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/ManagePlansModal.tsx
@@ -0,0 +1,62 @@
+import { Fragment } from "react";
+import { Tab } from "@headlessui/react";
+
+import { Modal, ModalContent } from "@app/components/v2";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+import { ManagePlansTable } from "./ManagePlansTable";
+
+type Props = {
+ popUp: UsePopUpState<["managePlan"]>;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["managePlan"]>, state?: boolean) => void;
+};
+
+export const ManagePlansModal = ({ popUp, handlePopUpToggle }: Props) => {
+ return (
+ <Modal
+ isOpen={popUp?.managePlan?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("managePlan", isOpen);
+ }}
+ >
+ <ModalContent className="max-w-screen-lg" title="Infisical Cloud Plans">
+ <Tab.Group>
+ <Tab.List className="max-w-screen-lg border-b-2 border-mineshaft-600">
+ <Tab as={Fragment}>
+ {({ selected }) => (
+ <button
+ type="button"
+ className={`p-4 ${
+ selected ? "border-b-2 border-white text-white" : "text-mineshaft-400"
+ } w-30 font-semibold outline-none`}
+ >
+ Bill monthly
+ </button>
+ )}
+ </Tab>
+ <Tab as={Fragment}>
+ {({ selected }) => (
+ <button
+ type="button"
+ className={`p-4 ${
+ selected ? "border-b-2 border-white text-white" : "text-mineshaft-400"
+ } w-30 font-semibold outline-none`}
+ >
+ Bill yearly
+ </button>
+ )}
+ </Tab>
+ </Tab.List>
+ <Tab.Panels className="mt-4">
+ <Tab.Panel>
+ <ManagePlansTable billingCycle="monthly" />
+ </Tab.Panel>
+ <Tab.Panel>
+ <ManagePlansTable billingCycle="yearly" />
+ </Tab.Panel>
+ </Tab.Panels>
+ </Tab.Group>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/ManagePlansTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/ManagePlansTable.tsx
new file mode 100644
index 0000000000..b37c220123
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/ManagePlansTable.tsx
@@ -0,0 +1,138 @@
+import { faCircleCheck, faCircleXmark, faFileInvoice } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import {
+ Button,
+ EmptyState,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useOrganization, useSubscription } from "@app/context";
+import { useCreateCustomerPortalSession, useGetOrgPlansTable } from "@app/hooks/api";
+
+type Props = {
+ billingCycle: "monthly" | "yearly";
+};
+
+export const ManagePlansTable = ({ billingCycle }: Props) => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+ const { data: tableData, isLoading: isTableDataLoading } = useGetOrgPlansTable({
+ organizationId: currentOrg?.id ?? "",
+ billingCycle
+ });
+ const createCustomerPortalSession = useCreateCustomerPortalSession();
+
+ const displayCell = (value: null | number | string | boolean) => {
+ if (value === null) return "Unlimited";
+
+ if (typeof value === "boolean") {
+ if (value) return <FontAwesomeIcon icon={faCircleCheck} color="#2ecc71" />;
+
+ return <FontAwesomeIcon icon={faCircleXmark} color="#e74c3c" />;
+ }
+
+ return value;
+ };
+
+ return (
+ <TableContainer>
+ <Table>
+ <THead>
+ {subscription && !isTableDataLoading && tableData && (
+ <Tr>
+ <Th className="">Feature / Limit</Th>
+ {tableData.head.map(({ name, priceLine }) => {
+ return (
+ <Th
+ key={`plans-feature-head-${billingCycle}-${name}`}
+ className="flex-1 text-center"
+ >
+ <p>{name}</p>
+ <p>{priceLine}</p>
+ </Th>
+ );
+ })}
+ </Tr>
+ )}
+ </THead>
+ <TBody>
+ {subscription &&
+ !isTableDataLoading &&
+ tableData &&
+ tableData.rows.map(({ name, starter, pro, enterprise }) => {
+ return (
+ <Tr className="h-12" key={`plans-feature-row-${billingCycle}-${name}`}>
+ <Td>{displayCell(name)}</Td>
+ <Td className="text-center">{displayCell(starter)}</Td>
+ <Td className="text-center">{displayCell(pro)}</Td>
+ <Td className="text-center">{displayCell(enterprise)}</Td>
+ </Tr>
+ );
+ })}
+ {isTableDataLoading && <TableSkeleton columns={5} innerKey="cloud-products" />}
+ {!isTableDataLoading && tableData?.rows.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No cloud product details found" icon={faFileInvoice} />
+ </Td>
+ </Tr>
+ )}
+ {subscription && !isTableDataLoading && tableData && (
+ <Tr className="h-12">
+ <Td />
+ {tableData.head.map(({ slug, tier }) => {
+ const isCurrentPlan = slug === subscription.slug;
+ let subscriptionText = "Upgrade";
+
+ if (subscription.tier > tier) {
+ subscriptionText = "Downgrade";
+ }
+
+ if (tier === 3) {
+ subscriptionText = "Contact sales";
+ }
+
+ return isCurrentPlan ? (
+ <Td>
+ <Button colorSchema="secondary" className="w-full" isDisabled>
+ Current
+ </Button>
+ </Td>
+ ) : (
+ <Td>
+ <Button
+ onClick={async () => {
+ if (!currentOrg?.id) return;
+
+ if (tier !== 3) {
+ const { url } = await createCustomerPortalSession.mutateAsync(
+ currentOrg.id
+ );
+ window.location.href = url;
+ return;
+ }
+
+ window.location.href = "https://infisical.com/scheduledemo";
+ }}
+ color="mineshaft"
+ className="w-full"
+ >
+ {subscriptionText}
+ </Button>
+ </Td>
+ );
+ })}
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/PreviewSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/PreviewSection.tsx
new file mode 100644
index 0000000000..a7c4cb4431
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/PreviewSection.tsx
@@ -0,0 +1,172 @@
+import { faArrowUpRightFromSquare } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button } from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import {
+ useCreateCustomerPortalSession,
+ useGetOrgPlanBillingInfo,
+ useGetOrgTrialUrl
+} from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { ManagePlansModal } from "./ManagePlansModal";
+
+export const PreviewSection = () => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+ const { data, isLoading } = useGetOrgPlanBillingInfo(currentOrg?.id ?? "");
+ const getOrgTrialUrl = useGetOrgTrialUrl();
+ const createCustomerPortalSession = useCreateCustomerPortalSession();
+
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["managePlan"] as const);
+
+ const formatAmount = (amount: number) => {
+ const formattedTotal = (Math.floor(amount) / 100).toLocaleString("en-US", {
+ style: "currency",
+ currency: "USD"
+ });
+
+ return formattedTotal;
+ };
+
+ const formatDate = (date: number) => {
+ const createdDate = new Date(date * 1000);
+ const day: number = createdDate.getDate();
+ const month: number = createdDate.getMonth() + 1;
+ const year: number = createdDate.getFullYear();
+ const formattedDate: string = `${day}/${month}/${year}`;
+
+ return formattedDate;
+ };
+
+ function formatPlanSlug(slug: string) {
+ return slug.replace(/(\b[a-z])/g, (match) => match.toUpperCase()).replace(/-/g, " ");
+ }
+
+ const handleUpgradeBtnClick = async () => {
+ try {
+ if (!subscription || !currentOrg) return;
+
+ if (!subscription.has_used_trial) {
+ // direct user to start pro trial
+ const url = await getOrgTrialUrl.mutateAsync({
+ orgId: currentOrg.id,
+ success_url: window.location.href
+ });
+
+ window.location.href = url;
+ } else {
+ // open compare plans modal
+ handlePopUpOpen("managePlan");
+ }
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
+ return (
+ <div>
+ {subscription &&
+ subscription?.slug !== "enterprise" &&
+ subscription?.slug !== "pro" &&
+ subscription?.slug !== "pro-annual" && (
+ <div className="flex flex-row space-x-6">
+ <div className="mb-6 flex flex-1 items-center rounded-lg border border-primary/40 bg-primary/10 p-4">
+ <div className="flex-1">
+ <h2 className="text-xl font-medium text-mineshaft-100">
+ Unleash the full power of{" "}
+ <span className="bg-gradient-to-r from-primary-500 to-yellow bg-clip-text font-semibold text-transparent">
+ Infisical
+ </span>
+ </h2>
+ <p className="mt-4 text-gray-400">
+ Get unlimited members, projects, RBAC, smart alerts, and so much more.
+ </p>
+ </div>
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Billing}>
+ {(isAllowed) => (
+ <Button
+ onClick={() => handleUpgradeBtnClick()}
+ color="mineshaft"
+ isDisabled={!isAllowed}
+ >
+ {!subscription.has_used_trial ? "Start Pro Free Trial" : "Upgrade Plan"}
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <div className="mb-6 flex w-full max-w-[12rem] flex-col items-center rounded-lg border border-mineshaft-600 bg-mineshaft-800 p-4">
+ <div className="mb-4 flex w-full justify-center font-semibold text-mineshaft-200">
+ Want to learn more?{" "}
+ </div>
+ <div className="flex w-full justify-center">
+ <a
+ href="https://infisical.com/schedule-demo"
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ <span className="cursor-pointer rounded-full border border-mineshaft-500 bg-mineshaft-600 px-4 py-2 duration-200 hover:border-primary/40 hover:bg-primary/10">
+ Book a demo{" "}
+ <FontAwesomeIcon
+ icon={faArrowUpRightFromSquare}
+ className="mb-[0.06rem] ml-1 text-xs"
+ />
+ </span>
+ </a>
+ </div>
+ </div>
+ </div>
+ )}
+ {!isLoading && subscription && data && (
+ <div className="mb-6 flex">
+ <div className="mr-4 flex-1 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <p className="mb-2 text-gray-400">Current plan</p>
+ <p className="mb-8 text-2xl font-semibold text-mineshaft-50">
+ {`${formatPlanSlug(subscription.slug)} ${
+ subscription.status === "trialing" ? "(Trial)" : ""
+ }`}
+ </p>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Billing}>
+ {(isAllowed) => (
+ <button
+ type="button"
+ onClick={async () => {
+ if (!currentOrg?.id) return;
+ const { url } = await createCustomerPortalSession.mutateAsync(currentOrg.id);
+ window.location.href = url;
+ }}
+ disabled={!isAllowed}
+ className="text-primary"
+ >
+ Manage plan &rarr;
+ </button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <div className="mr-4 flex-1 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <p className="mb-2 text-gray-400">Price</p>
+ <p className="mb-8 text-2xl font-semibold text-mineshaft-50">
+ {subscription.status === "trialing"
+ ? "$0.00 / month"
+ : `${formatAmount(data.amount)} / ${data.interval}`}
+ </p>
+ </div>
+ <div className="flex-1 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <p className="mb-2 text-gray-400">Subscription renews on</p>
+ <p className="mb-8 text-2xl font-semibold text-mineshaft-50">
+ {formatDate(data.currentPeriodEnd)}
+ </p>
+ </div>
+ </div>
+ )}
+ <ManagePlansModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/index.tsx
new file mode 100644
index 0000000000..341251e997
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingCloudTab/index.tsx
@@ -0,0 +1 @@
+export { BillingCloudTab } from "./BillingCloudTab";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/BillingDetailsTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/BillingDetailsTab.tsx
new file mode 100644
index 0000000000..f422fe0465
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/BillingDetailsTab.tsx
@@ -0,0 +1,15 @@
+import { CompanyNameSection } from "./CompanyNameSection";
+import { InvoiceEmailSection } from "./InvoiceEmailSection";
+import { PmtMethodsSection } from "./PmtMethodsSection";
+import { TaxIDSection } from "./TaxIDSection";
+
+export const BillingDetailsTab = () => {
+ return (
+ <>
+ <CompanyNameSection />
+ <InvoiceEmailSection />
+ <PmtMethodsSection />
+ <TaxIDSection />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/CompanyNameSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/CompanyNameSection.tsx
new file mode 100644
index 0000000000..10df8e43ac
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/CompanyNameSection.tsx
@@ -0,0 +1,91 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, FormControl, Input } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { useGetOrgBillingDetails, useUpdateOrgBillingDetails } from "@app/hooks/api";
+
+const schema = z
+ .object({
+ name: z.string()
+ })
+ .required();
+
+export const CompanyNameSection = () => {
+ const { currentOrg } = useOrganization();
+ const { reset, control, handleSubmit } = useForm({
+ defaultValues: {
+ name: ""
+ },
+ resolver: zodResolver(schema)
+ });
+ const { data } = useGetOrgBillingDetails(currentOrg?.id ?? "");
+ const { mutateAsync, isLoading } = useUpdateOrgBillingDetails();
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ name: data?.name ?? ""
+ });
+ }
+ }, [data]);
+
+ const onFormSubmit = async ({ name }: { name: string }) => {
+ try {
+ if (!currentOrg?.id) return;
+ if (name === "") return;
+ await mutateAsync({
+ name,
+ organizationId: currentOrg.id
+ });
+
+ createNotification({
+ text: "Successfully updated business name",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to update business name",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form
+ onSubmit={handleSubmit(onFormSubmit)}
+ className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"
+ >
+ <h2 className="mb-8 flex-1 text-xl font-semibold text-mineshaft-100">Business name</h2>
+ <div className="max-w-md">
+ <Controller
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl isError={Boolean(error)} errorText={error?.message}>
+ <Input placeholder="Acme Corp" {...field} className="bg-mineshaft-800" />
+ </FormControl>
+ )}
+ control={control}
+ name="name"
+ />
+ </div>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Billing}>
+ {(isAllowed) => (
+ <Button
+ type="submit"
+ colorSchema="secondary"
+ isLoading={isLoading}
+ isDisabled={isLoading || !isAllowed}
+ >
+ Save
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/InvoiceEmailSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/InvoiceEmailSection.tsx
new file mode 100644
index 0000000000..951c2bc33e
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/InvoiceEmailSection.tsx
@@ -0,0 +1,92 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { yupResolver } from "@hookform/resolvers/yup";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, FormControl, Input } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { useGetOrgBillingDetails, useUpdateOrgBillingDetails } from "@app/hooks/api";
+
+const schema = z
+ .object({
+ email: z.string()
+ })
+ .required();
+
+export const InvoiceEmailSection = () => {
+ const { currentOrg } = useOrganization();
+ const { reset, control, handleSubmit } = useForm({
+ defaultValues: {
+ email: ""
+ },
+ resolver: yupResolver(schema)
+ });
+ const { data } = useGetOrgBillingDetails(currentOrg?.id ?? "");
+ const { mutateAsync, isLoading } = useUpdateOrgBillingDetails();
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ email: data?.email ?? ""
+ });
+ }
+ }, [data]);
+
+ const onFormSubmit = async ({ email }: { email: string }) => {
+ try {
+ if (!currentOrg?.id) return;
+ if (email === "") return;
+
+ await mutateAsync({
+ email,
+ organizationId: currentOrg.id
+ });
+
+ createNotification({
+ text: "Successfully updated invoice email recipient",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to update invoice email recipient",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form
+ onSubmit={handleSubmit(onFormSubmit)}
+ className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"
+ >
+ <h2 className="mb-8 flex-1 text-xl font-semibold text-white">Invoice email recipient</h2>
+ <div className="max-w-md">
+ <Controller
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl isError={Boolean(error)} errorText={error?.message}>
+ <Input placeholder="[email protected]" {...field} className="bg-mineshaft-800" />
+ </FormControl>
+ )}
+ control={control}
+ name="email"
+ />
+ </div>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Billing}>
+ {(isAllowed) => (
+ <Button
+ type="submit"
+ colorSchema="secondary"
+ isLoading={isLoading}
+ isDisabled={isLoading || !isAllowed}
+ >
+ Save
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/PmtMethodsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/PmtMethodsSection.tsx
new file mode 100644
index 0000000000..266e529995
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/PmtMethodsSection.tsx
@@ -0,0 +1,47 @@
+import { faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { useAddOrgPmtMethod } from "@app/hooks/api";
+
+import { PmtMethodsTable } from "./PmtMethodsTable";
+
+export const PmtMethodsSection = () => {
+ const { currentOrg } = useOrganization();
+ const { mutateAsync, isLoading } = useAddOrgPmtMethod();
+
+ const handleAddPmtMethodBtnClick = async () => {
+ if (!currentOrg?.id) return;
+ const url = await mutateAsync({
+ organizationId: currentOrg.id,
+ success_url: window.location.href,
+ cancel_url: window.location.href
+ });
+
+ window.location.href = url;
+ };
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="mb-8 flex items-center">
+ <h2 className="flex-1 text-xl font-semibold text-white">Payment methods</h2>
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Billing}>
+ {(isAllowed) => (
+ <Button
+ onClick={handleAddPmtMethodBtnClick}
+ colorSchema="secondary"
+ isLoading={isLoading}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ isDisabled={!isAllowed}
+ >
+ Add method
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <PmtMethodsTable />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/PmtMethodsTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/PmtMethodsTable.tsx
new file mode 100644
index 0000000000..8dfe7e6056
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/PmtMethodsTable.tsx
@@ -0,0 +1,117 @@
+import { faCreditCard, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ DeleteActionModal,
+ EmptyState,
+ IconButton,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { usePopUp } from "@app/hooks";
+import { useDeleteOrgPmtMethod, useGetOrgPmtMethods } from "@app/hooks/api";
+
+export const PmtMethodsTable = () => {
+ const { currentOrg } = useOrganization();
+ const { data, isLoading } = useGetOrgPmtMethods(currentOrg?.id ?? "");
+ const deleteOrgPmtMethod = useDeleteOrgPmtMethod();
+ const { handlePopUpOpen, handlePopUpClose, handlePopUpToggle, popUp } = usePopUp([
+ "removeCard"
+ ] as const);
+
+ const pmtMethodToRemove = popUp.removeCard.data as { id: string; last4: string } | undefined;
+
+ const handleDeletePmtMethodBtnClick = async () => {
+ if (!currentOrg?.id || !pmtMethodToRemove) return;
+ try {
+ await deleteOrgPmtMethod.mutateAsync({
+ organizationId: currentOrg.id,
+ pmtMethodId: pmtMethodToRemove.id
+ });
+ createNotification({
+ type: "success",
+ text: "Successfully removed payment method"
+ });
+ handlePopUpClose("removeCard");
+ } catch (error: any) {
+ createNotification({
+ type: "error",
+ text: error.message ?? "Error removing payment method"
+ });
+ }
+ };
+
+ return (
+ <>
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="flex-1">Brand</Th>
+ <Th className="flex-1">Type</Th>
+ <Th className="flex-1">Last 4 Digits</Th>
+ <Th className="flex-1">Expiration</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ data &&
+ data?.length > 0 &&
+ data.map(({ _id: id, brand, exp_month, exp_year, funding, last4 }) => (
+ <Tr key={`pmt-method-${id}`} className="h-10">
+ <Td>{brand.charAt(0).toUpperCase() + brand.slice(1)}</Td>
+ <Td>{funding.charAt(0).toUpperCase() + funding.slice(1)}</Td>
+ <Td>{last4}</Td>
+ <Td>{`${exp_month}/${exp_year}`}</Td>
+ <Td>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Billing}
+ >
+ {(isAllowed) => (
+ <IconButton
+ onClick={() => handlePopUpOpen("removeCard", { id, last4 })}
+ size="lg"
+ isDisabled={!isAllowed}
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ )}
+ </OrgPermissionCan>
+ </Td>
+ </Tr>
+ ))}
+ {isLoading && <TableSkeleton columns={5} innerKey="pmt-methods" />}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No payment methods on file" icon={faCreditCard} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ <DeleteActionModal
+ isOpen={popUp.removeCard.isOpen}
+ deleteKey="confirm"
+ onChange={(isOpen) => handlePopUpToggle("removeCard", isOpen)}
+ title={`Remove payment method ending in *${pmtMethodToRemove?.last4}?`}
+ onDeleteApproved={handleDeletePmtMethodBtnClick}
+ />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/TaxIDModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/TaxIDModal.tsx
new file mode 100644
index 0000000000..3d0e889f55
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/TaxIDModal.tsx
@@ -0,0 +1,182 @@
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FormControl,
+ Input,
+ Modal,
+ ModalContent,
+ Select,
+ SelectItem
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useAddOrgTaxId } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const taxIDTypes = [
+ { label: "Australia ABN", value: "au_abn" },
+ { label: "Australia ARN", value: "au_arn" },
+ { label: "Bulgaria UIC", value: "bg_uic" },
+ { label: "Brazil CNPJ", value: "br_cnpj" },
+ { label: "Brazil CPF", value: "br_cpf" },
+ { label: "Canada BN", value: "ca_bn" },
+ { label: "Canada GST/HST", value: "ca_gst_hst" },
+ { label: "Canada PST BC", value: "ca_pst_bc" },
+ { label: "Canada PST MB", value: "ca_pst_mb" },
+ { label: "Canada PST SK", value: "ca_pst_sk" },
+ { label: "Canada QST", value: "ca_qst" },
+ { label: "Switzerland VAT", value: "ch_vat" },
+ { label: "Chile TIN", value: "cl_tin" },
+ { label: "Egypt TIN", value: "eg_tin" },
+ { label: "Spain CIF", value: "es_cif" },
+ { label: "EU OSS VAT", value: "eu_oss_vat" },
+ { label: "EU VAT", value: "eu_vat" },
+ { label: "GB VAT", value: "gb_vat" },
+ { label: "Georgia VAT", value: "ge_vat" },
+ { label: "Hong Kong BR", value: "hk_br" },
+ { label: "Hungary TIN", value: "hu_tin" },
+ { label: "Indonesia NPWP", value: "id_npwp" },
+ { label: "Israel VAT", value: "il_vat" },
+ { label: "India GST", value: "in_gst" },
+ { label: "Iceland VAT", value: "is_vat" },
+ { label: "Japan CN", value: "jp_cn" },
+ { label: "Japan RN", value: "jp_rn" },
+ { label: "Japan TRN", value: "jp_trn" },
+ { label: "Kenya PIN", value: "ke_pin" },
+ { label: "South Korea BRN", value: "kr_brn" },
+ { label: "Liechtenstein UID", value: "li_uid" },
+ { label: "Mexico RFC", value: "mx_rfc" },
+ { label: "Malaysia FRP", value: "my_frp" },
+ { label: "Malaysia ITN", value: "my_itn" },
+ { label: "Malaysia SST", value: "my_sst" },
+ { label: "Norway VAT", value: "no_vat" },
+ { label: "New Zealand GST", value: "nz_gst" },
+ { label: "Philippines TIN", value: "ph_tin" },
+ { label: "Russia INN", value: "ru_inn" },
+ { label: "Russia KPP", value: "ru_kpp" },
+ { label: "Saudi Arabia VAT", value: "sa_vat" },
+ { label: "Singapore GST", value: "sg_gst" },
+ { label: "Singapore UEN", value: "sg_uen" },
+ { label: "Slovenia TIN", value: "si_tin" },
+ { label: "Thailand VAT", value: "th_vat" },
+ { label: "Turkey TIN", value: "tr_tin" },
+ { label: "Taiwan VAT", value: "tw_vat" },
+ { label: "Ukraine VAT", value: "ua_vat" },
+ { label: "US EIN", value: "us_ein" },
+ { label: "South Africa VAT", value: "za_vat" }
+];
+
+const schema = z
+ .object({
+ type: z.string(),
+ value: z.string()
+ })
+ .required();
+
+export type AddTaxIDFormData = z.infer<typeof schema>;
+
+type Props = {
+ popUp: UsePopUpState<["addTaxID"]>;
+ handlePopUpClose: (popUpName: keyof UsePopUpState<["addTaxID"]>) => void;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["addTaxID"]>, state?: boolean) => void;
+};
+
+export const TaxIDModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => {
+ const { currentOrg } = useOrganization();
+ const addOrgTaxId = useAddOrgTaxId();
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<AddTaxIDFormData>({
+ resolver: zodResolver(schema)
+ });
+
+ const onTaxIDModalSubmit = async ({ type, value }: AddTaxIDFormData) => {
+ try {
+ if (!currentOrg?.id) return;
+ await addOrgTaxId.mutateAsync({
+ organizationId: currentOrg.id,
+ type,
+ value
+ });
+
+ createNotification({
+ text: "Successfully added Tax ID",
+ type: "success"
+ });
+ handlePopUpClose("addTaxID");
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to add Tax ID",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.addTaxID?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addTaxID", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent title="Add Tax ID">
+ <form onSubmit={handleSubmit(onTaxIDModalSubmit)}>
+ <Controller
+ control={control}
+ name="type"
+ defaultValue="eu_vat"
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl label="Type" errorText={error?.message} isError={Boolean(error)}>
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ className="w-full"
+ >
+ {taxIDTypes.map(({ label, value }) => (
+ <SelectItem value={String(value || "")} key={label}>
+ {label}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="value"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Value" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} placeholder="DE000000000" />
+ </FormControl>
+ )}
+ />
+ <div className="mt-8 flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Add
+ </Button>
+ <Button colorSchema="secondary" variant="plain">
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/TaxIDSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/TaxIDSection.tsx
new file mode 100644
index 0000000000..ecb876aa52
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/TaxIDSection.tsx
@@ -0,0 +1,42 @@
+import { faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { TaxIDModal } from "./TaxIDModal";
+import { TaxIDTable } from "./TaxIDTable";
+
+export const TaxIDSection = () => {
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "addTaxID"
+ ] as const);
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="mb-8 flex items-center">
+ <h2 className="flex-1 text-xl font-semibold text-white">Tax ID</h2>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Billing}>
+ {(isAllowed) => (
+ <Button
+ onClick={() => handlePopUpOpen("addTaxID")}
+ colorSchema="secondary"
+ isDisabled={!isAllowed}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ >
+ Add method
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <TaxIDTable />
+ <TaxIDModal
+ popUp={popUp}
+ handlePopUpClose={handlePopUpClose}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/TaxIDTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/TaxIDTable.tsx
new file mode 100644
index 0000000000..7a6362da2d
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/TaxIDTable.tsx
@@ -0,0 +1,139 @@
+import { faFileInvoice, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ EmptyState,
+ IconButton,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { useDeleteOrgTaxId, useGetOrgTaxIds } from "@app/hooks/api";
+
+const taxIDTypeLabelMap: { [key: string]: string } = {
+ au_abn: "Australia ABN",
+ au_arn: "Australia ARN",
+ bg_uic: "Bulgaria UIC",
+ br_cnpj: "Brazil CNPJ",
+ br_cpf: "Brazil CPF",
+ ca_bn: "Canada BN",
+ ca_gst_hst: "Canada GST/HST",
+ ca_pst_bc: "Canada PST BC",
+ ca_pst_mb: "Canada PST MB",
+ ca_pst_sk: "Canada PST SK",
+ ca_qst: "Canada QST",
+ ch_vat: "Switzerland VAT",
+ cl_tin: "Chile TIN",
+ eg_tin: "Egypt TIN",
+ es_cif: "Spain CIF",
+ eu_oss_vat: "EU OSS VAT",
+ eu_vat: "EU VAT",
+ gb_vat: "GB VAT",
+ ge_vat: "Georgia VAT",
+ hk_br: "Hong Kong BR",
+ hu_tin: "Hungary TIN",
+ id_npwp: "Indonesia NPWP",
+ il_vat: "Israel VAT",
+ in_gst: "India GST",
+ is_vat: "Iceland VAT",
+ jp_cn: "Japan CN",
+ jp_rn: "Japan RN",
+ jp_trn: "Japan TRN",
+ ke_pin: "Kenya PIN",
+ kr_brn: "South Korea BRN",
+ li_uid: "Liechtenstein UID",
+ mx_rfc: "Mexico RFC",
+ my_frp: "Malaysia FRP",
+ my_itn: "Malaysia ITN",
+ my_sst: "Malaysia SST",
+ no_vat: "Norway VAT",
+ nz_gst: "New Zealand GST",
+ ph_tin: "Philippines TIN",
+ ru_inn: "Russia INN",
+ ru_kpp: "Russia KPP",
+ sa_vat: "Saudi Arabia VAT",
+ sg_gst: "Singapore GST",
+ sg_uen: "Singapore UEN",
+ si_tin: "Slovenia TIN",
+ th_vat: "Thailand VAT",
+ tr_tin: "Turkey TIN",
+ tw_vat: "Taiwan VAT",
+ ua_vat: "Ukraine VAT",
+ us_ein: "US EIN",
+ za_vat: "South Africa VAT"
+};
+
+export const TaxIDTable = () => {
+ const { currentOrg } = useOrganization();
+ const { data, isLoading } = useGetOrgTaxIds(currentOrg?.id ?? "");
+ const deleteOrgTaxId = useDeleteOrgTaxId();
+
+ const handleDeleteTaxIdBtnClick = async (taxId: string) => {
+ if (!currentOrg?.id) return;
+ await deleteOrgTaxId.mutateAsync({
+ organizationId: currentOrg.id,
+ taxId
+ });
+ };
+
+ return (
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="flex-1">Type</Th>
+ <Th className="flex-1">Value</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ data &&
+ data?.length > 0 &&
+ data.map(({ id, type, value }) => (
+ <Tr key={`tax-id-${id}`} className="h-10">
+ <Td>{taxIDTypeLabelMap[type]}</Td>
+ <Td>{value}</Td>
+ <Td>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Billing}
+ >
+ {(isAllowed) => (
+ <IconButton
+ onClick={async () => {
+ await handleDeleteTaxIdBtnClick(id);
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ isDisabled={!isAllowed}
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ )}
+ </OrgPermissionCan>
+ </Td>
+ </Tr>
+ ))}
+ {isLoading && <TableSkeleton columns={3} innerKey="tax-ids" />}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No Tax IDs on file" icon={faFileInvoice} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/index.tsx
new file mode 100644
index 0000000000..346c0f7d3d
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingDetailsTab/index.tsx
@@ -0,0 +1 @@
+export { BillingDetailsTab } from "./BillingDetailsTab";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingReceiptsTab/BillingReceiptsTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingReceiptsTab/BillingReceiptsTab.tsx
new file mode 100644
index 0000000000..0ae6d2c77c
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingReceiptsTab/BillingReceiptsTab.tsx
@@ -0,0 +1,10 @@
+import { InvoicesTable } from "./InvoicesTable";
+
+export const BillingReceiptsTab = () => {
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <h2 className="flex-1 text-xl font-semibold text-white">Invoices</h2>
+ <InvoicesTable />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingReceiptsTab/InvoicesTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingReceiptsTab/InvoicesTable.tsx
new file mode 100644
index 0000000000..bc6032a676
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingReceiptsTab/InvoicesTable.tsx
@@ -0,0 +1,80 @@
+import { faDownload, faFileInvoice } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import {
+ EmptyState,
+ IconButton,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useGetOrgInvoices } from "@app/hooks/api";
+
+export const InvoicesTable = () => {
+ const { currentOrg } = useOrganization();
+ const { data, isLoading } = useGetOrgInvoices(currentOrg?.id ?? "");
+ return (
+ <TableContainer className="mt-8">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="flex-1">Invoice #</Th>
+ <Th className="flex-1">Date</Th>
+ <Th className="flex-1">Status</Th>
+ <Th className="flex-1">Amount</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ data &&
+ data?.length > 0 &&
+ data.map(({ id, created, paid, number, total, invoice_pdf }) => {
+ const formattedTotal = (Math.floor(total) / 100).toLocaleString("en-US", {
+ style: "currency",
+ currency: "USD"
+ });
+ const createdDate = new Date(created * 1000);
+ const day: number = createdDate.getDate();
+ const month: number = createdDate.getMonth() + 1;
+ const year: number = createdDate.getFullYear();
+ const formattedDate: string = `${day}/${month}/${year}`;
+
+ return (
+ <Tr key={`invoice-${id}`} className="h-10">
+ <Td>{number}</Td>
+ <Td>{formattedDate}</Td>
+ <Td>{paid ? "Paid" : "Not Paid"}</Td>
+ <Td>{formattedTotal}</Td>
+ <Td>
+ <IconButton
+ onClick={async () => window.open(invoice_pdf)}
+ size="lg"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faDownload} />
+ </IconButton>
+ </Td>
+ </Tr>
+ );
+ })}
+ {isLoading && <TableSkeleton columns={5} innerKey="invoices" />}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No invoices on file" icon={faFileInvoice} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingReceiptsTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingReceiptsTab/index.tsx
new file mode 100644
index 0000000000..eec019952c
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingReceiptsTab/index.tsx
@@ -0,0 +1 @@
+export { BillingReceiptsTab } from "./BillingReceiptsTab";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingSelfHostedTab/BillingSelfHostedTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingSelfHostedTab/BillingSelfHostedTab.tsx
new file mode 100644
index 0000000000..c5a8d8f94e
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingSelfHostedTab/BillingSelfHostedTab.tsx
@@ -0,0 +1,9 @@
+import { LicensesSection } from "./LicensesSection";
+
+export const BillingSelfHostedTab = () => {
+ return (
+ <div>
+ <LicensesSection />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingSelfHostedTab/LicensesSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingSelfHostedTab/LicensesSection.tsx
new file mode 100644
index 0000000000..919d8eabbe
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingSelfHostedTab/LicensesSection.tsx
@@ -0,0 +1,63 @@
+import { faFileContract } from "@fortawesome/free-solid-svg-icons";
+
+import {
+ EmptyState,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useGetOrgLicenses } from "@app/hooks/api";
+
+export const LicensesSection = () => {
+ const { currentOrg } = useOrganization();
+ const { data, isLoading } = useGetOrgLicenses(currentOrg?.id ?? "");
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <h2 className="mb-8 flex-1 text-xl font-semibold text-white">Enterprise licenses</h2>
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th>License Key</Th>
+ <Th>Status</Th>
+ <Th>Issued Date</Th>
+ <Th>Expiry Date</Th>
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ data &&
+ data?.length > 0 &&
+ data.map(({ id, licenseKey, isActivated, createdAt, expiresAt }) => {
+ const formattedCreatedAt = new Date(createdAt).toISOString().split("T")[0];
+ const formattedExpiresAt = new Date(expiresAt).toISOString().split("T")[0];
+ return (
+ <Tr key={`license-${id}`} className="h-10">
+ <Td>{licenseKey}</Td>
+ <Td>{isActivated ? "Active" : "Inactive"}</Td>
+ <Td>{formattedCreatedAt}</Td>
+ <Td>{formattedExpiresAt}</Td>
+ </Tr>
+ );
+ })}
+ {isLoading && <TableSkeleton columns={4} innerKey="licenses" />}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={4}>
+ <EmptyState title="No enterprise licenses on file" icon={faFileContract} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingSelfHostedTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingSelfHostedTab/index.tsx
new file mode 100644
index 0000000000..da9282157a
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingSelfHostedTab/index.tsx
@@ -0,0 +1 @@
+export * from "./BillingSelfHostedTab";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingTabGroup/BillingTabGroup.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingTabGroup/BillingTabGroup.tsx
new file mode 100644
index 0000000000..6d8b59d2a7
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingTabGroup/BillingTabGroup.tsx
@@ -0,0 +1,42 @@
+import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { withPermission } from "@app/hoc";
+
+import { BillingCloudTab } from "../BillingCloudTab";
+import { BillingDetailsTab } from "../BillingDetailsTab";
+import { BillingReceiptsTab } from "../BillingReceiptsTab";
+import { BillingSelfHostedTab } from "../BillingSelfHostedTab";
+
+const tabs = [
+ { name: "Infisical Cloud", key: "tab-infisical-cloud" },
+ { name: "Infisical Self-Hosted", key: "tab-infisical-self-hosted" },
+ { name: "Receipts", key: "tab-receipts" },
+ { name: "Billing details", key: "tab-billing-details" }
+];
+
+export const BillingTabGroup = withPermission(
+ () => {
+ return (
+ <Tabs defaultValue={tabs[0].key}>
+ <TabList>
+ {tabs.map((tab) => (
+ <Tab value={tab.key}>{tab.name}</Tab>
+ ))}
+ </TabList>
+ <TabPanel value={tabs[0].key}>
+ <BillingCloudTab />
+ </TabPanel>
+ <TabPanel value={tabs[1].key}>
+ <BillingSelfHostedTab />
+ </TabPanel>
+ <TabPanel value={tabs[2].key}>
+ <BillingReceiptsTab />
+ </TabPanel>
+ <TabPanel value={tabs[3].key}>
+ <BillingDetailsTab />
+ </TabPanel>
+ </Tabs>
+ );
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Billing }
+);
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingTabGroup/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingTabGroup/index.tsx
new file mode 100644
index 0000000000..8ad1fb5b87
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/BillingTabGroup/index.tsx
@@ -0,0 +1 @@
+export { BillingTabGroup } from "./BillingTabGroup";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/index.tsx
new file mode 100644
index 0000000000..8ad1fb5b87
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/-components/index.tsx
@@ -0,0 +1 @@
+export { BillingTabGroup } from "./BillingTabGroup";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/index.tsx
new file mode 100644
index 0000000000..dc2a0de6a1
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/billing/index.tsx
@@ -0,0 +1,52 @@
+import { Helmet } from 'react-helmet'
+import { useTranslation } from 'react-i18next'
+import { createFileRoute } from '@tanstack/react-router'
+
+import { OrgPermissionActions, OrgPermissionSubjects } from '@app/context'
+import { withPermission } from '@app/hoc'
+
+import { BillingTabGroup } from './-components'
+
+const BillngPage = withPermission(
+ () => {
+ const { t } = useTranslation()
+ return (
+ <div className="flex h-full w-full justify-center bg-bunker-800 text-white">
+ <div className="w-full max-w-7xl px-6">
+ <div className="my-6">
+ <p className="text-3xl font-semibold text-gray-200">
+ {t('billing.title')}
+ </p>
+ <div />
+ </div>
+ <BillingTabGroup />
+ </div>
+ </div>
+ )
+ },
+ {
+ action: OrgPermissionActions.Read,
+ subject: OrgPermissionSubjects.Billing,
+ },
+)
+
+const BillingRoute = () => {
+ const { t } = useTranslation()
+
+ return (
+ <div className="h-full bg-bunker-800">
+ <Helmet>
+ <title>{t('common.head-title', { title: t('billing.title') })}</title>
+ <link rel="icon" href="/infisical.ico" />
+ <meta property="og:image" content="/images/message.png" />
+ </Helmet>
+ <BillngPage />
+ </div>
+ )
+}
+
+export const Route = createFileRoute(
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/billing/',
+)({
+ component: BillingRoute,
+})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/cert-manager/overview.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/cert-manager/overview.tsx
new file mode 100644
index 0000000000..5be0fdc596
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/cert-manager/overview.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from "@tanstack/react-router";
+
+import { ProjectType } from "@app/hooks/api/workspace/types";
+
+import { ProductOverview } from "../secret-manager/overview";
+
+const CertManagerOverviewPage = () => <ProductOverview type={ProjectType.CertificateManager} />;
+
+export const Route = createFileRoute(
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/cert-manager/overview"
+)({
+ component: CertManagerOverviewPage
+});
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/AddGroupMemberModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/AddGroupMemberModal.tsx
new file mode 100644
index 0000000000..38cf33c2de
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/AddGroupMemberModal.tsx
@@ -0,0 +1,172 @@
+import { useState } from "react";
+import { faMagnifyingGlass, faUsers } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ EmptyState,
+ Input,
+ Modal,
+ ModalContent,
+ Pagination,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { useDebounce, useResetPageHelper } from "@app/hooks";
+import { useAddUserToGroup, useListGroupUsers } from "@app/hooks/api";
+import { EFilterReturnedUsers } from "@app/hooks/api/groups/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+type Props = {
+ popUp: UsePopUpState<["addGroupMembers"]>;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["addGroupMembers"]>, state?: boolean) => void;
+};
+
+export const AddGroupMembersModal = ({ popUp, handlePopUpToggle }: Props) => {
+ const [page, setPage] = useState(1);
+ const [perPage, setPerPage] = useState(10);
+ const [searchMemberFilter, setSearchMemberFilter] = useState("");
+ const [debouncedSearch] = useDebounce(searchMemberFilter);
+
+ const popUpData = popUp?.addGroupMembers?.data as {
+ groupId: string;
+ slug: string;
+ };
+
+ const offset = (page - 1) * perPage;
+ const { data, isLoading } = useListGroupUsers({
+ id: popUpData?.groupId,
+ groupSlug: popUpData?.slug,
+ offset,
+ limit: perPage,
+ search: debouncedSearch,
+ filter: EFilterReturnedUsers.NON_MEMBERS
+ });
+
+ const { totalCount = 0 } = data ?? {};
+
+ useResetPageHelper({
+ totalCount,
+ offset,
+ setPage
+ });
+
+ const { mutateAsync: addUserToGroupMutateAsync } = useAddUserToGroup();
+
+ const handleAddMember = async (username: string) => {
+ try {
+ if (!popUpData?.slug) {
+ createNotification({
+ text: "Some data is missing, please refresh the page and try again",
+ type: "error"
+ });
+ return;
+ }
+
+ await addUserToGroupMutateAsync({
+ groupId: popUpData.groupId,
+ username,
+ slug: popUpData.slug
+ });
+
+ createNotification({
+ text: "Successfully assigned user to the group",
+ type: "success"
+ });
+ } catch {
+ createNotification({
+ text: "Failed to assign user to the group",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.addGroupMembers?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addGroupMembers", isOpen);
+ }}
+ >
+ <ModalContent title="Add Group Members">
+ <Input
+ value={searchMemberFilter}
+ onChange={(e) => setSearchMemberFilter(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search members..."
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th>User</Th>
+ <Th />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={2} innerKey="group-users" />}
+ {!isLoading &&
+ data?.users?.map(({ id, firstName, lastName, username }) => {
+ return (
+ <Tr className="items-center" key={`group-user-${id}`}>
+ <Td>
+ <p>{`${firstName ?? "-"} ${lastName ?? ""}`}</p>
+ <p>{username}</p>
+ </Td>
+ <Td className="flex justify-end">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Groups}
+ >
+ {(isAllowed) => {
+ return (
+ <Button
+ isLoading={isLoading}
+ isDisabled={!isAllowed}
+ colorSchema="primary"
+ variant="outline_bg"
+ type="submit"
+ onClick={() => handleAddMember(username)}
+ >
+ Assign
+ </Button>
+ );
+ }}
+ </OrgPermissionCan>
+ </Td>
+ </Tr>
+ );
+ })}
+ </TBody>
+ </Table>
+ {!isLoading && totalCount > 0 && (
+ <Pagination
+ count={totalCount}
+ page={page}
+ perPage={perPage}
+ onChangePage={(newPage) => setPage(newPage)}
+ onChangePerPage={(newPerPage) => setPerPage(newPerPage)}
+ />
+ )}
+ {!isLoading && !data?.users?.length && (
+ <EmptyState
+ title={
+ debouncedSearch ? "No users match search" : "All users are already in the group"
+ }
+ icon={faUsers}
+ />
+ )}
+ </TableContainer>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupCreateUpdateModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupCreateUpdateModal.tsx
new file mode 100644
index 0000000000..42f2c73aaa
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupCreateUpdateModal.tsx
@@ -0,0 +1,192 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FilterableSelect,
+ FormControl,
+ Input,
+ Modal,
+ ModalContent
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { findOrgMembershipRole } from "@app/helpers/roles";
+import { useCreateGroup, useGetOrgRoles, useUpdateGroup } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const GroupFormSchema = z.object({
+ name: z.string().min(1, "Name cannot be empty").max(50, "Name must be 50 characters or fewer"),
+ slug: z
+ .string()
+ .min(5, "Slug must be at least 5 characters long")
+ .max(36, "Slug must be 36 characters or fewer"),
+ role: z.object({ name: z.string(), slug: z.string() })
+});
+
+export type TGroupFormData = z.infer<typeof GroupFormSchema>;
+
+type Props = {
+ popUp: UsePopUpState<["groupCreateUpdate"]>;
+ handlePopUpClose: (popUpName: keyof UsePopUpState<["groupCreateUpdate"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["groupCreateUpdate"]>,
+ state?: boolean
+ ) => void;
+};
+
+export const GroupCreateUpdateModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => {
+ const { currentOrg } = useOrganization();
+ const { data: roles } = useGetOrgRoles(currentOrg?.id || "");
+ const { mutateAsync: createMutateAsync, isLoading: createIsLoading } = useCreateGroup();
+ const { mutateAsync: updateMutateAsync, isLoading: updateIsLoading } = useUpdateGroup();
+
+ const { control, handleSubmit, reset } = useForm<TGroupFormData>({
+ resolver: zodResolver(GroupFormSchema)
+ });
+
+ useEffect(() => {
+ const group = popUp?.groupCreateUpdate?.data as {
+ groupId: string;
+ name: string;
+ slug: string;
+ role: string;
+ customRole: {
+ name: string;
+ slug: string;
+ };
+ };
+
+ if (!roles?.length) return;
+
+ if (group) {
+ reset({
+ name: group.name,
+ slug: group.slug,
+ role: group?.customRole ?? findOrgMembershipRole(roles, group.role)
+ });
+ } else {
+ reset({
+ name: "",
+ slug: "",
+ role: findOrgMembershipRole(roles, currentOrg!.defaultMembershipRole)
+ });
+ }
+ }, [popUp?.groupCreateUpdate?.data, roles]);
+
+ const onGroupModalSubmit = async ({ name, slug, role }: TGroupFormData) => {
+ try {
+ if (!currentOrg?.id) return;
+
+ const group = popUp?.groupCreateUpdate?.data as {
+ groupId: string;
+ name: string;
+ slug: string;
+ };
+
+ if (group) {
+ await updateMutateAsync({
+ id: group.groupId,
+ name,
+ slug,
+ role: role.slug || undefined
+ });
+ } else {
+ await createMutateAsync({
+ name,
+ slug,
+ organizationId: currentOrg.id,
+ role: role.slug || undefined
+ });
+ }
+ handlePopUpToggle("groupCreateUpdate", false);
+ reset();
+
+ createNotification({
+ text: `Successfully ${popUp?.groupCreateUpdate?.data ? "updated" : "created"} group`,
+ type: "success"
+ });
+ } catch {
+ createNotification({
+ text: `Failed to ${popUp?.groupCreateUpdate?.data ? "updated" : "created"} group`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.groupCreateUpdate?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("groupCreateUpdate", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent
+ bodyClassName="overflow-visible"
+ title={`${popUp?.groupCreateUpdate?.data ? "Update" : "Create"} Group`}
+ >
+ <form onSubmit={handleSubmit(onGroupModalSubmit)}>
+ <Controller
+ control={control}
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Name" errorText={error?.message} isError={Boolean(error)}>
+ <Input {...field} placeholder="Engineering" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="slug"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Slug" errorText={error?.message} isError={Boolean(error)}>
+ <Input {...field} placeholder="engineering" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="role"
+ render={({ field: { onChange, value }, fieldState: { error } }) => (
+ <FormControl
+ label="Role"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ className="mt-4"
+ >
+ <FilterableSelect
+ options={roles}
+ placeholder="Select role..."
+ onChange={onChange}
+ value={value}
+ getOptionValue={(option) => option.slug}
+ getOptionLabel={(option) => option.name}
+ />
+ </FormControl>
+ )}
+ />
+ <div className="mt-8 flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={createIsLoading || updateIsLoading}
+ >
+ {!popUp?.groupCreateUpdate?.data ? "Create" : "Update"}
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpClose("groupCreateUpdate")}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupDetailsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupDetailsSection.tsx
new file mode 100644
index 0000000000..2b46740078
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupDetailsSection.tsx
@@ -0,0 +1,88 @@
+import { faPencil } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { IconButton, Spinner, Tooltip } from "@app/components/v2";
+import { CopyButton } from "@app/components/v2/CopyButton";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { useGetGroupById } from "@app/hooks/api/";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+type Props = {
+ groupId: string;
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["groupCreateUpdate"]>, data?: object) => void;
+};
+
+export const GroupDetailsSection = ({ groupId, handlePopUpOpen }: Props) => {
+ const { data, isLoading } = useGetGroupById(groupId);
+
+ if (isLoading) return <Spinner size="sm" className="ml-2 mt-2" />;
+
+ return data ? (
+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <h3 className="text-lg font-semibold text-mineshaft-100">Group Details</h3>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Groups}>
+ {(isAllowed) => {
+ return (
+ <Tooltip content="Edit Group">
+ <IconButton
+ isDisabled={!isAllowed}
+ ariaLabel="edit group button"
+ variant="plain"
+ className="group relative"
+ onClick={() => {
+ handlePopUpOpen("groupCreateUpdate", {
+ groupId,
+ name: data.group.name,
+ slug: data.group.slug,
+ role: data.group.role
+ });
+ }}
+ >
+ <FontAwesomeIcon icon={faPencil} />
+ </IconButton>
+ </Tooltip>
+ );
+ }}
+ </OrgPermissionCan>
+ </div>
+ <div className="pt-4">
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Group ID</p>
+ <div className="group flex items-center gap-2">
+ <p className="text-sm text-mineshaft-300">{data.group.id}</p>
+ <CopyButton value={data.group.id} name="Group ID" size="xs" variant="plain" />
+ </div>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Name</p>
+ <p className="text-sm text-mineshaft-300">{data.group.name}</p>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Slug</p>
+ <div className="group flex items-center gap-2">
+ <p className="text-sm text-mineshaft-300">{data.group.slug}</p>
+ <CopyButton value={data.group.slug} name="Slug" size="xs" variant="plain" />
+ </div>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Organization Role</p>
+ <p className="text-sm text-mineshaft-300">{data.group.role}</p>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Created At</p>
+ <p className="text-sm text-mineshaft-300">
+ {new Date(data.group.createdAt).toLocaleString()}
+ </p>
+ </div>
+ </div>
+ </div>
+ ) : (
+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <p className="text-mineshaft-300">Group data not found</p>
+ </div>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/GroupMembersSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/GroupMembersSection.tsx
new file mode 100644
index 0000000000..33a5e1f541
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/GroupMembersSection.tsx
@@ -0,0 +1,90 @@
+import { faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { DeleteActionModal, IconButton } from "@app/components/v2";
+import { useRemoveUserFromGroup } from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { AddGroupMembersModal } from "../AddGroupMemberModal";
+import { GroupMembersTable } from "./GroupMembersTable";
+
+type Props = {
+ groupId: string;
+ groupSlug: string;
+};
+
+export const GroupMembersSection = ({ groupId, groupSlug }: Props) => {
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([
+ "addGroupMembers",
+ "removeMemberFromGroup"
+ ] as const);
+
+ const { mutateAsync: removeUserFromGroupMutateAsync } = useRemoveUserFromGroup();
+ const handleRemoveUserFromGroup = async (username: string) => {
+ try {
+ await removeUserFromGroupMutateAsync({
+ groupId,
+ username,
+ slug: groupSlug
+ });
+
+ createNotification({
+ text: `Successfully removed user ${username} from the group`,
+ type: "success"
+ });
+
+ handlePopUpToggle("removeMemberFromGroup", false);
+ } catch {
+ createNotification({
+ text: `Failed to remove user ${username} from the group`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <div className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <h3 className="text-lg font-semibold text-mineshaft-100">Group Members</h3>
+ <IconButton
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={() => {
+ handlePopUpOpen("addGroupMembers", {
+ groupId,
+ slug: groupSlug
+ });
+ }}
+ >
+ <FontAwesomeIcon icon={faPlus} />
+ </IconButton>
+ </div>
+ <div className="py-4">
+ <GroupMembersTable
+ groupId={groupId}
+ groupSlug={groupSlug}
+ handlePopUpOpen={handlePopUpOpen}
+ />
+ </div>
+ <AddGroupMembersModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
+ <DeleteActionModal
+ isOpen={popUp.removeMemberFromGroup.isOpen}
+ title={`Are you sure want to remove ${
+ (popUp?.removeMemberFromGroup?.data as { username: string })?.username || ""
+ } from the group?`}
+ onChange={(isOpen) => handlePopUpToggle("removeMemberFromGroup", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() => {
+ const userData = popUp?.removeMemberFromGroup?.data as {
+ username: string;
+ id: string;
+ };
+
+ return handleRemoveUserFromGroup(userData.username);
+ }}
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/GroupMembersTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/GroupMembersTable.tsx
new file mode 100644
index 0000000000..8c3268dab8
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/GroupMembersTable.tsx
@@ -0,0 +1,195 @@
+import { useMemo } from "react";
+import {
+ faArrowDown,
+ faArrowUp,
+ faFolder,
+ faMagnifyingGlass,
+ faSearch
+} from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ EmptyState,
+ IconButton,
+ Input,
+ Pagination,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { usePagination, useResetPageHelper } from "@app/hooks";
+import { useListGroupUsers } from "@app/hooks/api";
+import { OrderByDirection } from "@app/hooks/api/generic/types";
+import { EFilterReturnedUsers } from "@app/hooks/api/groups/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+import { GroupMembershipRow } from "./GroupMembershipRow";
+
+type Props = {
+ groupId: string;
+ groupSlug: string;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["removeMemberFromGroup", "addGroupMembers"]>,
+ data?: object
+ ) => void;
+};
+
+enum GroupMembersOrderBy {
+ Name = "name"
+}
+
+export const GroupMembersTable = ({ groupId, groupSlug, handlePopUpOpen }: Props) => {
+ const {
+ search,
+ setSearch,
+ setPage,
+ page,
+ perPage,
+ setPerPage,
+ offset,
+ orderDirection,
+ toggleOrderDirection
+ } = usePagination(GroupMembersOrderBy.Name, { initPerPage: 10 });
+
+ const { data: groupMemberships, isLoading } = useListGroupUsers({
+ id: groupId,
+ groupSlug,
+ offset,
+ limit: perPage,
+ search,
+ filter: EFilterReturnedUsers.EXISTING_MEMBERS
+ });
+
+ const filteredGroupMemberships = useMemo(() => {
+ return groupMemberships && groupMemberships?.users
+ ? groupMemberships?.users
+ ?.filter((membership) => {
+ const userSearchString = `${membership.firstName && membership.firstName} ${
+ membership.lastName && membership.lastName
+ } ${membership.email && membership.email} ${
+ membership.username && membership.username
+ }`;
+ return userSearchString.toLowerCase().includes(search.trim().toLowerCase());
+ })
+ .sort((a, b) => {
+ const [membershipOne, membershipTwo] =
+ orderDirection === OrderByDirection.ASC ? [a, b] : [b, a];
+
+ const membershipOneComparisonString = membershipOne.firstName
+ ? membershipOne.firstName
+ : membershipOne.email;
+
+ const membershipTwoComparisonString = membershipTwo.firstName
+ ? membershipTwo.firstName
+ : membershipTwo.email;
+
+ const comparison = membershipOneComparisonString
+ .toLowerCase()
+ .localeCompare(membershipTwoComparisonString.toLowerCase());
+
+ return comparison;
+ })
+ : [];
+ }, [groupMemberships, orderDirection, search]);
+
+ useResetPageHelper({
+ totalCount: filteredGroupMemberships?.length,
+ offset,
+ setPage
+ });
+
+ return (
+ <div>
+ <Input
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search users..."
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="w-1/3">
+ <div className="flex items-center">
+ Name
+ <IconButton
+ variant="plain"
+ className="ml-2"
+ ariaLabel="sort"
+ onClick={toggleOrderDirection}
+ >
+ <FontAwesomeIcon
+ icon={orderDirection === OrderByDirection.DESC ? faArrowUp : faArrowDown}
+ />
+ </IconButton>
+ </div>
+ </Th>
+ <Th>Email</Th>
+ <Th>Added On</Th>
+ <Th />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={4} innerKey="group-user-memberships" />}
+ {!isLoading &&
+ filteredGroupMemberships.slice(offset, perPage * page).map((userGroupMembership) => {
+ return (
+ <GroupMembershipRow
+ key={`user-group-membership-${userGroupMembership.id}`}
+ user={userGroupMembership}
+ handlePopUpOpen={handlePopUpOpen}
+ />
+ );
+ })}
+ </TBody>
+ </Table>
+ {Boolean(filteredGroupMemberships.length) && (
+ <Pagination
+ count={filteredGroupMemberships.length}
+ page={page}
+ perPage={perPage}
+ onChangePage={setPage}
+ onChangePerPage={setPerPage}
+ />
+ )}
+ {!isLoading && !filteredGroupMemberships?.length && (
+ <EmptyState
+ title={
+ groupMemberships?.users.length
+ ? "No users match this search..."
+ : "This group does not have any members yet"
+ }
+ icon={groupMemberships?.users.length ? faSearch : faFolder}
+ />
+ )}
+ {!groupMemberships?.users.length && (
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Groups}>
+ {(isAllowed) => (
+ <div className="mb-4 flex items-center justify-center">
+ <Button
+ isDisabled={!isAllowed}
+ onClick={() => {
+ handlePopUpOpen("addGroupMembers", {
+ groupId,
+ slug: groupSlug
+ });
+ }}
+ >
+ Add members
+ </Button>
+ </div>
+ )}
+ </OrgPermissionCan>
+ )}
+ </TableContainer>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/GroupMembershipRow.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/GroupMembershipRow.tsx
new file mode 100644
index 0000000000..2aa9f4ef51
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/GroupMembershipRow.tsx
@@ -0,0 +1,56 @@
+import { faUserMinus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { IconButton, Td, Tooltip, Tr } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { TGroupUser } from "@app/hooks/api/groups/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+type Props = {
+ user: TGroupUser;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["removeMemberFromGroup"]>,
+ data?: object
+ ) => void;
+};
+
+export const GroupMembershipRow = ({
+ user: { firstName, lastName, username, joinedGroupAt, email, id },
+ handlePopUpOpen
+}: Props) => {
+ return (
+ <Tr className="items-center" key={`group-user-${id}`}>
+ <Td>
+ <p>{`${firstName ?? "-"} ${lastName ?? ""}`}</p>
+ </Td>
+ <Td>
+ <p>{email}</p>
+ </Td>
+ <Td>
+ <Tooltip content={new Date(joinedGroupAt).toLocaleString()}>
+ <p>{new Date(joinedGroupAt).toLocaleDateString()}</p>
+ </Tooltip>
+ </Td>
+ <Td className="justify-end">
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Groups}>
+ {(isAllowed) => {
+ return (
+ <Tooltip content="Remove user from group">
+ <IconButton
+ isDisabled={!isAllowed}
+ ariaLabel="Remove user from group"
+ onClick={() => handlePopUpOpen("removeMemberFromGroup", { username })}
+ variant="plain"
+ colorSchema="danger"
+ >
+ <FontAwesomeIcon icon={faUserMinus} className="cursor-pointer" />
+ </IconButton>
+ </Tooltip>
+ );
+ }}
+ </OrgPermissionCan>
+ </Td>
+ </Tr>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/index.tsx
new file mode 100644
index 0000000000..70c696609c
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/GroupMembersSection/index.tsx
@@ -0,0 +1 @@
+export { GroupMembersSection } from "./GroupMembersSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/index.tsx
new file mode 100644
index 0000000000..003c479108
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/-components/index.tsx
@@ -0,0 +1 @@
+export { GroupDetailsSection } from "./GroupDetailsSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/index.tsx
new file mode 100644
index 0000000000..ed2867b094
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/groups/$groupId/index.tsx
@@ -0,0 +1,245 @@
+import { Helmet } from 'react-helmet'
+import { useTranslation } from 'react-i18next'
+import { faChevronLeft, faEllipsis } from '@fortawesome/free-solid-svg-icons'
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
+import { createFileRoute, useNavigate, useParams } from '@tanstack/react-router'
+import { twMerge } from 'tailwind-merge'
+
+import { createNotification } from '@app/components/notifications'
+import { OrgPermissionCan } from '@app/components/permissions'
+import {
+ Button,
+ DeleteActionModal,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ Spinner,
+ Tooltip,
+ UpgradePlanModal,
+} from '@app/components/v2'
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+} from '@app/context'
+import { withPermission } from '@app/hoc'
+import { useDeleteGroup } from '@app/hooks/api'
+import { useGetGroupById } from '@app/hooks/api/groups/queries'
+import { usePopUp } from '@app/hooks/usePopUp'
+
+import { GroupCreateUpdateModal } from './-components/GroupCreateUpdateModal'
+import { GroupMembersSection } from './-components/GroupMembersSection'
+import { GroupDetailsSection } from './-components'
+
+export enum TabSections {
+ Member = 'members',
+ Groups = 'groups',
+ Roles = 'roles',
+ Identities = 'identities',
+}
+
+const GroupPage = withPermission(
+ () => {
+ const navigate = useNavigate()
+ const params = useParams({
+ from: '/_authenticate/_org_details/_org-layout/organization/$organizationId/groups/$groupId',
+ })
+ const groupId = params.groupId as string
+ const { currentOrg } = useOrganization()
+
+ const { data, isLoading } = useGetGroupById(groupId)
+
+ const { mutateAsync: deleteMutateAsync } = useDeleteGroup()
+
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } =
+ usePopUp(['groupCreateUpdate', 'deleteGroup', 'upgradePlan'] as const)
+
+ const onDeleteGroupSubmit = async ({
+ name,
+ id,
+ }: {
+ name: string
+ id: string
+ }) => {
+ try {
+ await deleteMutateAsync({
+ id,
+ })
+ createNotification({
+ text: `Successfully deleted the ${name} group`,
+ type: 'success',
+ })
+ navigate({
+ to: '/organization/$organizationId/members' as const,
+ params: {
+ organizationId: currentOrg.id,
+ },
+ search: {
+ selectedTab: TabSections.Groups,
+ },
+ })
+ } catch (err) {
+ console.error(err)
+ createNotification({
+ text: `Failed to delete the ${name} group`,
+ type: 'error',
+ })
+ }
+
+ handlePopUpClose('deleteGroup')
+ }
+
+ if (isLoading) return <Spinner size="sm" className="ml-2 mt-2" />
+
+ return (
+ <div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white">
+ {data && (
+ <div className="mx-auto mb-6 w-full max-w-7xl px-6 py-6">
+ <Button
+ variant="link"
+ type="submit"
+ leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
+ onClick={() => {
+ navigate({
+ to: '/organization/$organizationId/members' as const,
+ params: {
+ organizationId: currentOrg.id,
+ },
+ search: {
+ selectedTab: TabSections.Groups,
+ },
+ })
+ }}
+ className="mb-4"
+ >
+ Groups
+ </Button>
+ <div className="mb-4 flex items-center justify-between">
+ <p className="text-3xl font-semibold text-white">
+ {data.group.name}
+ </p>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <div className="hover:text-primary-400 data-[state=open]:text-primary-400">
+ <Tooltip content="More options">
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </Tooltip>
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Groups}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ !isAllowed &&
+ 'pointer-events-none cursor-not-allowed opacity-50',
+ )}
+ onClick={async () => {
+ handlePopUpOpen('groupCreateUpdate', {
+ groupId,
+ name: data.group.name,
+ slug: data.group.slug,
+ role: data.group.role,
+ })
+ }}
+ disabled={!isAllowed}
+ >
+ Edit Group
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Groups}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ isAllowed
+ ? 'hover:!bg-red-500 hover:!text-white'
+ : 'pointer-events-none cursor-not-allowed opacity-50',
+ )}
+ onClick={async () => {
+ handlePopUpOpen('deleteGroup', {
+ id: groupId,
+ name: data.group.name,
+ })
+ }}
+ disabled={!isAllowed}
+ >
+ Delete Group
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ <div className="flex">
+ <div className="mr-4 w-96">
+ <GroupDetailsSection
+ groupId={groupId}
+ handlePopUpOpen={handlePopUpOpen}
+ />
+ </div>
+ <GroupMembersSection
+ groupId={groupId}
+ groupSlug={data.group.slug}
+ />
+ </div>
+ </div>
+ )}
+ <GroupCreateUpdateModal
+ popUp={popUp}
+ handlePopUpClose={handlePopUpClose}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <DeleteActionModal
+ isOpen={popUp.deleteGroup.isOpen}
+ title={`Are you sure want to delete the group named ${
+ (popUp?.deleteGroup?.data as { name: string })?.name || ''
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle('deleteGroup', isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() =>
+ onDeleteGroupSubmit(
+ popUp?.deleteGroup?.data as { name: string; id: string },
+ )
+ }
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle('upgradePlan', isOpen)}
+ text={
+ (popUp.upgradePlan?.data as { description: string })?.description
+ }
+ />
+ </div>
+ )
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Groups },
+)
+
+const GroupDetailPage = () => {
+ const { t } = useTranslation()
+ return (
+ <>
+ <Helmet>
+ <title>
+ {t('common.head-title', { title: t('settings.org.title') })}
+ </title>
+ <link rel="icon" href="/infisical.ico" />
+ </Helmet>
+ <GroupPage />
+ </>
+ )
+}
+
+export const Route = createFileRoute(
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/groups/$groupId/',
+)({
+ component: GroupDetailPage,
+})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx
new file mode 100644
index 0000000000..23f72d7dae
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx
@@ -0,0 +1,157 @@
+import { useEffect } from "react";
+import { faPencil, faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, IconButton, Select, SelectItem, Tooltip } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { useGetIdentityById } from "@app/hooks/api";
+import { IdentityAuthMethod, identityAuthToNameMap } from "@app/hooks/api/identities";
+import { Identity } from "@app/hooks/api/identities/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+import { IdentityClientSecrets } from "./IdentityClientSecrets";
+import { IdentityTokens } from "./IdentityTokens";
+
+type Props = {
+ identityId: string;
+ setSelectedAuthMethod: (authMethod: Identity["authMethods"][number] | null) => void;
+ selectedAuthMethod: Identity["authMethods"][number] | null;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<
+ [
+ "clientSecret",
+ "identityAuthMethod",
+ "revokeClientSecret",
+ "token",
+ "revokeToken",
+ "universalAuthClientSecret",
+ "tokenList"
+ ]
+ >,
+ data?: object
+ ) => void;
+};
+
+export const IdentityAuthenticationSection = ({
+ identityId,
+ setSelectedAuthMethod,
+ selectedAuthMethod,
+ handlePopUpOpen
+}: Props) => {
+ const { data } = useGetIdentityById(identityId);
+
+ useEffect(() => {
+ if (!data?.identity) return;
+
+ if (data.identity.authMethods?.length) {
+ setSelectedAuthMethod(data.identity.authMethods[0]);
+ }
+
+ // eslint-disable-next-line consistent-return
+ return () => setSelectedAuthMethod(null);
+ }, [data?.identity]);
+
+ return data ? (
+ <div className="mt-4 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <h3 className="text-lg font-semibold text-mineshaft-100">Authentication</h3>
+
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Identity}>
+ {(isAllowed) => {
+ return (
+ <Tooltip content="Add new auth method">
+ <IconButton
+ isDisabled={!isAllowed}
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={() =>
+ handlePopUpOpen("identityAuthMethod", {
+ identityId,
+ name: data.identity.name,
+ allAuthMethods: data.identity.authMethods
+ })
+ }
+ >
+ <FontAwesomeIcon icon={faPlus} />
+ </IconButton>
+ </Tooltip>
+ );
+ }}
+ </OrgPermissionCan>
+ </div>
+ {data.identity.authMethods.length > 0 ? (
+ <>
+ <div className="py-4">
+ <div className="flex justify-between">
+ <p className="mb-0.5 ml-px text-sm font-semibold text-mineshaft-300">Auth Method</p>
+ </div>
+ <div className="flex items-center gap-2">
+ <div className="w-full">
+ <Select
+ className="w-full"
+ value={selectedAuthMethod as string}
+ onValueChange={(value) => setSelectedAuthMethod(value as IdentityAuthMethod)}
+ >
+ {(data.identity?.authMethods || []).map((authMethod) => (
+ <SelectItem key={authMethod || authMethod} value={authMethod}>
+ {identityAuthToNameMap[authMethod]}
+ </SelectItem>
+ ))}
+ </Select>
+ </div>
+ <div>
+ <Tooltip content="Edit auth method">
+ <IconButton
+ onClick={() => {
+ handlePopUpOpen("identityAuthMethod", {
+ identityId,
+ name: data.identity.name,
+ authMethod: selectedAuthMethod,
+ allAuthMethods: data.identity.authMethods
+ });
+ }}
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ >
+ <FontAwesomeIcon icon={faPencil} />
+ </IconButton>
+ </Tooltip>{" "}
+ </div>
+ </div>
+ </div>
+ {selectedAuthMethod === IdentityAuthMethod.UNIVERSAL_AUTH && (
+ <IdentityClientSecrets identityId={identityId} handlePopUpOpen={handlePopUpOpen} />
+ )}
+ {selectedAuthMethod === IdentityAuthMethod.TOKEN_AUTH && (
+ <IdentityTokens identityId={identityId} handlePopUpOpen={handlePopUpOpen} />
+ )}
+ </>
+ ) : (
+ <div className="w-full space-y-2 pt-2">
+ <p className="text-sm text-mineshaft-300">
+ No authentication methods configured. Get started by creating a new auth method.
+ </p>
+ <Button
+ onClick={() => {
+ handlePopUpOpen("identityAuthMethod", {
+ identityId,
+ name: data.identity.name,
+ allAuthMethods: data.identity.authMethods
+ });
+ }}
+ variant="outline_bg"
+ className="w-full"
+ size="xs"
+ >
+ Create Auth Method
+ </Button>
+ </div>
+ )}
+ </div>
+ ) : (
+ <div />
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/IdentityClientSecrets.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/IdentityClientSecrets.tsx
new file mode 100644
index 0000000000..a68b99faf8
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/IdentityClientSecrets.tsx
@@ -0,0 +1,142 @@
+import { faCheck, faCopy, faKey, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { format } from "date-fns";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, IconButton, Tooltip } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { useTimedReset } from "@app/hooks";
+import {
+ useGetIdentityById,
+ useGetIdentityUniversalAuth,
+ useGetIdentityUniversalAuthClientSecrets
+} from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+type Props = {
+ identityId: string;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<
+ ["clientSecret", "revokeClientSecret", "universalAuthClientSecret"]
+ >,
+ data?: object
+ ) => void;
+};
+
+const SHOW_LIMIT = 3;
+
+export const IdentityClientSecrets = ({ identityId, handlePopUpOpen }: Props) => {
+ const [copyTextClientId, isCopyingClientId, setCopyTextClientId] = useTimedReset<string>({
+ initialState: "Copy Client ID to clipboard"
+ });
+
+ const { data } = useGetIdentityById(identityId);
+ const { data: identityUniversalAuth } = useGetIdentityUniversalAuth(identityId);
+ const { data: clientSecrets } = useGetIdentityUniversalAuthClientSecrets(identityId);
+ return (
+ <div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Client ID</p>
+ <div className="group flex align-top">
+ <p className="text-sm text-mineshaft-300">{identityUniversalAuth?.clientId ?? ""}</p>
+ <div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
+ <Tooltip content={copyTextClientId}>
+ <IconButton
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative ml-2"
+ onClick={() => {
+ navigator.clipboard.writeText(identityUniversalAuth?.clientId ?? "");
+ setCopyTextClientId("Copied");
+ }}
+ >
+ <FontAwesomeIcon icon={isCopyingClientId ? faCheck : faCopy} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ </div>
+ </div>
+ {clientSecrets?.length ? (
+ <div className="flex justify-between">
+ <p className="text-sm font-semibold text-mineshaft-300">{`Client Secrets (${clientSecrets.length})`}</p>
+ <Button
+ variant="link"
+ onClick={() => {
+ handlePopUpOpen("universalAuthClientSecret", {
+ identityId,
+ name: data?.identity.name ?? ""
+ });
+ }}
+ >
+ Manage
+ </Button>
+ </div>
+ ) : (
+ <div />
+ )}
+ {clientSecrets
+ ?.slice(0, SHOW_LIMIT)
+ .map(({ id, clientSecretTTL, clientSecretPrefix, createdAt }) => {
+ let expiresAt;
+ if (clientSecretTTL > 0) {
+ expiresAt = new Date(new Date(createdAt).getTime() + clientSecretTTL * 1000);
+ }
+
+ return (
+ <div
+ className="group flex items-center justify-between py-2 last:pb-0"
+ key={`client-secret-${id}`}
+ >
+ <div className="flex items-center">
+ <FontAwesomeIcon size="1x" icon={faKey} />
+ <div className="ml-4">
+ <p className="text-sm font-semibold text-mineshaft-300">
+ {`${clientSecretPrefix}****`}
+ </p>
+ <p className="text-sm text-mineshaft-300">
+ {expiresAt ? `Expires on ${format(expiresAt, "yyyy-MM-dd")}` : "No Expiry"}
+ </p>
+ </div>
+ </div>
+ <div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
+ <Tooltip content="Revoke Client Secret">
+ <IconButton
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={() => {
+ handlePopUpOpen("revokeClientSecret", {
+ clientSecretId: id,
+ clientSecretPrefix
+ });
+ }}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ </div>
+ );
+ })}
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Identity}>
+ {(isAllowed) => {
+ return (
+ <Button
+ isDisabled={!isAllowed}
+ className="mt-4 w-full"
+ colorSchema="primary"
+ type="submit"
+ onClick={() => {
+ handlePopUpOpen("clientSecret", {
+ identityId
+ });
+ }}
+ >
+ Create Client Secret
+ </Button>
+ );
+ }}
+ </OrgPermissionCan>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/IdentityTokens.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/IdentityTokens.tsx
new file mode 100644
index 0000000000..18b61b0ca2
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/IdentityTokens.tsx
@@ -0,0 +1,121 @@
+import { faEllipsis, faKey } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { format } from "date-fns";
+
+import {
+ Button,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ Tooltip
+} from "@app/components/v2";
+import { useGetIdentityById, useGetIdentityTokensTokenAuth } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+type Props = {
+ identityId: string;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["token", "tokenList", "revokeToken"]>,
+ data?: object
+ ) => void;
+};
+
+export const IdentityTokens = ({ identityId, handlePopUpOpen }: Props) => {
+ const { data } = useGetIdentityById(identityId);
+ const { data: tokens } = useGetIdentityTokensTokenAuth(identityId);
+ return (
+ <div>
+ {tokens?.length ? (
+ <div className="flex justify-between">
+ <p className="text-sm font-semibold text-mineshaft-300">{`Access Tokens (${tokens.length})`}</p>
+ <Button
+ variant="link"
+ onClick={() => {
+ handlePopUpOpen("tokenList", {
+ identityId,
+ name: data?.identity.name ?? ""
+ });
+ }}
+ >
+ Manage
+ </Button>
+ </div>
+ ) : (
+ <div />
+ )}
+ {tokens?.map((token) => {
+ const expiresAt = new Date(
+ new Date(token.createdAt).getTime() + token.accessTokenMaxTTL * 1000
+ );
+ return (
+ <div
+ className="group flex items-center justify-between py-2 last:pb-0"
+ key={`identity-token-${token.id}`}
+ >
+ <div className="flex items-center">
+ <FontAwesomeIcon size="1x" icon={faKey} />
+ <div className="ml-4">
+ <p className="text-sm font-semibold text-mineshaft-300">
+ {token.name ? token.name : "-"}
+ </p>
+ <p className="text-sm text-mineshaft-300">
+ {token.isAccessTokenRevoked
+ ? "Revoked"
+ : `Expires on ${format(expiresAt, "yyyy-MM-dd")}`}
+ </p>
+ </div>
+ </div>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <div className="opacity-0 transition-opacity duration-300 hover:text-primary-400 group-hover:opacity-100 data-[state=open]:text-primary-400">
+ <Tooltip content="More options">
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </Tooltip>
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <DropdownMenuItem
+ onClick={async () => {
+ handlePopUpOpen("token", {
+ identityId,
+ tokenId: token.id,
+ name: token.name
+ });
+ }}
+ >
+ Edit Token
+ </DropdownMenuItem>
+ {!token.isAccessTokenRevoked && (
+ <DropdownMenuItem
+ onClick={async () => {
+ handlePopUpOpen("revokeToken", {
+ identityId,
+ tokenId: token.id,
+ name: token.name
+ });
+ }}
+ >
+ Revoke Token
+ </DropdownMenuItem>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ );
+ })}
+ <Button
+ className="mr-4 mt-4 w-full"
+ colorSchema="primary"
+ type="submit"
+ onClick={() => {
+ handlePopUpOpen("token", {
+ identityId
+ });
+ }}
+ >
+ Create Token
+ </Button>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/index.tsx
new file mode 100644
index 0000000000..401c930d89
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityAuthenticationSection/index.tsx
@@ -0,0 +1 @@
+export { IdentityAuthenticationSection } from "./IdentityAuthenticationSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityClientSecretModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityClientSecretModal.tsx
new file mode 100644
index 0000000000..102a31adfb
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityClientSecretModal.tsx
@@ -0,0 +1,182 @@
+import { useState } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FormControl,
+ IconButton,
+ Input,
+ Modal,
+ ModalContent,
+ Tooltip
+} from "@app/components/v2";
+import { useTimedReset } from "@app/hooks";
+import { useCreateIdentityUniversalAuthClientSecret } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z
+ .object({
+ description: z.string(),
+ ttl: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "TTL cannot be greater than 315360000"
+ }),
+ numUsesLimit: z.string()
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ popUp: UsePopUpState<["clientSecret"]>;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["clientSecret"]>, state?: boolean) => void;
+};
+
+export const IdentityClientSecretModal = ({ popUp, handlePopUpToggle }: Props) => {
+ const { mutateAsync: createClientSecret } = useCreateIdentityUniversalAuthClientSecret();
+ const [token, setToken] = useState("");
+ const [copyTextToken, isCopyingToken, setCopyTextToken] = useTimedReset<string>({
+ initialState: "Copy to clipboard"
+ });
+ const hasToken = Boolean(token);
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ description: "",
+ ttl: "",
+ numUsesLimit: ""
+ }
+ });
+
+ const popUpData = popUp?.clientSecret?.data as {
+ identityId: string;
+ };
+
+ const onFormSubmit = async ({ description, ttl, numUsesLimit }: FormData) => {
+ const { clientSecret } = await createClientSecret({
+ identityId: popUpData.identityId,
+ description,
+ ttl: Number(ttl),
+ numUsesLimit: Number(numUsesLimit)
+ });
+
+ setToken(clientSecret);
+
+ createNotification({
+ text: "Successfully created client secret",
+ type: "success"
+ });
+
+ reset();
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.clientSecret?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("clientSecret", isOpen);
+ reset();
+ setToken("");
+ }}
+ >
+ <ModalContent
+ title="Create Client Secret"
+ subTitle={hasToken ? "We will only show this secret once" : ""}
+ >
+ {!hasToken ? (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="description"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Description"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="My Client Secret" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="ttl"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="TTL (seconds - optional)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <div className="flex">
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ </div>
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="numUsesLimit"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Max Number of Uses"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ </FormControl>
+ )}
+ />
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Create
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("clientSecret", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ ) : (
+ <div className="mb-3 mr-2 mt-2 flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{token}</p>
+ <Tooltip content={copyTextToken}>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(token);
+ setCopyTextToken("Copied");
+ }}
+ >
+ <FontAwesomeIcon icon={isCopyingToken ? faCheck : faCopy} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ )}
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityDetailsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityDetailsSection.tsx
new file mode 100644
index 0000000000..4b25475cc2
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityDetailsSection.tsx
@@ -0,0 +1,118 @@
+import { faCheck, faCopy, faKey, faPencil } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { IconButton, Tag, Tooltip } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { useTimedReset } from "@app/hooks";
+import { useGetIdentityById } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+type Props = {
+ identityId: string;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["identity", "identityAuthMethod", "token", "clientSecret"]>,
+ data?: object
+ ) => void;
+};
+
+export const IdentityDetailsSection = ({ identityId, handlePopUpOpen }: Props) => {
+ const [copyTextId, isCopyingId, setCopyTextId] = useTimedReset<string>({
+ initialState: "Copy ID to clipboard"
+ });
+
+ const { data } = useGetIdentityById(identityId);
+ return data ? (
+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <h3 className="text-lg font-semibold text-mineshaft-100">Identity Details</h3>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Identity}>
+ {(isAllowed) => {
+ return (
+ <Tooltip content="Edit Identity">
+ <IconButton
+ isDisabled={!isAllowed}
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={() => {
+ handlePopUpOpen("identity", {
+ identityId,
+ name: data.identity.name,
+ role: data.role,
+ customRole: data.customRole,
+ metadata: data.metadata
+ });
+ }}
+ >
+ <FontAwesomeIcon icon={faPencil} />
+ </IconButton>
+ </Tooltip>
+ );
+ }}
+ </OrgPermissionCan>
+ </div>
+ <div className="pt-4">
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Identity ID</p>
+ <div className="group flex align-top">
+ <p className="text-sm text-mineshaft-300">{data.identity.id}</p>
+ <div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
+ <Tooltip content={copyTextId}>
+ <IconButton
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative ml-2"
+ onClick={() => {
+ navigator.clipboard.writeText(data.identity.id);
+ setCopyTextId("Copied");
+ }}
+ >
+ <FontAwesomeIcon icon={isCopyingId ? faCheck : faCopy} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ </div>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Name</p>
+ <p className="text-sm text-mineshaft-300">{data.identity.name}</p>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Organization Role</p>
+ <p className="text-sm text-mineshaft-300">{data.role}</p>
+ </div>
+ <div>
+ <p className="text-sm font-semibold text-mineshaft-300">Metadata</p>
+ {data?.metadata?.length ? (
+ <div className="mt-1 flex flex-wrap gap-2 text-sm text-mineshaft-300">
+ {data.metadata?.map((el) => (
+ <div key={el.id} className="flex items-center">
+ <Tag
+ size="xs"
+ className="mr-0 flex items-center rounded-r-none border border-mineshaft-500"
+ >
+ <FontAwesomeIcon icon={faKey} size="xs" className="mr-1" />
+ <div>{el.key}</div>
+ </Tag>
+ <Tag
+ size="xs"
+ className="flex items-center rounded-l-none border border-mineshaft-500 bg-mineshaft-900 pl-1"
+ >
+ <div className="max-w-[150px] overflow-hidden text-ellipsis whitespace-nowrap">
+ {el.value}
+ </div>
+ </Tag>
+ </div>
+ ))}
+ </div>
+ ) : (
+ <p className="text-sm text-mineshaft-300">-</p>
+ )}
+ </div>
+ </div>
+ </div>
+ ) : (
+ <div />
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityAddToProjectModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityAddToProjectModal.tsx
new file mode 100644
index 0000000000..c6597a5eb7
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityAddToProjectModal.tsx
@@ -0,0 +1,185 @@
+import { useMemo } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FilterableSelect,
+ FormControl,
+ Modal,
+ ModalClose,
+ ModalContent
+} from "@app/components/v2";
+import { useOrganization, useWorkspace } from "@app/context";
+import {
+ useAddIdentityToWorkspace,
+ useGetIdentityProjectMemberships,
+ useGetProjectRoles,
+ useGetWorkspaceById
+} from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z
+ .object({
+ project: z.object({ name: z.string(), id: z.string() }),
+ role: z.object({ name: z.string(), slug: z.string() })
+ })
+ .required();
+
+type FormData = z.infer<typeof schema>;
+
+type Props = {
+ identityId: string;
+ popUp: UsePopUpState<["addIdentityToProject"]>;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["addIdentityToProject"]>,
+ state?: boolean
+ ) => void;
+};
+
+// TODO: eventually refactor to support adding to multiple projects at once? would lose role granularity unique to project
+
+const Content = ({ identityId, handlePopUpToggle }: Omit<Props, "popUp">) => {
+ const { currentOrg } = useOrganization();
+ const { workspaces } = useWorkspace();
+ const { mutateAsync: addIdentityToWorkspace } = useAddIdentityToWorkspace();
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting },
+ watch
+ } = useForm<FormData>({
+ resolver: zodResolver(schema)
+ });
+
+ const projectId = watch("project")?.id;
+ const { data: projectMemberships } = useGetIdentityProjectMemberships(identityId);
+ const { data: project, isLoading: isProjectLoading } = useGetWorkspaceById(projectId);
+ const { data: roles, isLoading: isRolesLoading } = useGetProjectRoles(project?.id ?? "");
+
+ const filteredWorkspaces = useMemo(() => {
+ const wsWorkspaceIds = new Map();
+
+ projectMemberships?.forEach((projectMembership) => {
+ wsWorkspaceIds.set(projectMembership.project.id, true);
+ });
+
+ return (workspaces || []).filter(
+ ({ id, orgId }) => !wsWorkspaceIds.has(id) && orgId === currentOrg?.id
+ );
+ }, [workspaces, projectMemberships]);
+
+ const onFormSubmit = async ({ project: selectedProject, role }: FormData) => {
+ try {
+ await addIdentityToWorkspace({
+ workspaceId: selectedProject.id,
+ identityId,
+ role: role.slug || undefined
+ });
+
+ createNotification({
+ text: "Successfully added identity to project",
+ type: "success"
+ });
+
+ reset();
+ handlePopUpToggle("addIdentityToProject", false);
+ } catch (err) {
+ console.error(err);
+ const error = err as any;
+ const text = error?.response?.data?.message ?? "Failed to add identity to project";
+
+ createNotification({
+ text,
+ type: "error"
+ });
+ }
+ };
+
+ const isProjectSelected = Boolean(projectId);
+
+ return (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ name="project"
+ render={({ field: { onChange, value }, fieldState: { error } }) => (
+ <FormControl
+ label="Project"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ className="mt-4"
+ >
+ <FilterableSelect
+ value={value}
+ onChange={onChange}
+ options={filteredWorkspaces}
+ placeholder="Select project..."
+ getOptionValue={(option) => option.id}
+ getOptionLabel={(option) => option.name}
+ isLoading={isProjectSelected && isProjectLoading}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="role"
+ render={({ field: { onChange, value }, fieldState: { error } }) => (
+ <FormControl
+ label="Role"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ className="mt-4"
+ >
+ <FilterableSelect
+ isDisabled={!isProjectSelected}
+ value={value}
+ onChange={onChange}
+ options={roles}
+ isLoading={isProjectSelected && isRolesLoading}
+ placeholder="Select role..."
+ getOptionValue={(option) => option.slug}
+ getOptionLabel={(option) => option.name}
+ />
+ </FormControl>
+ )}
+ />
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Add
+ </Button>
+ <ModalClose asChild>
+ <Button colorSchema="secondary" variant="plain">
+ Cancel
+ </Button>
+ </ModalClose>
+ </div>
+ </form>
+ );
+};
+
+export const IdentityAddToProjectModal = ({ identityId, popUp, handlePopUpToggle }: Props) => {
+ return (
+ <Modal
+ isOpen={popUp?.addIdentityToProject?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addIdentityToProject", isOpen);
+ }}
+ >
+ <ModalContent bodyClassName="overflow-visible" title="Add Identity to Project">
+ <Content identityId={identityId} handlePopUpToggle={handlePopUpToggle} />
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityProjectRow.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityProjectRow.tsx
new file mode 100644
index 0000000000..0c892afcdf
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityProjectRow.tsx
@@ -0,0 +1,111 @@
+import { useMemo } from "react";
+import { faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { useNavigate } from "@tanstack/react-router";
+import { format } from "date-fns";
+
+import { createNotification } from "@app/components/notifications";
+import { IconButton, Tag, Td, Tooltip, Tr } from "@app/components/v2";
+import { useWorkspace } from "@app/context";
+import { IdentityMembership } from "@app/hooks/api/identities/types";
+import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+export enum TabSections {
+ Member = "members",
+ Groups = "groups",
+ Roles = "roles",
+ Identities = "identities"
+}
+
+type Props = {
+ membership: IdentityMembership;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["removeIdentityFromProject"]>,
+ data?: object
+ ) => void;
+};
+
+const formatRoleName = (role: string, customRoleName?: string) => {
+ if (role === ProjectMembershipRole.Custom) return customRoleName;
+ if (role === ProjectMembershipRole.Admin) return "Admin";
+ if (role === ProjectMembershipRole.Member) return "Developer";
+ if (role === ProjectMembershipRole.Viewer) return "Viewer";
+ if (role === ProjectMembershipRole.NoAccess) return "No Access";
+ return role;
+};
+
+export const IdentityProjectRow = ({
+ membership: { id, createdAt, identity, project, roles },
+ handlePopUpOpen
+}: Props) => {
+ const { workspaces } = useWorkspace();
+ const navigate = useNavigate();
+
+ const isAccessible = useMemo(() => {
+ const workspaceIds = new Map();
+
+ workspaces?.forEach((workspace) => {
+ workspaceIds.set(workspace.id, true);
+ });
+
+ return workspaceIds.has(project.id);
+ }, [workspaces, project]);
+
+ return (
+ <Tr
+ className="group h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ key={`identity-project-membership-${id}`}
+ onClick={() => {
+ if (isAccessible) {
+ navigate({
+ to: `/${project?.type}/${project.id}/members` as const,
+ search: {
+ selectedTab: TabSections.Identities
+ }
+ });
+ return;
+ }
+
+ createNotification({
+ text: "Unable to access project",
+ type: "error"
+ });
+ }}
+ >
+ <Td className="max-w-0 truncate">{project.name}</Td>
+ <Td>
+ <Tag size="xs">{project.type}</Tag>
+ </Td>
+ <Td>{`${formatRoleName(roles[0].role, roles[0].customRoleName)}${
+ roles.length > 1 ? ` (+${roles.length - 1})` : ""
+ }`}</Td>
+ <Td>{format(new Date(createdAt), "yyyy-MM-dd")}</Td>
+ <Td>
+ {isAccessible && (
+ <div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
+ <Tooltip content="Remove">
+ <IconButton
+ colorSchema="danger"
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("removeIdentityFromProject", {
+ identityId: identity.id,
+ identityName: identity.name,
+ projectId: project.id,
+ projectName: project.name
+ });
+ }}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ )}
+ </Td>
+ </Tr>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityProjectsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityProjectsSection.tsx
new file mode 100644
index 0000000000..b0c13009d9
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityProjectsSection.tsx
@@ -0,0 +1,92 @@
+import { faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { DeleteActionModal, IconButton } from "@app/components/v2";
+import { useDeleteIdentityFromWorkspace } from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { IdentityAddToProjectModal } from "./IdentityAddToProjectModal";
+import { IdentityProjectsTable } from "./IdentityProjectsTable";
+
+type Props = {
+ identityId: string;
+};
+
+export const IdentityProjectsSection = ({ identityId }: Props) => {
+ const { mutateAsync: deleteMutateAsync } = useDeleteIdentityFromWorkspace();
+
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "addIdentityToProject",
+ "removeIdentityFromProject"
+ ] as const);
+
+ const onRemoveIdentitySubmit = async (id: string, projectId: string) => {
+ try {
+ await deleteMutateAsync({
+ identityId: id,
+ workspaceId: projectId
+ });
+
+ createNotification({
+ text: "Successfully removed identity from project",
+ type: "success"
+ });
+
+ handlePopUpClose("removeIdentityFromProject");
+ } catch (err) {
+ console.error(err);
+ const error = err as any;
+ const text = error?.response?.data?.message ?? "Failed to remove identity from project";
+
+ createNotification({
+ text,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <div className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <h3 className="text-lg font-semibold text-mineshaft-100">Projects</h3>
+ <IconButton
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={() => {
+ handlePopUpOpen("addIdentityToProject");
+ }}
+ >
+ <FontAwesomeIcon icon={faPlus} />
+ </IconButton>
+ </div>
+ <div className="py-4">
+ <IdentityProjectsTable identityId={identityId} handlePopUpOpen={handlePopUpOpen} />
+ </div>
+ <DeleteActionModal
+ isOpen={popUp.removeIdentityFromProject.isOpen}
+ title={`Are you sure want to remove ${
+ (popUp?.removeIdentityFromProject?.data as { identityName: string })?.identityName || ""
+ } from ${
+ (popUp?.removeIdentityFromProject?.data as { projectName: string })?.projectName || ""
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle("removeIdentityFromProject", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() => {
+ const popupData = popUp?.removeIdentityFromProject?.data as {
+ identityId: string;
+ projectId: string;
+ };
+
+ return onRemoveIdentitySubmit(popupData.identityId, popupData.projectId);
+ }}
+ />
+ <IdentityAddToProjectModal
+ identityId={identityId}
+ popUp={popUp}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityProjectsTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityProjectsTable.tsx
new file mode 100644
index 0000000000..4f9191f3ae
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/IdentityProjectsTable.tsx
@@ -0,0 +1,151 @@
+import { useMemo } from "react";
+import {
+ faArrowDown,
+ faArrowUp,
+ faFolder,
+ faMagnifyingGlass,
+ faSearch
+} from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import {
+ EmptyState,
+ IconButton,
+ Input,
+ Pagination,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { usePagination, useResetPageHelper } from "@app/hooks";
+import { useGetIdentityProjectMemberships } from "@app/hooks/api";
+import { OrderByDirection } from "@app/hooks/api/generic/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+import { IdentityProjectRow } from "./IdentityProjectRow";
+
+type Props = {
+ identityId: string;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["removeIdentityFromProject"]>,
+ data?: object
+ ) => void;
+};
+
+enum IdentityProjectsOrderBy {
+ Name = "name"
+}
+
+export const IdentityProjectsTable = ({ identityId, handlePopUpOpen }: Props) => {
+ const { data: projectMemberships = [], isLoading } = useGetIdentityProjectMemberships(identityId);
+
+ const {
+ search,
+ setSearch,
+ setPage,
+ page,
+ perPage,
+ setPerPage,
+ offset,
+ orderDirection,
+ toggleOrderDirection
+ } = usePagination(IdentityProjectsOrderBy.Name, { initPerPage: 10 });
+
+ const filteredProjectMemberships = useMemo(
+ () =>
+ projectMemberships
+ ?.filter((membership) =>
+ membership.project.name.toLowerCase().includes(search.trim().toLowerCase())
+ )
+ .sort((a, b) => {
+ const [membershipOne, membershipTwo] =
+ orderDirection === OrderByDirection.ASC ? [a, b] : [b, a];
+
+ return membershipOne.project.name
+ .toLowerCase()
+ .localeCompare(membershipTwo.project.name.toLowerCase());
+ }),
+ [projectMemberships, orderDirection, search]
+ );
+
+ useResetPageHelper({
+ totalCount: filteredProjectMemberships.length,
+ offset,
+ setPage
+ });
+
+ return (
+ <div>
+ <Input
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search projects..."
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="w-2/3">
+ <div className="flex items-center">
+ Name
+ <IconButton
+ variant="plain"
+ className="ml-2"
+ ariaLabel="sort"
+ onClick={toggleOrderDirection}
+ >
+ <FontAwesomeIcon
+ icon={orderDirection === OrderByDirection.DESC ? faArrowUp : faArrowDown}
+ />
+ </IconButton>
+ </div>
+ </Th>
+
+ <Th>Type</Th>
+ <Th>Role</Th>
+ <Th>Added On</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={4} innerKey="identity-project-memberships" />}
+ {!isLoading &&
+ filteredProjectMemberships.slice(offset, perPage * page).map((membership) => {
+ return (
+ <IdentityProjectRow
+ key={`identity-project-membership-${membership.id}`}
+ membership={membership}
+ handlePopUpOpen={handlePopUpOpen}
+ />
+ );
+ })}
+ </TBody>
+ </Table>
+ {Boolean(filteredProjectMemberships.length) && (
+ <Pagination
+ count={filteredProjectMemberships.length}
+ page={page}
+ perPage={perPage}
+ onChangePage={setPage}
+ onChangePerPage={setPerPage}
+ />
+ )}
+ {!isLoading && !filteredProjectMemberships?.length && (
+ <EmptyState
+ title={
+ projectMemberships.length
+ ? "No projects match search..."
+ : "This identity has not been assigned to any projects"
+ }
+ icon={projectMemberships.length ? faSearch : faFolder}
+ />
+ )}
+ </TableContainer>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/index.tsx
new file mode 100644
index 0000000000..4eb7d40a94
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityProjectsSection/index.tsx
@@ -0,0 +1 @@
+export { IdentityProjectsSection } from "./IdentityProjectsSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityTokenListModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityTokenListModal.tsx
new file mode 100644
index 0000000000..f0336061b8
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityTokenListModal.tsx
@@ -0,0 +1,270 @@
+import { useEffect, useState } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { useTranslation } from "react-i18next";
+import { faCheck, faCopy, faKey, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { format } from "date-fns";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ EmptyState,
+ FormControl,
+ IconButton,
+ Input,
+ Modal,
+ ModalContent,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useToggle } from "@app/hooks";
+import {
+ useCreateTokenIdentityTokenAuth,
+ useGetIdentityTokensTokenAuth,
+ useGetIdentityUniversalAuthClientSecrets
+} from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z.object({
+ name: z.string()
+});
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ popUp: UsePopUpState<["tokenList", "revokeToken"]>;
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["revokeToken"]>, data?: object) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["tokenList", "revokeToken"]>,
+ state?: boolean
+ ) => void;
+};
+
+export const IdentityTokenListModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Props) => {
+ const { t } = useTranslation();
+
+ const [token, setToken] = useState("");
+ const [isClientSecretCopied, setIsClientSecretCopied] = useToggle(false);
+ const [isClientIdCopied, setIsClientIdCopied] = useToggle(false);
+
+ const popUpData = popUp?.tokenList?.data as {
+ identityId: string;
+ name: string;
+ };
+
+ const { data: tokens } = useGetIdentityTokensTokenAuth(popUpData?.identityId ?? "");
+ const { data, isLoading } = useGetIdentityUniversalAuthClientSecrets(popUpData?.identityId ?? "");
+
+ const { mutateAsync: createToken } = useCreateTokenIdentityTokenAuth();
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ name: ""
+ }
+ });
+
+ useEffect(() => {
+ let timer: NodeJS.Timeout;
+ if (isClientSecretCopied) {
+ timer = setTimeout(() => setIsClientSecretCopied.off(), 2000);
+ }
+
+ return () => clearTimeout(timer);
+ }, [isClientSecretCopied]);
+
+ useEffect(() => {
+ let timer: NodeJS.Timeout;
+ if (isClientIdCopied) {
+ timer = setTimeout(() => setIsClientIdCopied.off(), 2000);
+ }
+
+ return () => clearTimeout(timer);
+ }, [isClientIdCopied]);
+
+ const onFormSubmit = async ({ name }: FormData) => {
+ try {
+ if (!popUpData?.identityId) return;
+
+ const newTokenData = await createToken({
+ identityId: popUpData.identityId,
+ name
+ });
+
+ setToken(newTokenData.accessToken);
+
+ createNotification({
+ text: "Successfully created token",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to create token",
+ type: "error"
+ });
+ }
+ };
+
+ const hasToken = Boolean(token);
+
+ return (
+ <Modal
+ isOpen={popUp?.tokenList?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("tokenList", isOpen);
+ reset();
+ setToken("");
+ }}
+ >
+ <ModalContent title={`Manage Access Tokens for ${popUpData?.name ?? ""}`}>
+ <h2 className="mb-4">New Token</h2>
+ {hasToken ? (
+ <div>
+ <div className="mb-4 flex items-center justify-between">
+ <p>We will only show this token once</p>
+ <Button
+ colorSchema="secondary"
+ type="submit"
+ onClick={() => {
+ reset();
+ setToken("");
+ }}
+ >
+ Got it
+ </Button>
+ </div>
+ <div className="mb-8 flex items-center justify-between rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{token}</p>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(token);
+ setIsClientSecretCopied.on();
+ }}
+ >
+ <FontAwesomeIcon icon={isClientSecretCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ {t("common.click-to-copy")}
+ </span>
+ </IconButton>
+ </div>
+ </div>
+ ) : (
+ <form onSubmit={handleSubmit(onFormSubmit)} className="mb-8">
+ <Controller
+ control={control}
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Name" isError={Boolean(error)} errorText={error?.message}>
+ <div className="flex">
+ <Input {...field} placeholder="My Token" />
+ <Button
+ className="ml-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Create
+ </Button>
+ </div>
+ </FormControl>
+ )}
+ />
+ </form>
+ )}
+ <h2 className="mb-4">Tokens</h2>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th>name</Th>
+ <Th>Num Uses</Th>
+ <Th>Created At</Th>
+ <Th>Max Expires At</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={5} innerKey="identities-tokens" />}
+ {!isLoading &&
+ tokens?.map(
+ ({
+ id,
+ createdAt,
+ name,
+ accessTokenNumUses,
+ accessTokenNumUsesLimit,
+ accessTokenMaxTTL,
+ isAccessTokenRevoked
+ }) => {
+ const expiresAt = new Date(
+ new Date(createdAt).getTime() + accessTokenMaxTTL * 1000
+ );
+
+ return (
+ <Tr className="h-10 items-center" key={`mi-client-secret-${id}`}>
+ <Td>{name === "" ? "-" : name}</Td>
+ <Td>{`${accessTokenNumUses}${
+ accessTokenNumUsesLimit ? `/${accessTokenNumUsesLimit}` : ""
+ }`}</Td>
+ <Td>{format(new Date(createdAt), "yyyy-MM-dd")}</Td>
+ <Td>
+ {isAccessTokenRevoked ? "Revoked" : `${format(expiresAt, "yyyy-MM-dd")}`}
+ </Td>
+ <Td>
+ {!isAccessTokenRevoked && (
+ <IconButton
+ onClick={() => {
+ handlePopUpOpen("revokeToken", {
+ identityId: popUpData?.identityId,
+ tokenId: id,
+ name
+ });
+ }}
+ size="lg"
+ colorSchema="primary"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ )}
+ </Td>
+ </Tr>
+ );
+ }
+ )}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState
+ title="No tokens have been created for this identity yet"
+ icon={faKey}
+ />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityTokenModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityTokenModal.tsx
new file mode 100644
index 0000000000..c188680eb9
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/IdentityTokenModal.tsx
@@ -0,0 +1,182 @@
+import { useEffect, useState } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FormControl,
+ IconButton,
+ Input,
+ Modal,
+ ModalContent,
+ Tooltip
+} from "@app/components/v2";
+import { useTimedReset } from "@app/hooks";
+import { useCreateTokenIdentityTokenAuth, useUpdateIdentityTokenAuthToken } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z
+ .object({
+ name: z.string()
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ popUp: UsePopUpState<["token"]>;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["token"]>, state?: boolean) => void;
+};
+
+export const IdentityTokenModal = ({ popUp, handlePopUpToggle }: Props) => {
+ const { mutateAsync: createToken } = useCreateTokenIdentityTokenAuth();
+ const { mutateAsync: updateToken } = useUpdateIdentityTokenAuthToken();
+ const [token, setToken] = useState("");
+ const [copyTextToken, isCopyingToken, setCopyTextToken] = useTimedReset<string>({
+ initialState: "Copy to clipboard"
+ });
+ const hasToken = Boolean(token);
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ name: ""
+ }
+ });
+
+ const tokenData = popUp?.token?.data as {
+ identityId: string;
+ tokenId?: string;
+ name?: string;
+ };
+
+ useEffect(() => {
+ if (tokenData?.tokenId && tokenData?.name) {
+ reset({
+ name: tokenData.name
+ });
+ } else {
+ reset({
+ name: ""
+ });
+ }
+ }, [popUp?.token?.data]);
+
+ const onFormSubmit = async ({ name }: FormData) => {
+ try {
+ if (tokenData?.tokenId) {
+ // update
+
+ await updateToken({
+ identityId: tokenData.identityId,
+ tokenId: tokenData.tokenId,
+ name
+ });
+
+ handlePopUpToggle("token", false);
+ } else {
+ // create
+
+ const newTokenData = await createToken({
+ identityId: tokenData.identityId,
+ name
+ });
+
+ setToken(newTokenData.accessToken);
+ }
+
+ createNotification({
+ text: `Successfully ${popUp?.token?.data ? "updated" : "created"} token`,
+ type: "success"
+ });
+
+ reset();
+ } catch (err) {
+ console.error(err);
+ const error = err as any;
+ const text =
+ error?.response?.data?.message ??
+ `Failed to ${popUp?.token?.data ? "update" : "create"} token`;
+
+ createNotification({
+ text,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.token?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("token", isOpen);
+ reset();
+ setToken("");
+ }}
+ >
+ <ModalContent
+ title={`${tokenData?.tokenId ? "Update" : "Create"} Access Token`}
+ subTitle={hasToken ? "We will only show this token once" : ""}
+ >
+ {!hasToken ? (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Name" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} placeholder="My Token" />
+ </FormControl>
+ )}
+ />
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {tokenData?.name ? "Update" : "Create"}
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("token", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ ) : (
+ <div className="mb-3 mr-2 mt-2 flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{token}</p>
+ <Tooltip content={copyTextToken}>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(token);
+ setCopyTextToken("Copied");
+ }}
+ >
+ <FontAwesomeIcon icon={isCopyingToken ? faCheck : faCopy} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ )}
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/index.tsx
new file mode 100644
index 0000000000..8fcbcfc212
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/-components/index.tsx
@@ -0,0 +1,6 @@
+export { IdentityAuthenticationSection } from "./IdentityAuthenticationSection/IdentityAuthenticationSection";
+export { IdentityClientSecretModal } from "./IdentityClientSecretModal";
+export { IdentityDetailsSection } from "./IdentityDetailsSection";
+export { IdentityProjectsSection } from "./IdentityProjectsSection/IdentityProjectsSection";
+export { IdentityTokenListModal } from "./IdentityTokenListModal";
+export { IdentityTokenModal } from "./IdentityTokenModal";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/index.tsx
new file mode 100644
index 0000000000..f5e20cd972
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/identities/$identityId/index.tsx
@@ -0,0 +1,415 @@
+/* eslint-disable @typescript-eslint/no-unused-vars */
+import { useState } from 'react'
+import { Helmet } from 'react-helmet'
+import { useTranslation } from 'react-i18next'
+import { faChevronLeft, faEllipsis } from '@fortawesome/free-solid-svg-icons'
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
+import { createFileRoute, useNavigate, useParams } from '@tanstack/react-router'
+import { twMerge } from 'tailwind-merge'
+
+import { createNotification } from '@app/components/notifications'
+import { OrgPermissionCan } from '@app/components/permissions'
+import {
+ Button,
+ DeleteActionModal,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ Tooltip,
+ UpgradePlanModal,
+} from '@app/components/v2'
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+} from '@app/context'
+import { withPermission } from '@app/hoc'
+import {
+ IdentityAuthMethod,
+ useDeleteIdentity,
+ useGetIdentityById,
+ useRevokeIdentityTokenAuthToken,
+ useRevokeIdentityUniversalAuthClientSecret,
+} from '@app/hooks/api'
+import { Identity } from '@app/hooks/api/identities/types'
+import { usePopUp } from '@app/hooks/usePopUp'
+import { TabSections } from '@app/types/org'
+
+import { IdentityAuthMethodModal } from '../../members/-components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal'
+import { IdentityModal } from '../../members/-components/OrgIdentityTab/components/IdentitySection/IdentityModal'
+import { IdentityUniversalAuthClientSecretModal } from '../../members/-components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthClientSecretModal'
+import {
+ IdentityAuthenticationSection,
+ IdentityClientSecretModal,
+ IdentityDetailsSection,
+ IdentityProjectsSection,
+ IdentityTokenListModal,
+ IdentityTokenModal,
+} from './-components'
+
+export const IdentitySection = withPermission(
+ () => {
+ const navigate = useNavigate()
+ const params = useParams({
+ from: '/_authenticate/_org_details/_org-layout/organization/$organizationId/identities/$identityId',
+ })
+ const identityId = params.identityId as string
+ const { currentOrg } = useOrganization()
+ const orgId = currentOrg?.id || ''
+ const { data } = useGetIdentityById(identityId)
+ const { mutateAsync: deleteIdentity } = useDeleteIdentity()
+ const { mutateAsync: revokeToken } = useRevokeIdentityTokenAuthToken()
+ const { mutateAsync: revokeClientSecret } =
+ useRevokeIdentityUniversalAuthClientSecret()
+
+ const [selectedAuthMethod, setSelectedAuthMethod] = useState<
+ Identity['authMethods'][number] | null
+ >(null)
+
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } =
+ usePopUp([
+ 'identity',
+ 'deleteIdentity',
+ 'identityAuthMethod',
+ 'revokeAuthMethod',
+ 'token',
+ 'tokenList',
+ 'revokeToken',
+ 'clientSecret',
+ 'revokeClientSecret',
+ 'universalAuthClientSecret', // list of client secrets
+ 'upgradePlan',
+ ] as const)
+
+ const onDeleteIdentitySubmit = async (id: string) => {
+ try {
+ await deleteIdentity({
+ identityId: id,
+ organizationId: orgId,
+ })
+
+ createNotification({
+ text: 'Successfully deleted identity',
+ type: 'success',
+ })
+
+ handlePopUpClose('deleteIdentity')
+ navigate({
+ to: `/organization/${orgId}/members` as const,
+ search: {
+ selectedTab: TabSections.Identities,
+ },
+ })
+ } catch (err) {
+ console.error(err)
+ const error = err as any
+ const text =
+ error?.response?.data?.message ?? 'Failed to delete identity'
+
+ createNotification({
+ text,
+ type: 'error',
+ })
+ }
+ }
+
+ const onRevokeTokenSubmit = async ({
+ identityId: parentIdentityId,
+ tokenId,
+ name,
+ }: {
+ identityId: string
+ tokenId: string
+ name: string
+ }) => {
+ try {
+ await revokeToken({
+ identityId: parentIdentityId,
+ tokenId,
+ })
+
+ handlePopUpClose('revokeToken')
+
+ createNotification({
+ text: `Successfully revoked token ${name ?? ''}`,
+ type: 'success',
+ })
+ } catch (err) {
+ console.error(err)
+ const error = err as any
+ const text =
+ error?.response?.data?.message ?? 'Failed to delete identity'
+
+ createNotification({
+ text,
+ type: 'error',
+ })
+ }
+ }
+
+ const onDeleteClientSecretSubmit = async ({
+ clientSecretId,
+ }: {
+ clientSecretId: string
+ }) => {
+ try {
+ if (
+ !data?.identity.id ||
+ selectedAuthMethod !== IdentityAuthMethod.UNIVERSAL_AUTH
+ )
+ return
+
+ await revokeClientSecret({
+ identityId: data?.identity.id,
+ clientSecretId,
+ })
+
+ handlePopUpToggle('revokeClientSecret', false)
+
+ createNotification({
+ text: 'Successfully deleted client secret',
+ type: 'success',
+ })
+ } catch (err) {
+ console.error(err)
+ createNotification({
+ text: 'Failed to delete client secret',
+ type: 'error',
+ })
+ }
+ }
+
+ return (
+ <div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white">
+ {data && (
+ <div className="mx-auto mb-6 w-full max-w-7xl px-6 py-6">
+ <Button
+ variant="link"
+ type="submit"
+ leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
+ onClick={() => {
+ navigate({
+ to: `/organization/${orgId}/members` as const,
+ search: {
+ selectedTab: TabSections.Identities,
+ },
+ })
+ }}
+ className="mb-4"
+ >
+ Identities
+ </Button>
+ <div className="mb-4 flex items-center justify-between">
+ <p className="text-3xl font-semibold text-white">
+ {data.identity.name}
+ </p>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <div className="hover:text-primary-400 data-[state=open]:text-primary-400">
+ <Tooltip content="More options">
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </Tooltip>
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Identity}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ !isAllowed &&
+ 'pointer-events-none cursor-not-allowed opacity-50',
+ )}
+ onClick={async () => {
+ handlePopUpOpen('identity', {
+ identityId,
+ name: data.identity.name,
+ role: data.role,
+ customRole: data.customRole,
+ })
+ }}
+ disabled={!isAllowed}
+ >
+ Edit Identity
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Identity}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ !isAllowed &&
+ 'pointer-events-none cursor-not-allowed opacity-50',
+ )}
+ onClick={async () => {
+ handlePopUpOpen('identityAuthMethod', {
+ identityId,
+ name: data.identity.name,
+ allAuthMethods: data.identity.authMethods,
+ })
+ }}
+ disabled={!isAllowed}
+ >
+ Add new auth method
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Identity}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ isAllowed
+ ? 'hover:!bg-red-500 hover:!text-white'
+ : 'pointer-events-none cursor-not-allowed opacity-50',
+ )}
+ onClick={async () => {
+ handlePopUpOpen('deleteIdentity', {
+ identityId,
+ name: data.identity.name,
+ })
+ }}
+ disabled={!isAllowed}
+ >
+ Delete Identity
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ <div className="flex">
+ <div className="mr-4 w-96">
+ <IdentityDetailsSection
+ identityId={identityId}
+ handlePopUpOpen={handlePopUpOpen}
+ />
+ <IdentityAuthenticationSection
+ selectedAuthMethod={selectedAuthMethod}
+ setSelectedAuthMethod={setSelectedAuthMethod}
+ identityId={identityId}
+ handlePopUpOpen={handlePopUpOpen}
+ />
+ </div>
+ <IdentityProjectsSection identityId={identityId} />
+ </div>
+ </div>
+ )}
+ <IdentityModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
+ <IdentityAuthMethodModal
+ popUp={popUp}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <IdentityTokenModal
+ popUp={popUp}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <IdentityTokenListModal
+ popUp={popUp}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <IdentityClientSecretModal
+ popUp={popUp}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <IdentityUniversalAuthClientSecretModal
+ popUp={popUp}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle('upgradePlan', isOpen)}
+ text={
+ (popUp.upgradePlan?.data as { description: string })?.description
+ }
+ />
+ <DeleteActionModal
+ isOpen={popUp.deleteIdentity.isOpen}
+ title={`Are you sure want to delete ${
+ (popUp?.deleteIdentity?.data as { name: string })?.name || ''
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle('deleteIdentity', isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() =>
+ onDeleteIdentitySubmit(
+ (popUp?.deleteIdentity?.data as { identityId: string })
+ ?.identityId,
+ )
+ }
+ />
+ <DeleteActionModal
+ isOpen={popUp.revokeToken.isOpen}
+ title={`Are you sure want to revoke ${
+ (popUp?.revokeToken?.data as { name: string })?.name || ''
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle('revokeToken', isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() => {
+ const revokeTokenData = popUp?.revokeToken?.data as {
+ identityId: string
+ tokenId: string
+ name: string
+ }
+
+ return onRevokeTokenSubmit(revokeTokenData)
+ }}
+ />
+ <DeleteActionModal
+ isOpen={popUp.revokeClientSecret.isOpen}
+ title={`Are you sure want to delete the client secret ${
+ (popUp?.revokeClientSecret?.data as { clientSecretPrefix: string })
+ ?.clientSecretPrefix || ''
+ }************?`}
+ onChange={(isOpen) => handlePopUpToggle('revokeClientSecret', isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() => {
+ const deleteClientSecretData = popUp?.revokeClientSecret?.data as {
+ clientSecretId: string
+ clientSecretPrefix: string
+ }
+
+ return onDeleteClientSecretSubmit({
+ clientSecretId: deleteClientSecretData.clientSecretId,
+ })
+ }}
+ />
+ </div>
+ )
+ },
+ {
+ action: OrgPermissionActions.Read,
+ subject: OrgPermissionSubjects.Identity,
+ },
+)
+
+const IdentityDetailPage = () => {
+ const { t } = useTranslation()
+ return (
+ <>
+ <Helmet>
+ <title>
+ {t('common.head-title', { title: t('settings.org.title') })}
+ </title>
+ <link rel="icon" href="/infisical.ico" />
+ </Helmet>
+ <IdentitySection />
+ </>
+ )
+}
+
+export const Route = createFileRoute(
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/identities/$identityId/',
+)({
+ component: IdentityDetailPage,
+})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/index.tsx
deleted file mode 100644
index d1bd04080d..0000000000
--- a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/index.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import {
- createFileRoute,
- useRouteContext,
- useRouter,
-} from '@tanstack/react-router'
-
-function RouteComponent() {
- const user = useRouteContext({
- from: '/_authenticate',
- select: (el) => el.user,
- })
- const router = useRouter()
-
- return (
- <div>
- Hello {user?.email}!
- <button
- type="button"
- onClick={() => {
- router.invalidate({
- filter: (d) => {
- console.log(d)
- return true
- },
- })
- }}
- >
- Click
- </button>
- </div>
- )
-}
-
-export const Route = createFileRoute(
- '/_authenticate/_org_details/_org-layout/organization/$organizationId/',
-)({
- component: RouteComponent,
-})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/kms/overview.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/kms/overview.tsx
new file mode 100644
index 0000000000..cb8b5f9d49
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/kms/overview.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+import { ProjectType } from '@app/hooks/api/workspace/types'
+
+import { ProductOverview } from '../secret-manager/overview'
+
+const KeyManagerOverviewPage = () => <ProductOverview type={ProjectType.KMS} />
+
+export const Route = createFileRoute(
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/kms/overview',
+)({
+ component: KeyManagerOverviewPage,
+})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/OrgGroupsTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/OrgGroupsTab.tsx
new file mode 100644
index 0000000000..428ee68d89
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/OrgGroupsTab.tsx
@@ -0,0 +1,18 @@
+import { motion } from "framer-motion";
+
+import { OrgGroupsSection } from "./components";
+
+export const OrgGroupsTab = () => {
+ return (
+ <motion.div
+ key="panel-org-groups"
+ transition={{ duration: 0.15 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: 30 }}
+ >
+ <OrgGroupsSection />
+ </motion.div>
+ );
+};
+
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupModal.tsx
new file mode 100644
index 0000000000..aaec0a5956
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupModal.tsx
@@ -0,0 +1,189 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FilterableSelect,
+ FormControl,
+ Input,
+ Modal,
+ ModalContent
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { findOrgMembershipRole } from "@app/helpers/roles";
+import { useCreateGroup, useGetOrgRoles, useUpdateGroup } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const GroupFormSchema = z.object({
+ name: z.string().min(1, "Name cannot be empty").max(50, "Name must be 50 characters or fewer"),
+ slug: z
+ .string()
+ .min(5, "Slug must be at least 5 characters long")
+ .max(36, "Slug must be 36 characters or fewer"),
+ role: z.object({ name: z.string(), slug: z.string() })
+});
+
+export type TGroupFormData = z.infer<typeof GroupFormSchema>;
+
+type Props = {
+ popUp: UsePopUpState<["group"]>;
+ handlePopUpClose: (popUpName: keyof UsePopUpState<["group"]>) => void;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["group"]>, state?: boolean) => void;
+};
+
+export const OrgGroupModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => {
+ const { currentOrg } = useOrganization();
+ const { data: roles } = useGetOrgRoles(currentOrg?.id || "");
+ const { mutateAsync: createMutateAsync, isLoading: createIsLoading } = useCreateGroup();
+ const { mutateAsync: updateMutateAsync, isLoading: updateIsLoading } = useUpdateGroup();
+
+ const { control, handleSubmit, reset } = useForm<TGroupFormData>({
+ resolver: zodResolver(GroupFormSchema)
+ });
+
+ useEffect(() => {
+ const group = popUp?.group?.data as {
+ groupId: string;
+ name: string;
+ slug: string;
+ role: string;
+ customRole: {
+ name: string;
+ slug: string;
+ };
+ };
+
+ if (!roles?.length) return;
+
+ if (group) {
+ reset({
+ name: group.name,
+ slug: group.slug,
+ role: group?.customRole ?? findOrgMembershipRole(roles, group.role)
+ });
+ } else {
+ reset({
+ name: "",
+ slug: "",
+ role: findOrgMembershipRole(roles, currentOrg!.defaultMembershipRole)
+ });
+ }
+ }, [popUp?.group?.data, roles]);
+
+ const onGroupModalSubmit = async ({ name, slug, role }: TGroupFormData) => {
+ try {
+ if (!currentOrg?.id) return;
+
+ const group = popUp?.group?.data as {
+ groupId: string;
+ name: string;
+ slug: string;
+ };
+
+ if (group) {
+ await updateMutateAsync({
+ id: group.groupId,
+ name,
+ slug,
+ role: role.slug || undefined
+ });
+ } else {
+ await createMutateAsync({
+ name,
+ slug,
+ organizationId: currentOrg.id,
+ role: role.slug || undefined
+ });
+ }
+ handlePopUpToggle("group", false);
+ reset();
+
+ createNotification({
+ text: `Successfully ${popUp?.group?.data ? "updated" : "created"} group`,
+ type: "success"
+ });
+ } catch {
+ createNotification({
+ text: `Failed to ${popUp?.group?.data ? "updated" : "created"} group`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.group?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("group", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent
+ bodyClassName="overflow-visible"
+ title={`${popUp?.group?.data ? "Update" : "Create"} Group`}
+ >
+ <form onSubmit={handleSubmit(onGroupModalSubmit)}>
+ <Controller
+ control={control}
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Name" errorText={error?.message} isError={Boolean(error)}>
+ <Input {...field} placeholder="Engineering" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="slug"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Slug" errorText={error?.message} isError={Boolean(error)}>
+ <Input {...field} placeholder="engineering" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="role"
+ render={({ field: { onChange, value }, fieldState: { error } }) => (
+ <FormControl
+ label={`${popUp?.group?.data ? "Update" : ""} Role`}
+ errorText={error?.message}
+ isError={Boolean(error)}
+ className="mt-4"
+ >
+ <FilterableSelect
+ options={roles}
+ placeholder="Select role..."
+ onChange={onChange}
+ value={value}
+ getOptionValue={(option) => option.slug}
+ getOptionLabel={(option) => option.name}
+ />
+ </FormControl>
+ )}
+ />
+ <div className="mt-8 flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={createIsLoading || updateIsLoading}
+ >
+ {!popUp?.group?.data ? "Create" : "Update"}
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpClose("group")}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsSection.tsx
new file mode 100644
index 0000000000..9c39491505
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsSection.tsx
@@ -0,0 +1,98 @@
+import { faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, DeleteActionModal, UpgradePlanModal } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
+import { useDeleteGroup } from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { OrgGroupModal } from "./OrgGroupModal";
+import { OrgGroupsTable } from "./OrgGroupsTable";
+
+export const OrgGroupsSection = () => {
+ const { subscription } = useSubscription();
+ const { mutateAsync: deleteMutateAsync } = useDeleteGroup();
+
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "group",
+ "groupMembers",
+ "deleteGroup",
+ "upgradePlan"
+ ] as const);
+
+ const handleAddGroupModal = () => {
+ if (!subscription?.groups) {
+ handlePopUpOpen("upgradePlan", {
+ description:
+ "You can manage users more efficiently with groups if you upgrade your Infisical plan."
+ });
+ } else {
+ handlePopUpOpen("group");
+ }
+ };
+
+ const onDeleteGroupSubmit = async ({ name, groupId }: { name: string; groupId: string }) => {
+ try {
+ await deleteMutateAsync({
+ id: groupId
+ });
+ createNotification({
+ text: `Successfully deleted the group named ${name}`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: `Failed to delete the group named ${name}`,
+ type: "error"
+ });
+ }
+
+ handlePopUpClose("deleteGroup");
+ };
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="mb-4 flex justify-between">
+ <p className="text-xl font-semibold text-mineshaft-100">Groups</p>
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Groups}>
+ {(isAllowed) => (
+ <Button
+ colorSchema="primary"
+ type="submit"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ onClick={() => handleAddGroupModal()}
+ isDisabled={!isAllowed}
+ >
+ Create Group
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <OrgGroupsTable handlePopUpOpen={handlePopUpOpen} />
+ <OrgGroupModal
+ popUp={popUp}
+ handlePopUpClose={handlePopUpClose}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <DeleteActionModal
+ isOpen={popUp.deleteGroup.isOpen}
+ title={`Are you sure want to delete the group named ${
+ (popUp?.deleteGroup?.data as { name: string })?.name || ""
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle("deleteGroup", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() =>
+ onDeleteGroupSubmit(popUp?.deleteGroup?.data as { name: string; groupId: string })
+ }
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text={(popUp.upgradePlan?.data as { description: string })?.description}
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx
new file mode 100644
index 0000000000..6edcf9ba81
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx
@@ -0,0 +1,397 @@
+import { useMemo } from "react";
+import {
+ faArrowDown,
+ faArrowUp,
+ faEllipsis,
+ faMagnifyingGlass,
+ faSearch,
+ faUsers
+} from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { twMerge } from "tailwind-merge";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ EmptyState,
+ IconButton,
+ Input,
+ Pagination,
+ Select,
+ SelectItem,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { usePagination, useResetPageHelper } from "@app/hooks";
+import { useGetOrganizationGroups, useGetOrgRoles, useUpdateGroup } from "@app/hooks/api";
+import { OrderByDirection } from "@app/hooks/api/generic/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+import { useNavigate } from "@tanstack/react-router";
+
+type Props = {
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["group", "deleteGroup", "groupMembers"]>,
+ data?: {
+ groupId?: string;
+ name?: string;
+ slug?: string;
+ role?: string;
+ customRole?: {
+ name: string;
+ slug: string;
+ };
+ }
+ ) => void;
+};
+
+enum GroupsOrderBy {
+ Name = "name",
+ Slug = "slug",
+ Role = "role"
+}
+
+export const OrgGroupsTable = ({ handlePopUpOpen }: Props) => {
+ const navigate = useNavigate();
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { isLoading, data: groups = [] } = useGetOrganizationGroups(orgId);
+ const { mutateAsync: updateMutateAsync } = useUpdateGroup();
+
+ const { data: roles } = useGetOrgRoles(orgId);
+
+ const handleChangeRole = async ({ id, role }: { id: string; role: string }) => {
+ try {
+ await updateMutateAsync({
+ id,
+ role
+ });
+
+ createNotification({
+ text: "Successfully updated group role",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to update group role",
+ type: "error"
+ });
+ }
+ };
+
+ const {
+ search,
+ setSearch,
+ setPage,
+ page,
+ perPage,
+ setPerPage,
+ offset,
+ orderDirection,
+ orderBy,
+ setOrderBy,
+ setOrderDirection,
+ toggleOrderDirection
+ } = usePagination<GroupsOrderBy>(GroupsOrderBy.Name, { initPerPage: 20 });
+
+ const filteredGroups = useMemo(() => {
+ const filtered = search
+ ? groups?.filter(
+ ({ name, slug }) =>
+ name.toLowerCase().includes(search.toLowerCase()) ||
+ slug.toLowerCase().includes(search.toLowerCase())
+ )
+ : groups;
+
+ const ordered = filtered?.sort((a, b) => {
+ switch (orderBy) {
+ case GroupsOrderBy.Role: {
+ const aValue = a.role === "custom" ? (a.customRole?.name as string) : a.role;
+ const bValue = b.role === "custom" ? (b.customRole?.name as string) : b.role;
+
+ return aValue.toLowerCase().localeCompare(bValue.toLowerCase());
+ }
+ default:
+ return a[orderBy].toLowerCase().localeCompare(b[orderBy].toLowerCase());
+ }
+ });
+
+ return orderDirection === OrderByDirection.ASC ? ordered : ordered?.reverse();
+ }, [search, groups, orderBy, orderDirection]);
+
+ const handleSort = (column: GroupsOrderBy) => {
+ if (column === orderBy) {
+ toggleOrderDirection();
+ return;
+ }
+
+ setOrderBy(column);
+ setOrderDirection(OrderByDirection.ASC);
+ };
+
+ useResetPageHelper({
+ totalCount: filteredGroups.length,
+ offset,
+ setPage
+ });
+
+ return (
+ <div>
+ <Input
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search groups..."
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th>
+ <div className="flex items-center">
+ Name
+ <IconButton
+ variant="plain"
+ className={`ml-2 ${orderBy === GroupsOrderBy.Name ? "" : "opacity-30"}`}
+ ariaLabel="sort"
+ onClick={() => handleSort(GroupsOrderBy.Name)}
+ >
+ <FontAwesomeIcon
+ icon={
+ orderDirection === OrderByDirection.DESC && orderBy === GroupsOrderBy.Name
+ ? faArrowUp
+ : faArrowDown
+ }
+ />
+ </IconButton>
+ </div>
+ </Th>
+ <Th>
+ <div className="flex items-center">
+ Slug
+ <IconButton
+ variant="plain"
+ className={`ml-2 ${orderBy === GroupsOrderBy.Slug ? "" : "opacity-30"}`}
+ ariaLabel="sort"
+ onClick={() => handleSort(GroupsOrderBy.Slug)}
+ >
+ <FontAwesomeIcon
+ icon={
+ orderDirection === OrderByDirection.DESC && orderBy === GroupsOrderBy.Slug
+ ? faArrowUp
+ : faArrowDown
+ }
+ />
+ </IconButton>
+ </div>
+ </Th>
+ <Th>
+ <div className="flex items-center">
+ Role
+ <IconButton
+ variant="plain"
+ className={`ml-2 ${orderBy === GroupsOrderBy.Role ? "" : "opacity-30"}`}
+ ariaLabel="sort"
+ onClick={() => handleSort(GroupsOrderBy.Role)}
+ >
+ <FontAwesomeIcon
+ icon={
+ orderDirection === OrderByDirection.DESC && orderBy === GroupsOrderBy.Role
+ ? faArrowUp
+ : faArrowDown
+ }
+ />
+ </IconButton>
+ </div>
+ </Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={4} innerKey="org-groups" />}
+ {!isLoading &&
+ filteredGroups
+ .slice(offset, perPage * page)
+ .map(({ id, name, slug, role, customRole }) => {
+ return (
+ <Tr
+ onClick={() =>
+ navigate({
+ to: "/organization/$organizationId/groups/$groupId",
+ params: {
+ organizationId: currentOrg.id,
+ groupId: id
+ }
+ })
+ }
+ className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ key={`org-group-${id}`}
+ >
+ <Td>{name}</Td>
+ <Td>{slug}</Td>
+ <Td>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Groups}
+ >
+ {(isAllowed) => {
+ return (
+ <Select
+ value={role === "custom" ? (customRole?.slug as string) : role}
+ isDisabled={!isAllowed}
+ className="w-48 bg-mineshaft-600"
+ dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
+ onValueChange={(selectedRole) =>
+ handleChangeRole({
+ id,
+ role: selectedRole
+ })
+ }
+ >
+ {(roles || []).map(({ slug: roleSlug, name: roleName }) => (
+ <SelectItem value={roleSlug} key={`role-option-${roleSlug}`}>
+ {roleName}
+ </SelectItem>
+ ))}
+ </Select>
+ );
+ }}
+ </OrgPermissionCan>
+ </Td>
+ <Td>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <div className="hover:text-primary-400 data-[state=open]:text-primary-400">
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+ createNotification({
+ text: "Copied group ID to clipboard",
+ type: "info"
+ });
+ navigator.clipboard.writeText(id);
+ }}
+ >
+ Copy Group ID
+ </DropdownMenuItem>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Groups}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ !isAllowed &&
+ "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("group", {
+ groupId: id,
+ name,
+ slug,
+ role,
+ customRole
+ });
+ }}
+ disabled={!isAllowed}
+ >
+ Edit Group
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Groups}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ !isAllowed &&
+ "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={() =>
+ navigate({
+ to: "/organization/$organizationId/groups/$groupId",
+ params: {
+ organizationId: currentOrg.id,
+ groupId: id
+ }
+ })
+ }
+ disabled={!isAllowed}
+ >
+ Manage Members
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Groups}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ isAllowed
+ ? "hover:!bg-red-500 hover:!text-white"
+ : "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("deleteGroup", {
+ groupId: id,
+ name
+ });
+ }}
+ disabled={!isAllowed}
+ >
+ Delete Group
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </Td>
+ </Tr>
+ );
+ })}
+ </TBody>
+ </Table>
+ {Boolean(filteredGroups.length) && (
+ <Pagination
+ count={filteredGroups.length}
+ page={page}
+ perPage={perPage}
+ onChangePage={setPage}
+ onChangePerPage={setPerPage}
+ />
+ )}
+ {!isLoading && !filteredGroups?.length && (
+ <EmptyState
+ title={
+ groups.length
+ ? "No organization groups match search..."
+ : "No organization groups found"
+ }
+ icon={groups.length ? faSearch : faUsers}
+ />
+ )}
+ </TableContainer>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/index.tsx
new file mode 100644
index 0000000000..ca3caabea3
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/OrgGroupsSection/index.tsx
@@ -0,0 +1 @@
+export { OrgGroupsSection } from "./OrgGroupsSection";
\ No newline at end of file
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/index.tsx
new file mode 100644
index 0000000000..ca3caabea3
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/components/index.tsx
@@ -0,0 +1 @@
+export { OrgGroupsSection } from "./OrgGroupsSection";
\ No newline at end of file
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/index.tsx
new file mode 100644
index 0000000000..69936a978e
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgGroupsTab/index.tsx
@@ -0,0 +1 @@
+export { OrgGroupsTab } from "./OrgGroupsTab";
\ No newline at end of file
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/OrgIdentityTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/OrgIdentityTab.tsx
new file mode 100644
index 0000000000..251b0b831c
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/OrgIdentityTab.tsx
@@ -0,0 +1,17 @@
+import { motion } from "framer-motion";
+
+import { IdentitySection } from "./components";
+
+export const OrgIdentityTab = () => {
+ return (
+ <motion.div
+ key="panel-service-token"
+ transition={{ duration: 0.15 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: 30 }}
+ >
+ <IdentitySection />
+ </motion.div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal.tsx
new file mode 100644
index 0000000000..70128fa1a8
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal.tsx
@@ -0,0 +1,55 @@
+import { useState } from "react";
+
+import { Modal, ModalContent } from "@app/components/v2";
+import { IdentityAuthMethod, identityAuthToNameMap } from "@app/hooks/api/identities";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+import { IdentityAuthMethodModalContent } from "./IdentityAuthMethodModalContent";
+
+type Props = {
+ popUp: UsePopUpState<["identityAuthMethod", "upgradePlan", "revokeAuthMethod"]>;
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["identityAuthMethod", "upgradePlan", "revokeAuthMethod"]>,
+ state?: boolean
+ ) => void;
+};
+
+export const IdentityAuthMethodModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Props) => {
+ const [selectedAuthMethod, setSelectedAuthMethod] = useState<IdentityAuthMethod | null>(null);
+
+ const initialAuthMethod = popUp?.identityAuthMethod?.data?.authMethod;
+
+ const isSelectedAuthAlreadyConfigured =
+ popUp?.identityAuthMethod?.data?.allAuthMethods?.includes(selectedAuthMethod);
+
+ return (
+ <Modal
+ isOpen={popUp?.identityAuthMethod?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("identityAuthMethod", isOpen);
+ }}
+ >
+ <ModalContent
+ title={
+ isSelectedAuthAlreadyConfigured
+ ? `Edit ${identityAuthToNameMap[selectedAuthMethod!] ?? ""}`
+ : `Create new ${identityAuthToNameMap[selectedAuthMethod!] ?? ""}`
+ }
+ >
+ <IdentityAuthMethodModalContent
+ popUp={popUp}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ identity={{
+ name: popUp?.identityAuthMethod?.data?.name,
+ authMethods: popUp?.identityAuthMethod?.data?.allAuthMethods,
+ id: popUp?.identityAuthMethod.data?.identityId
+ }}
+ initialAuthMethod={initialAuthMethod}
+ setSelectedAuthMethod={setSelectedAuthMethod}
+ />
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModalContent.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModalContent.tsx
new file mode 100644
index 0000000000..1df1294860
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModalContent.tsx
@@ -0,0 +1,335 @@
+import { useCallback } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Badge,
+ DeleteActionModal,
+ FormControl,
+ Select,
+ SelectItem,
+ Tooltip,
+ UpgradePlanModal
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import {
+ useDeleteIdentityAwsAuth,
+ useDeleteIdentityAzureAuth,
+ useDeleteIdentityGcpAuth,
+ useDeleteIdentityKubernetesAuth,
+ useDeleteIdentityOidcAuth,
+ useDeleteIdentityTokenAuth,
+ useDeleteIdentityUniversalAuth
+} from "@app/hooks/api";
+import {
+ IdentityAuthMethod,
+ identityAuthToNameMap,
+ useDeleteIdentityJwtAuth
+} from "@app/hooks/api/identities";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+import { IdentityAwsAuthForm } from "./IdentityAwsAuthForm";
+import { IdentityAzureAuthForm } from "./IdentityAzureAuthForm";
+import { IdentityGcpAuthForm } from "./IdentityGcpAuthForm";
+import { IdentityJwtAuthForm } from "./IdentityJwtAuthForm";
+import { IdentityKubernetesAuthForm } from "./IdentityKubernetesAuthForm";
+import { IdentityOidcAuthForm } from "./IdentityOidcAuthForm";
+import { IdentityTokenAuthForm } from "./IdentityTokenAuthForm";
+import { IdentityUniversalAuthForm } from "./IdentityUniversalAuthForm";
+
+type Props = {
+ popUp: UsePopUpState<["identityAuthMethod", "upgradePlan", "revokeAuthMethod"]>;
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["identityAuthMethod", "upgradePlan", "revokeAuthMethod"]>,
+ state?: boolean
+ ) => void;
+
+ identity: {
+ name: string;
+ id: string;
+ authMethods: IdentityAuthMethod[];
+ };
+ initialAuthMethod: IdentityAuthMethod;
+ setSelectedAuthMethod: (authMethod: IdentityAuthMethod) => void;
+};
+
+type TRevokeOptions = {
+ identityId: string;
+ organizationId: string;
+};
+
+type TRevokeMethods = {
+ revokeMethod: (revokeOptions: TRevokeOptions) => Promise<any>;
+ render: () => JSX.Element;
+};
+
+const identityAuthMethods = [
+ { label: "Token Auth", value: IdentityAuthMethod.TOKEN_AUTH },
+ { label: "Universal Auth", value: IdentityAuthMethod.UNIVERSAL_AUTH },
+ { label: "Kubernetes Auth", value: IdentityAuthMethod.KUBERNETES_AUTH },
+ { label: "GCP Auth", value: IdentityAuthMethod.GCP_AUTH },
+ { label: "AWS Auth", value: IdentityAuthMethod.AWS_AUTH },
+ { label: "Azure Auth", value: IdentityAuthMethod.AZURE_AUTH },
+ { label: "OIDC Auth", value: IdentityAuthMethod.OIDC_AUTH },
+ {
+ label: "JWT Auth",
+ value: IdentityAuthMethod.JWT_AUTH
+ }
+];
+
+const schema = z
+ .object({
+ authMethod: z.nativeEnum(IdentityAuthMethod)
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+export const IdentityAuthMethodModalContent = ({
+ popUp,
+ handlePopUpOpen,
+ handlePopUpToggle,
+ identity,
+ initialAuthMethod,
+ setSelectedAuthMethod
+}: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+
+ const { mutateAsync: revokeUniversalAuth } = useDeleteIdentityUniversalAuth();
+ const { mutateAsync: revokeTokenAuth } = useDeleteIdentityTokenAuth();
+ const { mutateAsync: revokeKubernetesAuth } = useDeleteIdentityKubernetesAuth();
+ const { mutateAsync: revokeGcpAuth } = useDeleteIdentityGcpAuth();
+ const { mutateAsync: revokeAwsAuth } = useDeleteIdentityAwsAuth();
+ const { mutateAsync: revokeAzureAuth } = useDeleteIdentityAzureAuth();
+ const { mutateAsync: revokeOidcAuth } = useDeleteIdentityOidcAuth();
+ const { mutateAsync: revokeJwtAuth } = useDeleteIdentityJwtAuth();
+
+ const { control, watch } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: async () => {
+ let authMethod = initialAuthMethod;
+
+ if (!authMethod) {
+ const firstAuthMethodNotConfiguredAuthMethod = identityAuthMethods.find(
+ ({ value }) => !identity?.authMethods?.includes(value)
+ );
+
+ if (firstAuthMethodNotConfiguredAuthMethod) {
+ authMethod = firstAuthMethodNotConfiguredAuthMethod.value;
+ }
+ }
+
+ setSelectedAuthMethod(authMethod);
+ return {
+ authMethod
+ };
+ }
+ });
+
+ const watchedAuthMethod = watch("authMethod");
+
+ const identityAuthMethodData = {
+ identityId: identity.id,
+ name: identity.name,
+ authMethod: watch("authMethod"),
+ configuredAuthMethods: identity.authMethods
+ } as {
+ identityId: string;
+ name: string;
+ authMethod?: IdentityAuthMethod;
+ configuredAuthMethods?: IdentityAuthMethod[];
+ };
+
+ const isSelectedAuthAlreadyConfigured =
+ identityAuthMethodData?.configuredAuthMethods?.includes(watchedAuthMethod);
+
+ const methodMap: Record<IdentityAuthMethod, TRevokeMethods | undefined> = {
+ [IdentityAuthMethod.UNIVERSAL_AUTH]: {
+ revokeMethod: revokeUniversalAuth,
+ render: () => (
+ <IdentityUniversalAuthForm
+ identityAuthMethodData={identityAuthMethodData}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ )
+ },
+
+ [IdentityAuthMethod.OIDC_AUTH]: {
+ revokeMethod: revokeOidcAuth,
+ render: () => (
+ <IdentityOidcAuthForm
+ identityAuthMethodData={identityAuthMethodData}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ )
+ },
+
+ [IdentityAuthMethod.TOKEN_AUTH]: {
+ revokeMethod: revokeTokenAuth,
+ render: () => (
+ <IdentityTokenAuthForm
+ identityAuthMethodData={identityAuthMethodData}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ )
+ },
+
+ [IdentityAuthMethod.AZURE_AUTH]: {
+ revokeMethod: revokeAzureAuth,
+ render: () => (
+ <IdentityAzureAuthForm
+ identityAuthMethodData={identityAuthMethodData}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ )
+ },
+
+ [IdentityAuthMethod.GCP_AUTH]: {
+ revokeMethod: revokeGcpAuth,
+ render: () => (
+ <IdentityGcpAuthForm
+ identityAuthMethodData={identityAuthMethodData}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ )
+ },
+
+ [IdentityAuthMethod.KUBERNETES_AUTH]: {
+ revokeMethod: revokeKubernetesAuth,
+ render: () => (
+ <IdentityKubernetesAuthForm
+ identityAuthMethodData={identityAuthMethodData}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ )
+ },
+
+ [IdentityAuthMethod.AWS_AUTH]: {
+ revokeMethod: revokeAwsAuth,
+ render: () => (
+ <IdentityAwsAuthForm
+ identityAuthMethodData={identityAuthMethodData}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ )
+ },
+
+ [IdentityAuthMethod.JWT_AUTH]: {
+ revokeMethod: revokeJwtAuth,
+ render: () => (
+ <IdentityJwtAuthForm
+ identityAuthMethodData={identityAuthMethodData}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ )
+ }
+ };
+
+ const isAlreadyConfigured = useCallback((method: IdentityAuthMethod) => {
+ return identityAuthMethodData?.configuredAuthMethods?.includes(method);
+ }, []);
+
+ const selectedMethodItem = methodMap[identityAuthMethodData.authMethod!];
+
+ return (
+ <>
+ <Controller
+ control={control}
+ name="authMethod"
+ defaultValue={IdentityAuthMethod.UNIVERSAL_AUTH}
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl label="Auth Method" errorText={error?.message} isError={Boolean(error)}>
+ <Select
+ isDisabled={isSelectedAuthAlreadyConfigured}
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => {
+ if (!isAlreadyConfigured(e as IdentityAuthMethod)) {
+ setSelectedAuthMethod(e as IdentityAuthMethod);
+ onChange(e);
+ }
+ }}
+ className="w-full"
+ >
+ {identityAuthMethods.map(({ label, value }) => {
+ const alreadyConfigured = isAlreadyConfigured(value);
+ return (
+ <Tooltip
+ key={`auth-method-${value}`}
+ content="Authentication method already configured"
+ isDisabled={!alreadyConfigured}
+ >
+ <SelectItem
+ isDisabled={alreadyConfigured}
+ value={String(value || "")}
+ key={label}
+ >
+ {label}{" "}
+ {alreadyConfigured && !isSelectedAuthAlreadyConfigured && (
+ <Badge>Configured</Badge>
+ )}
+ </SelectItem>
+ </Tooltip>
+ );
+ })}
+ </Select>
+ </FormControl>
+ )}
+ />
+ {selectedMethodItem?.render ? selectedMethodItem.render() : <div />}
+ <UpgradePlanModal
+ isOpen={popUp?.upgradePlan?.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text="You can use IP allowlisting if you switch to Infisical's Pro plan."
+ />
+ <DeleteActionModal
+ isOpen={popUp?.revokeAuthMethod?.isOpen}
+ title={`Are you sure want to remove ${
+ identityAuthMethodData?.authMethod
+ ? identityAuthToNameMap[identityAuthMethodData.authMethod]
+ : "the auth method"
+ } on ${identityAuthMethodData?.name ?? ""}?`}
+ onChange={(isOpen) => handlePopUpToggle("revokeAuthMethod", isOpen)}
+ deleteKey="confirm"
+ buttonText="Remove"
+ onDeleteApproved={async () => {
+ if (!identityAuthMethodData.authMethod || !orgId || !selectedMethodItem) {
+ return;
+ }
+
+ try {
+ await selectedMethodItem.revokeMethod({
+ identityId: identityAuthMethodData.identityId,
+ organizationId: orgId
+ });
+
+ createNotification({
+ text: "Successfully removed auth method",
+ type: "success"
+ });
+
+ handlePopUpToggle("revokeAuthMethod", false);
+ handlePopUpToggle("identityAuthMethod", false);
+ } catch {
+ createNotification({
+ text: "Failed to remove auth method",
+ type: "error"
+ });
+ }
+ }}
+ />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx
new file mode 100644
index 0000000000..59528e3a78
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx
@@ -0,0 +1,377 @@
+import { useEffect } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, IconButton, Input } from "@app/components/v2";
+import { useOrganization, useSubscription } from "@app/context";
+import {
+ useAddIdentityAwsAuth,
+ useGetIdentityAwsAuth,
+ useUpdateIdentityAwsAuth
+} from "@app/hooks/api";
+import { IdentityAuthMethod } from "@app/hooks/api/identities";
+import { IdentityTrustedIp } from "@app/hooks/api/identities/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z
+ .object({
+ stsEndpoint: z.string(),
+ allowedPrincipalArns: z.string(),
+ allowedAccountIds: z.string(),
+ accessTokenTTL: z
+ .string()
+ .refine(
+ (value) => Number(value) <= 315360000,
+ "Access Token TTL cannot be greater than 315360000"
+ ),
+ accessTokenMaxTTL: z
+ .string()
+ .refine(
+ (value) => Number(value) <= 315360000,
+ "Access Token Max TTL cannot be greater than 315360000"
+ ),
+ accessTokenNumUsesLimit: z.string(),
+ accessTokenTrustedIps: z
+ .object({
+ ipAddress: z.string().max(50)
+ })
+ .array()
+ .min(1)
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["identityAuthMethod", "revokeAuthMethod"]>,
+ state?: boolean
+ ) => void;
+ identityAuthMethodData: {
+ identityId: string;
+ name: string;
+ configuredAuthMethods?: IdentityAuthMethod[];
+ authMethod?: IdentityAuthMethod;
+ };
+};
+
+export const IdentityAwsAuthForm = ({
+ handlePopUpOpen,
+ handlePopUpToggle,
+ identityAuthMethodData
+}: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { subscription } = useSubscription();
+
+ const { mutateAsync: addMutateAsync } = useAddIdentityAwsAuth();
+ const { mutateAsync: updateMutateAsync } = useUpdateIdentityAwsAuth();
+
+ const isUpdate = identityAuthMethodData?.configuredAuthMethods?.includes(
+ identityAuthMethodData.authMethod! || ""
+ );
+ const { data } = useGetIdentityAwsAuth(identityAuthMethodData?.identityId ?? "", {
+ enabled: isUpdate
+ });
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ stsEndpoint: "https://sts.amazonaws.com/",
+ allowedPrincipalArns: "",
+ allowedAccountIds: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ }
+ });
+
+ const {
+ fields: accessTokenTrustedIpsFields,
+ append: appendAccessTokenTrustedIp,
+ remove: removeAccessTokenTrustedIp
+ } = useFieldArray({ control, name: "accessTokenTrustedIps" });
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ stsEndpoint: data.stsEndpoint,
+ allowedPrincipalArns: data.allowedPrincipalArns,
+ allowedAccountIds: data.allowedAccountIds,
+ accessTokenTTL: String(data.accessTokenTTL),
+ accessTokenMaxTTL: String(data.accessTokenMaxTTL),
+ accessTokenNumUsesLimit: String(data.accessTokenNumUsesLimit),
+ accessTokenTrustedIps: data.accessTokenTrustedIps.map(
+ ({ ipAddress, prefix }: IdentityTrustedIp) => {
+ return {
+ ipAddress: `${ipAddress}${prefix !== undefined ? `/${prefix}` : ""}`
+ };
+ }
+ )
+ });
+ } else {
+ reset({
+ stsEndpoint: "https://sts.amazonaws.com/",
+ allowedPrincipalArns: "",
+ allowedAccountIds: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ });
+ }
+ }, [data]);
+
+ const onFormSubmit = async ({
+ allowedPrincipalArns,
+ allowedAccountIds,
+ stsEndpoint,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps
+ }: FormData) => {
+ try {
+ if (!identityAuthMethodData) return;
+
+ if (data) {
+ await updateMutateAsync({
+ organizationId: orgId,
+ stsEndpoint,
+ allowedPrincipalArns,
+ allowedAccountIds,
+ identityId: identityAuthMethodData.identityId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ } else {
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId: identityAuthMethodData.identityId,
+ stsEndpoint: stsEndpoint || "",
+ allowedPrincipalArns: allowedPrincipalArns || "",
+ allowedAccountIds: allowedAccountIds || "",
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ }
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
+ } catch {
+ createNotification({
+ text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="allowedPrincipalArns"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Allowed Principal ARNs"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ {...field}
+ placeholder="arn:aws:iam::123456789012:role/MyRoleName, arn:aws:iam::123456789012:user/MyUserName..."
+ type="text"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="allowedAccountIds"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Allowed Account IDs"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="123456789012, ..." />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="https://sts.amazonaws.com/"
+ name="stsEndpoint"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="STS Endpoint" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} placeholder="https://sts.amazonaws.com/" type="text" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenMaxTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="0"
+ name="accessTokenNumUsesLimit"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max Number of Uses"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ </FormControl>
+ )}
+ />
+ {accessTokenTrustedIpsFields.map(({ id }, index) => (
+ <div className="mb-3 flex items-end space-x-2" key={id}>
+ <Controller
+ control={control}
+ name={`accessTokenTrustedIps.${index}.ipAddress`}
+ defaultValue="0.0.0.0/0"
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ label={index === 0 ? "Access Token Trusted IPs" : undefined}
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => {
+ if (subscription?.ipAllowlisting) {
+ field.onChange(e);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ placeholder="123.456.789.0"
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <IconButton
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ removeAccessTokenTrustedIp(index);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ appendAccessTokenTrustedIp({
+ ipAddress: "0.0.0.0/0"
+ });
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add IP Address
+ </Button>
+ </div>
+ <div className="flex justify-between">
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {!isUpdate ? "Create" : "Edit"}
+ </Button>
+
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("identityAuthMethod", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ {isUpdate && (
+ <Button
+ size="sm"
+ colorSchema="danger"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ onClick={() => handlePopUpToggle("revokeAuthMethod", true)}
+ >
+ Remove Auth Method
+ </Button>
+ )}
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm.tsx
new file mode 100644
index 0000000000..7af8798881
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm.tsx
@@ -0,0 +1,373 @@
+import { useEffect } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, IconButton, Input } from "@app/components/v2";
+import { useOrganization, useSubscription } from "@app/context";
+import {
+ useAddIdentityAzureAuth,
+ useGetIdentityAzureAuth,
+ useUpdateIdentityAzureAuth
+} from "@app/hooks/api";
+import { IdentityAuthMethod } from "@app/hooks/api/identities";
+import { IdentityTrustedIp } from "@app/hooks/api/identities/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z
+ .object({
+ tenantId: z.string().min(1),
+ resource: z.string(),
+ allowedServicePrincipalIds: z.string(),
+ accessTokenTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token TTL cannot be greater than 315360000"
+ }),
+ accessTokenMaxTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token Max TTL cannot be greater than 315360000"
+ }),
+ accessTokenNumUsesLimit: z.string(),
+ accessTokenTrustedIps: z
+ .array(
+ z.object({
+ ipAddress: z.string().max(50)
+ })
+ )
+ .min(1)
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["identityAuthMethod", "revokeAuthMethod"]>,
+ state?: boolean
+ ) => void;
+ identityAuthMethodData: {
+ identityId: string;
+ name: string;
+ configuredAuthMethods?: IdentityAuthMethod[];
+ authMethod?: IdentityAuthMethod;
+ };
+};
+
+export const IdentityAzureAuthForm = ({
+ handlePopUpOpen,
+ handlePopUpToggle,
+ identityAuthMethodData
+}: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { subscription } = useSubscription();
+
+ const { mutateAsync: addMutateAsync } = useAddIdentityAzureAuth();
+ const { mutateAsync: updateMutateAsync } = useUpdateIdentityAzureAuth();
+
+ const isUpdate = identityAuthMethodData?.configuredAuthMethods?.includes(
+ identityAuthMethodData.authMethod! || ""
+ );
+ const { data } = useGetIdentityAzureAuth(identityAuthMethodData?.identityId ?? "", {
+ enabled: isUpdate
+ });
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ tenantId: "",
+ resource: "https://management.azure.com/",
+ allowedServicePrincipalIds: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ }
+ });
+
+ const {
+ fields: accessTokenTrustedIpsFields,
+ append: appendAccessTokenTrustedIp,
+ remove: removeAccessTokenTrustedIp
+ } = useFieldArray({ control, name: "accessTokenTrustedIps" });
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ tenantId: data.tenantId,
+ resource: data.resource,
+ allowedServicePrincipalIds: data.allowedServicePrincipalIds,
+ accessTokenTTL: String(data.accessTokenTTL),
+ accessTokenMaxTTL: String(data.accessTokenMaxTTL),
+ accessTokenNumUsesLimit: String(data.accessTokenNumUsesLimit),
+ accessTokenTrustedIps: data.accessTokenTrustedIps.map(
+ ({ ipAddress, prefix }: IdentityTrustedIp) => {
+ return {
+ ipAddress: `${ipAddress}${prefix !== undefined ? `/${prefix}` : ""}`
+ };
+ }
+ )
+ });
+ } else {
+ reset({
+ tenantId: "",
+ resource: "https://management.azure.com/",
+ allowedServicePrincipalIds: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ });
+ }
+ }, [data]);
+
+ const onFormSubmit = async ({
+ tenantId,
+ resource,
+ allowedServicePrincipalIds,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps
+ }: FormData) => {
+ try {
+ if (!identityAuthMethodData) return;
+
+ if (data) {
+ await updateMutateAsync({
+ organizationId: orgId,
+ identityId: identityAuthMethodData.identityId,
+ tenantId,
+ resource,
+ allowedServicePrincipalIds,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ } else {
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId: identityAuthMethodData.identityId,
+ tenantId: tenantId || "",
+ resource: resource || "",
+ allowedServicePrincipalIds: allowedServicePrincipalIds || "",
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ }
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
+ } catch {
+ createNotification({
+ text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="tenantId"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Tenant ID"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ isRequired
+ >
+ <Input {...field} placeholder="00000000-0000-0000-0000-000000000000" type="text" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="resource"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Resource / Audience"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="https://management.azure.com/" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="allowedServicePrincipalIds"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Allowed Service Principal IDs"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="00000000-0000-0000-0000-000000000000, ..." />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenMaxTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="0"
+ name="accessTokenNumUsesLimit"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max Number of Uses"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ </FormControl>
+ )}
+ />
+ {accessTokenTrustedIpsFields.map(({ id }, index) => (
+ <div className="mb-3 flex items-end space-x-2" key={id}>
+ <Controller
+ control={control}
+ name={`accessTokenTrustedIps.${index}.ipAddress`}
+ defaultValue="0.0.0.0/0"
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ label={index === 0 ? "Access Token Trusted IPs" : undefined}
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => {
+ if (subscription?.ipAllowlisting) {
+ field.onChange(e);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ placeholder="123.456.789.0"
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <IconButton
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ removeAccessTokenTrustedIp(index);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ appendAccessTokenTrustedIp({
+ ipAddress: "0.0.0.0/0"
+ });
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add IP Address
+ </Button>
+ </div>
+ <div className="flex justify-between">
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {!isUpdate ? "Create" : "Edit"}
+ </Button>
+
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("identityAuthMethod", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ {isUpdate && (
+ <Button
+ size="sm"
+ colorSchema="danger"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ onClick={() => handlePopUpToggle("revokeAuthMethod", true)}
+ >
+ Remove Auth Method
+ </Button>
+ )}
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx
new file mode 100644
index 0000000000..0cccb82137
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx
@@ -0,0 +1,406 @@
+import { useEffect } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, IconButton, Input, Select, SelectItem } from "@app/components/v2";
+import { useOrganization, useSubscription } from "@app/context";
+import {
+ useAddIdentityGcpAuth,
+ useGetIdentityGcpAuth,
+ useUpdateIdentityGcpAuth
+} from "@app/hooks/api";
+import { IdentityAuthMethod } from "@app/hooks/api/identities";
+import { IdentityTrustedIp } from "@app/hooks/api/identities/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z
+ .object({
+ type: z.enum(["iam", "gce"]),
+ allowedServiceAccounts: z.string(),
+ allowedProjects: z.string(),
+ allowedZones: z.string(),
+ accessTokenTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token TTL cannot be greater than 315360000"
+ }),
+ accessTokenMaxTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token Max TTL cannot be greater than 315360000"
+ }),
+ accessTokenNumUsesLimit: z.string(),
+ accessTokenTrustedIps: z
+ .array(
+ z.object({
+ ipAddress: z.string().max(50)
+ })
+ )
+ .min(1)
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["identityAuthMethod", "revokeAuthMethod"]>,
+ state?: boolean
+ ) => void;
+ identityAuthMethodData: {
+ identityId: string;
+ name: string;
+ configuredAuthMethods?: IdentityAuthMethod[];
+ authMethod?: IdentityAuthMethod;
+ };
+};
+
+export const IdentityGcpAuthForm = ({
+ handlePopUpOpen,
+ handlePopUpToggle,
+ identityAuthMethodData
+}: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { subscription } = useSubscription();
+
+ const { mutateAsync: addMutateAsync } = useAddIdentityGcpAuth();
+ const { mutateAsync: updateMutateAsync } = useUpdateIdentityGcpAuth();
+
+ const isUpdate = identityAuthMethodData?.configuredAuthMethods?.includes(
+ identityAuthMethodData.authMethod! || ""
+ );
+ const { data } = useGetIdentityGcpAuth(identityAuthMethodData?.identityId ?? "", {
+ enabled: isUpdate
+ });
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting },
+ watch
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ type: "gce",
+ allowedServiceAccounts: "",
+ allowedProjects: "",
+ allowedZones: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ }
+ });
+
+ const watchedType = watch("type");
+
+ const {
+ fields: accessTokenTrustedIpsFields,
+ append: appendAccessTokenTrustedIp,
+ remove: removeAccessTokenTrustedIp
+ } = useFieldArray({ control, name: "accessTokenTrustedIps" });
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ type: data.type || "gce",
+ allowedServiceAccounts: data.allowedServiceAccounts,
+ allowedProjects: data.allowedProjects,
+ allowedZones: data.allowedZones,
+ accessTokenTTL: String(data.accessTokenTTL),
+ accessTokenMaxTTL: String(data.accessTokenMaxTTL),
+ accessTokenNumUsesLimit: String(data.accessTokenNumUsesLimit),
+ accessTokenTrustedIps: data.accessTokenTrustedIps.map(
+ ({ ipAddress, prefix }: IdentityTrustedIp) => {
+ return {
+ ipAddress: `${ipAddress}${prefix !== undefined ? `/${prefix}` : ""}`
+ };
+ }
+ )
+ });
+ } else {
+ reset({
+ type: "gce",
+ allowedServiceAccounts: "",
+ allowedProjects: "",
+ allowedZones: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ });
+ }
+ }, [data]);
+
+ const onFormSubmit = async ({
+ type,
+ allowedServiceAccounts,
+ allowedProjects,
+ allowedZones,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps
+ }: FormData) => {
+ try {
+ if (!identityAuthMethodData) return;
+
+ if (data) {
+ await updateMutateAsync({
+ identityId: identityAuthMethodData.identityId,
+ organizationId: orgId,
+ type,
+ allowedServiceAccounts,
+ allowedProjects,
+ allowedZones,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ } else {
+ await addMutateAsync({
+ identityId: identityAuthMethodData.identityId,
+ organizationId: orgId,
+ type,
+ allowedServiceAccounts: allowedServiceAccounts || "",
+ allowedProjects: allowedProjects || "",
+ allowedZones: allowedZones || "",
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ }
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
+ } catch {
+ createNotification({
+ text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ name="type"
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl label="Type" isError={Boolean(error)} errorText={error?.message}>
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ className="w-full"
+ >
+ <SelectItem value="gce" key="gce">
+ GCP ID Token Auth (Recommended)
+ </SelectItem>
+ <SelectItem value="iam" key="iam">
+ GCP IAM Auth
+ </SelectItem>
+ </Select>
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="allowedServiceAccounts"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Allowed Service Account Emails"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ {...field}
+ type="text"
+ />
+ </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}
+ name="allowedZones"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Allowed Zones" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} placeholder="us-west2-a, us-central1-a, ..." />
+ </FormControl>
+ )}
+ />
+ )}
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenMaxTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="0"
+ name="accessTokenNumUsesLimit"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max Number of Uses"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ </FormControl>
+ )}
+ />
+ {accessTokenTrustedIpsFields.map(({ id }, index) => (
+ <div className="mb-3 flex items-end space-x-2" key={id}>
+ <Controller
+ control={control}
+ name={`accessTokenTrustedIps.${index}.ipAddress`}
+ defaultValue="0.0.0.0/0"
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ label={index === 0 ? "Access Token Trusted IPs" : undefined}
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => {
+ if (subscription?.ipAllowlisting) {
+ field.onChange(e);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ placeholder="123.456.789.0"
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <IconButton
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ removeAccessTokenTrustedIp(index);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ appendAccessTokenTrustedIp({
+ ipAddress: "0.0.0.0/0"
+ });
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add IP Address
+ </Button>
+ </div>
+ <div className="flex justify-between">
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {!isUpdate ? "Create" : "Edit"}
+ </Button>
+
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("identityAuthMethod", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ {isUpdate && (
+ <Button
+ size="sm"
+ colorSchema="danger"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ onClick={() => handlePopUpToggle("revokeAuthMethod", true)}
+ >
+ Remove Auth Method
+ </Button>
+ )}
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm.tsx
new file mode 100644
index 0000000000..e975b272d0
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm.tsx
@@ -0,0 +1,688 @@
+import { useEffect } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faQuestionCircle } from "@fortawesome/free-regular-svg-icons";
+import { faPlus, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FormControl,
+ IconButton,
+ Input,
+ Select,
+ SelectItem,
+ TextArea,
+ Tooltip
+} from "@app/components/v2";
+import { useOrganization, useSubscription } from "@app/context";
+import { useAddIdentityJwtAuth, useUpdateIdentityJwtAuth } from "@app/hooks/api";
+import { IdentityAuthMethod } from "@app/hooks/api/identities";
+import { IdentityJwtConfigurationType } from "@app/hooks/api/identities/enums";
+import { useGetIdentityJwtAuth } from "@app/hooks/api/identities/queries";
+import { IdentityTrustedIp } from "@app/hooks/api/identities/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const commonSchema = z.object({
+ accessTokenTrustedIps: z
+ .array(
+ z.object({
+ ipAddress: z.string().max(50)
+ })
+ )
+ .min(1),
+ accessTokenTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token TTL cannot be greater than 315360000"
+ }),
+ accessTokenMaxTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token Max TTL cannot be greater than 315360000"
+ }),
+ accessTokenNumUsesLimit: z.string(),
+ boundIssuer: z.string().trim().default(""),
+ boundAudiences: z.string().optional().default(""),
+ boundClaims: z.array(
+ z.object({
+ key: z.string(),
+ value: z.string()
+ })
+ ),
+ boundSubject: z.string().optional().default("")
+});
+
+const schema = z.discriminatedUnion("configurationType", [
+ z
+ .object({
+ configurationType: z.literal(IdentityJwtConfigurationType.JWKS),
+ jwksUrl: z.string().trim().url(),
+ jwksCaCert: z.string().trim().default(""),
+ publicKeys: z
+ .object({
+ value: z.string()
+ })
+ .array()
+ .optional()
+ })
+ .merge(commonSchema),
+ z
+ .object({
+ configurationType: z.literal(IdentityJwtConfigurationType.STATIC),
+ jwksUrl: z.string().trim().optional(),
+ jwksCaCert: z.string().trim().optional().default(""),
+ publicKeys: z
+ .object({
+ value: z.string().min(1)
+ })
+ .array()
+ .min(1)
+ })
+ .merge(commonSchema)
+]);
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["identityAuthMethod", "revokeAuthMethod"]>,
+ state?: boolean
+ ) => void;
+ identityAuthMethodData: {
+ identityId: string;
+ name: string;
+ configuredAuthMethods?: IdentityAuthMethod[];
+ authMethod?: IdentityAuthMethod;
+ };
+};
+
+export const IdentityJwtAuthForm = ({
+ handlePopUpOpen,
+ handlePopUpToggle,
+ identityAuthMethodData
+}: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { subscription } = useSubscription();
+
+ const { mutateAsync: addMutateAsync } = useAddIdentityJwtAuth();
+ const { mutateAsync: updateMutateAsync } = useUpdateIdentityJwtAuth();
+
+ const isUpdate = identityAuthMethodData?.configuredAuthMethods?.includes(
+ identityAuthMethodData.authMethod! || ""
+ );
+ const { data } = useGetIdentityJwtAuth(identityAuthMethodData?.identityId ?? "", {
+ enabled: isUpdate
+ });
+
+ const {
+ watch,
+ control,
+ handleSubmit,
+ reset,
+ setValue,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
+ configurationType: IdentityJwtConfigurationType.JWKS
+ }
+ });
+
+ const selectedConfigurationType = watch("configurationType") as IdentityJwtConfigurationType;
+
+ const {
+ fields: publicKeyFields,
+ append: appendPublicKeyFields,
+ remove: removePublicKeyFields
+ } = useFieldArray({
+ control,
+ name: "publicKeys"
+ });
+
+ const {
+ fields: boundClaimsFields,
+ append: appendBoundClaimField,
+ remove: removeBoundClaimField
+ } = useFieldArray({
+ control,
+ name: "boundClaims"
+ });
+
+ const {
+ fields: accessTokenTrustedIpsFields,
+ append: appendAccessTokenTrustedIp,
+ remove: removeAccessTokenTrustedIp
+ } = useFieldArray({ control, name: "accessTokenTrustedIps" });
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ configurationType: data.configurationType,
+ jwksUrl: data.jwksUrl,
+ jwksCaCert: data.jwksCaCert,
+ publicKeys: data.publicKeys.map((pk) => ({
+ value: pk
+ })),
+ boundIssuer: data.boundIssuer,
+ boundAudiences: data.boundAudiences,
+ boundClaims: Object.entries(data.boundClaims).map(([key, value]) => ({
+ key,
+ value
+ })),
+ boundSubject: data.boundSubject,
+ accessTokenTTL: String(data.accessTokenTTL),
+ accessTokenMaxTTL: String(data.accessTokenMaxTTL),
+ accessTokenNumUsesLimit: String(data.accessTokenNumUsesLimit),
+ accessTokenTrustedIps: data.accessTokenTrustedIps.map(
+ ({ ipAddress, prefix }: IdentityTrustedIp) => {
+ return {
+ ipAddress: `${ipAddress}${prefix !== undefined ? `/${prefix}` : ""}`
+ };
+ }
+ )
+ });
+ } else {
+ reset({
+ configurationType: IdentityJwtConfigurationType.JWKS,
+ jwksUrl: "",
+ jwksCaCert: "",
+ boundIssuer: "",
+ boundAudiences: "",
+ boundClaims: [],
+ boundSubject: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ });
+ }
+ }, [data]);
+
+ const onFormSubmit = async ({
+ accessTokenTrustedIps,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ configurationType,
+ jwksUrl,
+ jwksCaCert,
+ publicKeys,
+ boundIssuer,
+ boundAudiences,
+ boundClaims,
+ boundSubject
+ }: FormData) => {
+ try {
+ if (!identityAuthMethodData) {
+ return;
+ }
+
+ if (data) {
+ await updateMutateAsync({
+ identityId: identityAuthMethodData.identityId,
+ organizationId: orgId,
+ configurationType,
+ jwksUrl,
+ jwksCaCert,
+ publicKeys: publicKeys?.map((field) => field.value).filter(Boolean),
+ boundIssuer,
+ boundAudiences,
+ boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
+ boundSubject,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ } else {
+ await addMutateAsync({
+ identityId: identityAuthMethodData.identityId,
+ configurationType,
+ jwksUrl,
+ jwksCaCert,
+ publicKeys: publicKeys?.map((field) => field.value).filter(Boolean),
+ boundIssuer,
+ boundAudiences,
+ boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
+ boundSubject,
+ organizationId: orgId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ }
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
+ } catch {
+ createNotification({
+ text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ name="configurationType"
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl
+ label="Configuration Type"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => {
+ if (e === IdentityJwtConfigurationType.JWKS) {
+ setValue("publicKeys", []);
+ } else {
+ setValue("publicKeys", [
+ {
+ value: ""
+ }
+ ]);
+ setValue("jwksUrl", "");
+ setValue("jwksCaCert", "");
+ }
+ onChange(e);
+ }}
+ className="w-full"
+ >
+ <SelectItem value={IdentityJwtConfigurationType.JWKS} key="jwks">
+ JWKS
+ </SelectItem>
+ <SelectItem value={IdentityJwtConfigurationType.STATIC} key="static">
+ Static
+ </SelectItem>
+ </Select>
+ </FormControl>
+ )}
+ />
+ {selectedConfigurationType === IdentityJwtConfigurationType.JWKS && (
+ <>
+ <Controller
+ control={control}
+ name="jwksUrl"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isRequired
+ label="JWKS URL"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} type="text" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="jwksCaCert"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="JWKS CA Certificate"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <TextArea {...field} placeholder="-----BEGIN CERTIFICATE----- ..." />
+ </FormControl>
+ )}
+ />
+ </>
+ )}
+
+ {selectedConfigurationType === IdentityJwtConfigurationType.STATIC && (
+ <>
+ {publicKeyFields.map(({ id }, index) => (
+ <div key={id} className="flex gap-2">
+ <Controller
+ control={control}
+ name={`publicKeys.${index}.value`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ className="flex-grow"
+ label={`Public Key ${index + 1}`}
+ errorText={error?.message}
+ isError={Boolean(error)}
+ icon={
+ <Tooltip
+ className="text-center"
+ content={<span>This field only accepts PEM-formatted public keys</span>}
+ >
+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" />
+ </Tooltip>
+ }
+ >
+ <TextArea {...field} placeholder="-----BEGIN PUBLIC KEY----- ..." />
+ </FormControl>
+ )}
+ />
+ <IconButton
+ onClick={() => {
+ if (publicKeyFields.length === 1) {
+ createNotification({
+ type: "error",
+ text: "A public key is required for static configurations"
+ });
+ return;
+ }
+
+ removePublicKeyFields(index);
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() =>
+ appendPublicKeyFields({
+ value: ""
+ })
+ }
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add Public Key
+ </Button>
+ </div>
+ </>
+ )}
+
+ <Controller
+ control={control}
+ name="boundIssuer"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Issuer" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} type="text" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="boundSubject"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Subject"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ icon={
+ <Tooltip
+ className="text-center"
+ content={<span>This field supports glob patterns</span>}
+ >
+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" />
+ </Tooltip>
+ }
+ >
+ <Input {...field} type="text" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="boundAudiences"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Audiences"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ icon={
+ <Tooltip
+ className="text-center"
+ content={<span>This field supports glob patterns</span>}
+ >
+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" />
+ </Tooltip>
+ }
+ >
+ <Input {...field} type="text" placeholder="service1, service2" />
+ </FormControl>
+ )}
+ />
+ {boundClaimsFields.map(({ id }, index) => (
+ <div className="mb-3 flex items-end space-x-2" key={id}>
+ <Controller
+ control={control}
+ name={`boundClaims.${index}.key`}
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ label={index === 0 ? "Claims" : undefined}
+ icon={
+ index === 0 ? (
+ <Tooltip
+ className="text-center"
+ content={<span>This field supports glob patterns</span>}
+ >
+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" />
+ </Tooltip>
+ ) : undefined
+ }
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => field.onChange(e)}
+ placeholder="property"
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <Controller
+ control={control}
+ name={`boundClaims.${index}.value`}
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => field.onChange(e)}
+ placeholder="value1, value2"
+ />
+ </FormControl>
+ );
+ }}
+ />
+
+ <IconButton
+ onClick={() => removeBoundClaimField(index)}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() =>
+ appendBoundClaimField({
+ key: "",
+ value: ""
+ })
+ }
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add Claims
+ </Button>
+ </div>
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenMaxTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="0"
+ name="accessTokenNumUsesLimit"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max Number of Uses"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ </FormControl>
+ )}
+ />
+ {accessTokenTrustedIpsFields.map(({ id }, index) => (
+ <div className="mb-3 flex items-end space-x-2" key={id}>
+ <Controller
+ control={control}
+ name={`accessTokenTrustedIps.${index}.ipAddress`}
+ defaultValue="0.0.0.0/0"
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ label={index === 0 ? "Access Token Trusted IPs" : undefined}
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => {
+ if (subscription?.ipAllowlisting) {
+ field.onChange(e);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ placeholder="123.456.789.0"
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <IconButton
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ removeAccessTokenTrustedIp(index);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ appendAccessTokenTrustedIp({
+ ipAddress: "0.0.0.0/0"
+ });
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add IP Address
+ </Button>
+ </div>
+ <div className="flex justify-between">
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {isUpdate ? "Update" : "Create"}
+ </Button>
+
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("identityAuthMethod", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ {isUpdate && (
+ <Button
+ size="sm"
+ colorSchema="danger"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ onClick={() => handlePopUpToggle("revokeAuthMethod", true)}
+ >
+ Remove Auth Method
+ </Button>
+ )}
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx
new file mode 100644
index 0000000000..8234d5ea77
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx
@@ -0,0 +1,446 @@
+import { useEffect } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, IconButton, Input, TextArea } from "@app/components/v2";
+import { useOrganization, useSubscription } from "@app/context";
+import {
+ useAddIdentityKubernetesAuth,
+ useGetIdentityKubernetesAuth,
+ useUpdateIdentityKubernetesAuth
+} from "@app/hooks/api";
+import { IdentityAuthMethod } from "@app/hooks/api/identities";
+import { IdentityTrustedIp } from "@app/hooks/api/identities/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z
+ .object({
+ kubernetesHost: z.string().min(1),
+ tokenReviewerJwt: z.string().min(1),
+ allowedNames: z.string(),
+ allowedNamespaces: z.string(),
+ allowedAudience: z.string(),
+ caCert: z.string(),
+ accessTokenTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token TTL cannot be greater than 315360000"
+ }),
+ accessTokenMaxTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token Max TTL cannot be greater than 315360000"
+ }),
+ accessTokenNumUsesLimit: z.string(),
+ accessTokenTrustedIps: z
+ .array(
+ z.object({
+ ipAddress: z.string().max(50)
+ })
+ )
+ .min(1)
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["identityAuthMethod", "revokeAuthMethod"]>,
+ state?: boolean
+ ) => void;
+ identityAuthMethodData: {
+ identityId: string;
+ name: string;
+ configuredAuthMethods?: IdentityAuthMethod[];
+ authMethod?: IdentityAuthMethod;
+ };
+};
+
+export const IdentityKubernetesAuthForm = ({
+ handlePopUpOpen,
+ handlePopUpToggle,
+ identityAuthMethodData
+}: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { subscription } = useSubscription();
+
+ const { mutateAsync: addMutateAsync } = useAddIdentityKubernetesAuth();
+ const { mutateAsync: updateMutateAsync } = useUpdateIdentityKubernetesAuth();
+
+ const isUpdate = identityAuthMethodData?.configuredAuthMethods?.includes(
+ identityAuthMethodData.authMethod! || ""
+ );
+ const { data } = useGetIdentityKubernetesAuth(identityAuthMethodData?.identityId ?? "", {
+ enabled: isUpdate
+ });
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ kubernetesHost: "",
+ tokenReviewerJwt: "",
+ allowedNames: "",
+ allowedNamespaces: "",
+ allowedAudience: "",
+ caCert: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ }
+ });
+
+ const {
+ fields: accessTokenTrustedIpsFields,
+ append: appendAccessTokenTrustedIp,
+ remove: removeAccessTokenTrustedIp
+ } = useFieldArray({ control, name: "accessTokenTrustedIps" });
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ kubernetesHost: data.kubernetesHost,
+ tokenReviewerJwt: data.tokenReviewerJwt,
+ allowedNames: data.allowedNames,
+ allowedNamespaces: data.allowedNamespaces,
+ allowedAudience: data.allowedAudience,
+ caCert: data.caCert,
+ accessTokenTTL: String(data.accessTokenTTL),
+ accessTokenMaxTTL: String(data.accessTokenMaxTTL),
+ accessTokenNumUsesLimit: String(data.accessTokenNumUsesLimit),
+ accessTokenTrustedIps: data.accessTokenTrustedIps.map(
+ ({ ipAddress, prefix }: IdentityTrustedIp) => {
+ return {
+ ipAddress: `${ipAddress}${prefix !== undefined ? `/${prefix}` : ""}`
+ };
+ }
+ )
+ });
+ } else {
+ reset({
+ kubernetesHost: "",
+ tokenReviewerJwt: "",
+ allowedNames: "",
+ allowedNamespaces: "",
+ allowedAudience: "",
+ caCert: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ });
+ }
+ }, [data]);
+
+ const onFormSubmit = async ({
+ kubernetesHost,
+ tokenReviewerJwt,
+ allowedNames,
+ allowedNamespaces,
+ allowedAudience,
+ caCert,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps
+ }: FormData) => {
+ try {
+ if (!identityAuthMethodData) return;
+
+ if (data) {
+ await updateMutateAsync({
+ organizationId: orgId,
+ kubernetesHost,
+ tokenReviewerJwt,
+ allowedNames,
+ allowedNamespaces,
+ allowedAudience,
+ caCert,
+ identityId: identityAuthMethodData.identityId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ } else {
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId: identityAuthMethodData.identityId,
+ kubernetesHost: kubernetesHost || "",
+ tokenReviewerJwt,
+ allowedNames: allowedNames || "",
+ allowedNamespaces: allowedNamespaces || "",
+ allowedAudience: allowedAudience || "",
+ caCert: caCert || "",
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ }
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
+ } catch {
+ createNotification({
+ text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="kubernetesHost"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Kubernetes Host / Base Kubernetes API URL "
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="The host string, host:port pair, or URL to the base of the Kubernetes API server. This can usually be obtained by running 'kubectl cluster-info'"
+ isRequired
+ >
+ <Input {...field} placeholder="https://my-example-k8s-api-host.com" type="text" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="tokenReviewerJwt"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Token Reviewer JWT"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="A long-lived service account JWT token for Infisical to access the TokenReview API to validate other service account JWT tokens submitted by applications/pods."
+ isRequired
+ >
+ <Input {...field} placeholder="" type="password" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="allowedNames"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Allowed Service Account Names"
+ isError={Boolean(error)}
+ tooltipText="An optional comma-separated list of trusted service account names that are allowed to authenticate with Infisical. Leave empty to allow any service account."
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="service-account-1-name, service-account-1-name" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="allowedNamespaces"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Allowed Namespaces"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="A comma-separated list of trusted namespaces that service accounts must belong to authenticate with Infisical."
+ >
+ <Input {...field} placeholder="namespaceA, namespaceB" type="text" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="allowedAudience"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Allowed Audience"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="An optional audience claim that the service account JWT token must have to authenticate with Infisical. Leave empty to allow any audience claim."
+ >
+ <Input {...field} placeholder="" type="text" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="caCert"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="CA Certificate"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ tooltipText="An optional PEM-encoded CA cert for the Kubernetes API server. This is used by the TLS client for secure communication with the Kubernetes API server."
+ >
+ <TextArea {...field} placeholder="-----BEGIN CERTIFICATE----- ..." />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token TTL (seconds)"
+ tooltipText="The lifetime for an acccess token in seconds. This value will be referenced at renewal time."
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenMaxTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="The maximum lifetime for an access token in seconds. This value will be referenced at renewal time."
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="0"
+ name="accessTokenNumUsesLimit"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max Number of Uses"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="The maximum number of times that an access token can be used; a value of 0 implies infinite number of uses."
+ >
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ </FormControl>
+ )}
+ />
+ {accessTokenTrustedIpsFields.map(({ id }, index) => (
+ <div className="mb-3 flex items-end space-x-2" key={id}>
+ <Controller
+ control={control}
+ name={`accessTokenTrustedIps.${index}.ipAddress`}
+ defaultValue="0.0.0.0/0"
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ label={index === 0 ? "Access Token Trusted IPs" : undefined}
+ isError={Boolean(error)}
+ errorText={error?.message}
+ tooltipText="The IPs or CIDR ranges that access tokens can be used from. By default, each token is given the 0.0.0.0/0, allowing usage from any network address."
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => {
+ if (subscription?.ipAllowlisting) {
+ field.onChange(e);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ placeholder="123.456.789.0"
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <IconButton
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ removeAccessTokenTrustedIp(index);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ appendAccessTokenTrustedIp({
+ ipAddress: "0.0.0.0/0"
+ });
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add IP Address
+ </Button>
+ </div>
+ <div className="flex justify-between">
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {isUpdate ? "Update" : "Create"}
+ </Button>
+
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("identityAuthMethod", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ {isUpdate && (
+ <Button
+ size="sm"
+ colorSchema="danger"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ onClick={() => handlePopUpToggle("revokeAuthMethod", true)}
+ >
+ Remove Auth Method
+ </Button>
+ )}
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx
new file mode 100644
index 0000000000..1ae4ff0bfe
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx
@@ -0,0 +1,301 @@
+import { useEffect } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { useNavigate } from "@tanstack/react-router";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FilterableSelect,
+ FormControl,
+ FormLabel,
+ IconButton,
+ Input,
+ Modal,
+ ModalContent
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { findOrgMembershipRole } from "@app/helpers/roles";
+import { useCreateIdentity, useGetOrgRoles, useUpdateIdentity } from "@app/hooks/api";
+import { useAddIdentityUniversalAuth } from "@app/hooks/api/identities";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z
+ .object({
+ name: z.string().min(1, "Required"),
+ role: z.object({ slug: z.string(), name: z.string() }),
+ metadata: z
+ .object({
+ key: z.string().trim().min(1),
+ value: z.string().trim().min(1)
+ })
+ .array()
+ .default([])
+ .optional()
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ popUp: UsePopUpState<["identity"]>;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["identity"]>, state?: boolean) => void;
+};
+
+export const IdentityModal = ({ popUp, handlePopUpToggle }: Props) => {
+ const navigate = useNavigate();
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+
+ const { data: roles } = useGetOrgRoles(orgId);
+
+ const { mutateAsync: createMutateAsync } = useCreateIdentity();
+ const { mutateAsync: updateMutateAsync } = useUpdateIdentity();
+ const { mutateAsync: addMutateAsync } = useAddIdentityUniversalAuth();
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ name: ""
+ }
+ });
+
+ const metadataFormFields = useFieldArray({
+ control,
+ name: "metadata"
+ });
+
+ useEffect(() => {
+ const identity = popUp?.identity?.data as {
+ identityId: string;
+ name: string;
+ role: string;
+ metadata?: { key: string; value: string }[];
+ customRole: {
+ name: string;
+ slug: string;
+ };
+ };
+
+ if (!roles?.length) return;
+
+ if (identity) {
+ reset({
+ name: identity.name,
+ role: identity.customRole ?? findOrgMembershipRole(roles, identity.role),
+ metadata: identity.metadata
+ });
+ } else {
+ reset({
+ name: "",
+ role: findOrgMembershipRole(roles, currentOrg!.defaultMembershipRole)
+ });
+ }
+ }, [popUp?.identity?.data, roles]);
+
+ const onFormSubmit = async ({ name, role, metadata }: FormData) => {
+ try {
+ const identity = popUp?.identity?.data as {
+ identityId: string;
+ name: string;
+ role: string;
+ };
+
+ if (identity) {
+ // update
+
+ await updateMutateAsync({
+ identityId: identity.identityId,
+ name,
+ role: role.slug || undefined,
+ organizationId: orgId,
+ metadata
+ });
+
+ handlePopUpToggle("identity", false);
+ } else {
+ // create
+
+ const { id: createdId } = await createMutateAsync({
+ name,
+ role: role.slug || undefined,
+ organizationId: orgId,
+ metadata
+ });
+
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId: createdId,
+ clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
+ accessTokenTTL: 2592000,
+ accessTokenMaxTTL: 2592000,
+ accessTokenNumUsesLimit: 0
+ });
+
+ handlePopUpToggle("identity", false);
+ navigate({
+ to: "/organization/$organizationId/identities/$identityId",
+ params: {
+ organizationId: currentOrg.id,
+ identityId: createdId
+ }
+ });
+ }
+
+ createNotification({
+ text: `Successfully ${popUp?.identity?.data ? "updated" : "created"} identity`,
+ type: "success"
+ });
+
+ reset();
+ } catch (err) {
+ console.error(err);
+ const error = err as any;
+ const text =
+ error?.response?.data?.message ??
+ `Failed to ${popUp?.identity?.data ? "update" : "create"} identity`;
+
+ createNotification({
+ text,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.identity?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("identity", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent
+ bodyClassName="overflow-visible"
+ title={`${popUp?.identity?.data ? "Update" : "Create"} Identity`}
+ >
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Name" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} placeholder="Machine 1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="role"
+ render={({ field: { onChange, value }, fieldState: { error } }) => (
+ <FormControl
+ label={`${popUp?.identity?.data ? "Update" : ""} Role`}
+ errorText={error?.message}
+ isError={Boolean(error)}
+ className="mt-4"
+ >
+ <FilterableSelect
+ placeholder="Select role..."
+ options={roles}
+ onChange={onChange}
+ value={value}
+ getOptionValue={(option) => option.slug}
+ getOptionLabel={(option) => option.name}
+ />
+ </FormControl>
+ )}
+ />
+ <div>
+ <FormLabel label="Metadata" />
+ </div>
+ <div className="mb-3 flex flex-col space-y-2">
+ {metadataFormFields.fields.map(({ id: metadataFieldId }, i) => (
+ <div key={metadataFieldId} className="flex items-end space-x-2">
+ <div className="flex-grow">
+ {i === 0 && <span className="text-xs text-mineshaft-400">Key</span>}
+ <Controller
+ control={control}
+ name={`metadata.${i}.key`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="flex-grow">
+ {i === 0 && (
+ <FormLabel label="Value" className="text-xs text-mineshaft-400" isOptional />
+ )}
+ <Controller
+ control={control}
+ name={`metadata.${i}.value`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ </div>
+ <IconButton
+ ariaLabel="delete key"
+ className="bottom-0.5 h-9"
+ variant="outline_bg"
+ onClick={() => metadataFormFields.remove(i)}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="mt-2 flex justify-end">
+ <Button
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ variant="outline_bg"
+ onClick={() => metadataFormFields.append({ key: "", value: "" })}
+ >
+ Add Key
+ </Button>
+ </div>
+ </div>
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {popUp?.identity?.data ? "Update" : "Create"}
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("identity", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm.tsx
new file mode 100644
index 0000000000..01d1d0b449
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm.tsx
@@ -0,0 +1,527 @@
+import { useEffect } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faQuestionCircle } from "@fortawesome/free-regular-svg-icons";
+import { faPlus, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, IconButton, Input, TextArea, Tooltip } from "@app/components/v2";
+import { useOrganization, useSubscription } from "@app/context";
+import { useAddIdentityOidcAuth, useUpdateIdentityOidcAuth } from "@app/hooks/api";
+import { IdentityAuthMethod } from "@app/hooks/api/identities";
+import { useGetIdentityOidcAuth } from "@app/hooks/api/identities/queries";
+import { IdentityTrustedIp } from "@app/hooks/api/identities/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z.object({
+ accessTokenTrustedIps: z
+ .array(
+ z.object({
+ ipAddress: z.string().max(50)
+ })
+ )
+ .min(1),
+ accessTokenTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token TTL cannot be greater than 315360000"
+ }),
+ accessTokenMaxTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token Max TTL cannot be greater than 315360000"
+ }),
+ accessTokenNumUsesLimit: z.string(),
+ oidcDiscoveryUrl: z.string().url().min(1),
+ caCert: z.string().trim().default(""),
+ boundIssuer: z.string().min(1),
+ boundAudiences: z.string().optional().default(""),
+ boundClaims: z.array(
+ z.object({
+ key: z.string(),
+ value: z.string()
+ })
+ ),
+ boundSubject: z.string().optional().default("")
+});
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["identityAuthMethod", "revokeAuthMethod"]>,
+ state?: boolean
+ ) => void;
+ identityAuthMethodData: {
+ identityId: string;
+ name: string;
+ configuredAuthMethods?: IdentityAuthMethod[];
+ authMethod?: IdentityAuthMethod;
+ };
+};
+
+export const IdentityOidcAuthForm = ({
+ handlePopUpOpen,
+ handlePopUpToggle,
+ identityAuthMethodData
+}: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { subscription } = useSubscription();
+
+ const { mutateAsync: addMutateAsync } = useAddIdentityOidcAuth();
+ const { mutateAsync: updateMutateAsync } = useUpdateIdentityOidcAuth();
+
+ const isUpdate = identityAuthMethodData?.configuredAuthMethods?.includes(
+ identityAuthMethodData.authMethod! || ""
+ );
+ const { data } = useGetIdentityOidcAuth(identityAuthMethodData?.identityId ?? "", {
+ enabled: isUpdate
+ });
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ }
+ });
+
+ const {
+ fields: boundClaimsFields,
+ append: appendBoundClaimField,
+ remove: removeBoundClaimField
+ } = useFieldArray({
+ control,
+ name: "boundClaims"
+ });
+
+ const {
+ fields: accessTokenTrustedIpsFields,
+ append: appendAccessTokenTrustedIp,
+ remove: removeAccessTokenTrustedIp
+ } = useFieldArray({ control, name: "accessTokenTrustedIps" });
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ oidcDiscoveryUrl: data.oidcDiscoveryUrl,
+ caCert: data.caCert,
+ boundIssuer: data.boundIssuer,
+ boundAudiences: data.boundAudiences,
+ boundClaims: Object.entries(data.boundClaims).map(([key, value]) => ({
+ key,
+ value
+ })),
+ boundSubject: data.boundSubject,
+ accessTokenTTL: String(data.accessTokenTTL),
+ accessTokenMaxTTL: String(data.accessTokenMaxTTL),
+ accessTokenNumUsesLimit: String(data.accessTokenNumUsesLimit),
+ accessTokenTrustedIps: data.accessTokenTrustedIps.map(
+ ({ ipAddress, prefix }: IdentityTrustedIp) => {
+ return {
+ ipAddress: `${ipAddress}${prefix !== undefined ? `/${prefix}` : ""}`
+ };
+ }
+ )
+ });
+ } else {
+ reset({
+ oidcDiscoveryUrl: "",
+ caCert: "",
+ boundIssuer: "",
+ boundAudiences: "",
+ boundClaims: [],
+ boundSubject: "",
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ });
+ }
+ }, [data]);
+
+ const onFormSubmit = async ({
+ accessTokenTrustedIps,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ oidcDiscoveryUrl,
+ caCert,
+ boundIssuer,
+ boundAudiences,
+ boundClaims,
+ boundSubject
+ }: FormData) => {
+ try {
+ if (!identityAuthMethodData) {
+ return;
+ }
+
+ if (data) {
+ await updateMutateAsync({
+ identityId: identityAuthMethodData.identityId,
+ organizationId: orgId,
+ oidcDiscoveryUrl,
+ caCert,
+ boundIssuer,
+ boundAudiences,
+ boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
+ boundSubject,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ } else {
+ await addMutateAsync({
+ identityId: identityAuthMethodData.identityId,
+ oidcDiscoveryUrl,
+ caCert,
+ boundIssuer,
+ boundAudiences,
+ boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
+ boundSubject,
+ organizationId: orgId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ }
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
+ } catch {
+ createNotification({
+ text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ name="oidcDiscoveryUrl"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isRequired
+ label="OIDC Discovery URL"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ {...field}
+ placeholder="https://token.actions.githubusercontent.com"
+ type="text"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="boundIssuer"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isRequired
+ label="Issuer"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ {...field}
+ type="text"
+ placeholder="https://token.actions.githubusercontent.com"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="caCert"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="CA Certificate" errorText={error?.message} isError={Boolean(error)}>
+ <TextArea {...field} placeholder="-----BEGIN CERTIFICATE----- ..." />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="boundSubject"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Subject"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ icon={
+ <Tooltip
+ className="text-center"
+ content={<span>This field supports glob patterns</span>}
+ >
+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" />
+ </Tooltip>
+ }
+ >
+ <Input {...field} type="text" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="boundAudiences"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Audiences"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ icon={
+ <Tooltip
+ className="text-center"
+ content={<span>This field supports glob patterns</span>}
+ >
+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" />
+ </Tooltip>
+ }
+ >
+ <Input {...field} type="text" placeholder="service1, service2" />
+ </FormControl>
+ )}
+ />
+ {boundClaimsFields.map(({ id }, index) => (
+ <div className="mb-3 flex items-end space-x-2" key={id}>
+ <Controller
+ control={control}
+ name={`boundClaims.${index}.key`}
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ label={index === 0 ? "Claims" : undefined}
+ icon={
+ index === 0 ? (
+ <Tooltip
+ className="text-center"
+ content={<span>This field supports glob patterns</span>}
+ >
+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" />
+ </Tooltip>
+ ) : undefined
+ }
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => field.onChange(e)}
+ placeholder="property"
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <Controller
+ control={control}
+ name={`boundClaims.${index}.value`}
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => field.onChange(e)}
+ placeholder="value1, value2"
+ />
+ </FormControl>
+ );
+ }}
+ />
+
+ <IconButton
+ onClick={() => removeBoundClaimField(index)}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() =>
+ appendBoundClaimField({
+ key: "",
+ value: ""
+ })
+ }
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add Claims
+ </Button>
+ </div>
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenMaxTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="0"
+ name="accessTokenNumUsesLimit"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max Number of Uses"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ </FormControl>
+ )}
+ />
+ {accessTokenTrustedIpsFields.map(({ id }, index) => (
+ <div className="mb-3 flex items-end space-x-2" key={id}>
+ <Controller
+ control={control}
+ name={`accessTokenTrustedIps.${index}.ipAddress`}
+ defaultValue="0.0.0.0/0"
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ label={index === 0 ? "Access Token Trusted IPs" : undefined}
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => {
+ if (subscription?.ipAllowlisting) {
+ field.onChange(e);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ placeholder="123.456.789.0"
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <IconButton
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ removeAccessTokenTrustedIp(index);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ appendAccessTokenTrustedIp({
+ ipAddress: "0.0.0.0/0"
+ });
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add IP Address
+ </Button>
+ </div>
+ <div className="flex justify-between">
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {isUpdate ? "Update" : "Create"}
+ </Button>
+
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("identityAuthMethod", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ {isUpdate && (
+ <Button
+ size="sm"
+ colorSchema="danger"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ onClick={() => handlePopUpToggle("revokeAuthMethod", true)}
+ >
+ Remove Auth Method
+ </Button>
+ )}
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx
new file mode 100644
index 0000000000..63ca7d7170
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx
@@ -0,0 +1,146 @@
+import { faArrowUpRightFromSquare, faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, DeleteActionModal, UpgradePlanModal } from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { withPermission } from "@app/hoc";
+import { useDeleteIdentity } from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+// import { IdentityAuthMethodModal } from "./IdentityAuthMethodModal";
+import { IdentityModal } from "./IdentityModal";
+import { IdentityTable } from "./IdentityTable";
+import { IdentityTokenAuthTokenModal } from "./IdentityTokenAuthTokenModal";
+// import { IdentityUniversalAuthClientSecretModal } from "./IdentityUniversalAuthClientSecretModal";
+
+export const IdentitySection = withPermission(
+ () => {
+ const { subscription } = useSubscription();
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+
+ const { mutateAsync: deleteMutateAsync } = useDeleteIdentity();
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "identity",
+ "identityAuthMethod",
+ "deleteIdentity",
+ "universalAuthClientSecret",
+ "deleteUniversalAuthClientSecret",
+ "upgradePlan",
+ "tokenAuthToken"
+ ] as const);
+
+ const isMoreIdentitiesAllowed = subscription?.identityLimit
+ ? subscription.identitiesUsed < subscription.identityLimit
+ : true;
+
+ const isEnterprise = subscription?.slug === "enterprise";
+
+ const onDeleteIdentitySubmit = async (identityId: string) => {
+ try {
+ await deleteMutateAsync({
+ identityId,
+ organizationId: orgId
+ });
+
+ createNotification({
+ text: "Successfully deleted identity",
+ type: "success"
+ });
+
+ handlePopUpClose("deleteIdentity");
+ } catch (err) {
+ console.error(err);
+ const error = err as any;
+ const text = error?.response?.data?.message ?? "Failed to delete identity";
+
+ createNotification({
+ text,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="mb-4 flex justify-between">
+ <p className="text-xl font-semibold text-mineshaft-100">Identities</p>
+ <div className="flex w-full justify-end pr-4">
+ <a
+ target="_blank"
+ rel="noopener noreferrer"
+ href="https://infisical.com/docs/documentation/platform/identities/overview"
+ className="w-max cursor-pointer rounded-md border border-mineshaft-500 bg-mineshaft-600 px-4 py-2 text-mineshaft-200 duration-200 hover:border-primary/40 hover:bg-primary/10 hover:text-white"
+ >
+ Documentation{" "}
+ <FontAwesomeIcon
+ icon={faArrowUpRightFromSquare}
+ className="mb-[0.06rem] ml-1 text-xs"
+ />
+ </a>
+ </div>
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Identity}>
+ {(isAllowed) => (
+ <Button
+ colorSchema="primary"
+ type="submit"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ onClick={() => {
+ if (!isMoreIdentitiesAllowed && !isEnterprise) {
+ handlePopUpOpen("upgradePlan", {
+ description: "You can add more identities if you upgrade your Infisical plan."
+ });
+ return;
+ }
+ handlePopUpOpen("identity");
+ }}
+ isDisabled={!isAllowed}
+ >
+ Create Identity
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <IdentityTable handlePopUpOpen={handlePopUpOpen} />
+ <IdentityModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
+ {/* <IdentityAuthMethodModal
+ popUp={popUp}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ /> */}
+ {/* <IdentityUniversalAuthClientSecretModal
+ popUp={popUp}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ /> */}
+ <IdentityTokenAuthTokenModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
+ <DeleteActionModal
+ isOpen={popUp.deleteIdentity.isOpen}
+ title={`Are you sure want to delete ${
+ (popUp?.deleteIdentity?.data as { name: string })?.name || ""
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle("deleteIdentity", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() =>
+ onDeleteIdentitySubmit(
+ (popUp?.deleteIdentity?.data as { identityId: string })?.identityId
+ )
+ }
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text={(popUp.upgradePlan?.data as { description: string })?.description}
+ />
+ </div>
+ );
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Identity }
+);
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
new file mode 100644
index 0000000000..87f004f0c3
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
@@ -0,0 +1,319 @@
+import {
+ faArrowDown,
+ faArrowUp,
+ faEllipsis,
+ faMagnifyingGlass,
+ faServer
+} from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { twMerge } from "tailwind-merge";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ EmptyState,
+ IconButton,
+ Input,
+ Pagination,
+ Select,
+ SelectItem,
+ Spinner,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { usePagination, useResetPageHelper } from "@app/hooks";
+import { useGetIdentityMembershipOrgs, useGetOrgRoles, useUpdateIdentity } from "@app/hooks/api";
+import { OrderByDirection } from "@app/hooks/api/generic/types";
+import { OrgIdentityOrderBy } from "@app/hooks/api/organization/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+import { useNavigate } from "@tanstack/react-router";
+
+type Props = {
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["deleteIdentity"]>,
+ data?: {
+ identityId: string;
+ name: string;
+ }
+ ) => void;
+};
+
+export const IdentityTable = ({ handlePopUpOpen }: Props) => {
+ const navigate = useNavigate();
+ const { currentOrg } = useOrganization();
+
+ const {
+ offset,
+ limit,
+ orderBy,
+ setOrderBy,
+ orderDirection,
+ setOrderDirection,
+ search,
+ debouncedSearch,
+ setPage,
+ setSearch,
+ perPage,
+ page,
+ setPerPage
+ } = usePagination<OrgIdentityOrderBy>(OrgIdentityOrderBy.Name);
+
+ const organizationId = currentOrg?.id || "";
+
+ const { mutateAsync: updateMutateAsync } = useUpdateIdentity();
+
+ const { data, isLoading, isFetching } = useGetIdentityMembershipOrgs(
+ {
+ organizationId,
+ offset,
+ limit,
+ orderDirection,
+ orderBy,
+ search: debouncedSearch
+ },
+ { keepPreviousData: true }
+ );
+
+ const { totalCount = 0 } = data ?? {};
+ useResetPageHelper({
+ totalCount,
+ offset,
+ setPage
+ });
+
+ const { data: roles } = useGetOrgRoles(organizationId);
+
+ const handleSort = (column: OrgIdentityOrderBy) => {
+ if (column === orderBy) {
+ setOrderDirection((prev) =>
+ prev === OrderByDirection.ASC ? OrderByDirection.DESC : OrderByDirection.ASC
+ );
+ return;
+ }
+
+ setOrderBy(column);
+ setOrderDirection(OrderByDirection.ASC);
+ };
+
+ const handleChangeRole = async ({ identityId, role }: { identityId: string; role: string }) => {
+ try {
+ await updateMutateAsync({
+ identityId,
+ role,
+ organizationId
+ });
+
+ createNotification({
+ text: "Successfully updated identity role",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ const error = err as any;
+ const text = error?.response?.data?.message ?? "Failed to update identity role";
+
+ createNotification({
+ text,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <div>
+ <Input
+ containerClassName="mb-4"
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search identities by name..."
+ />
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr className="h-14">
+ <Th className="w-1/2">
+ <div className="flex items-center">
+ Name
+ <IconButton
+ variant="plain"
+ className={`ml-2 ${orderBy === OrgIdentityOrderBy.Name ? "" : "opacity-30"}`}
+ ariaLabel="sort"
+ onClick={() => handleSort(OrgIdentityOrderBy.Name)}
+ >
+ <FontAwesomeIcon
+ icon={
+ orderDirection === OrderByDirection.DESC &&
+ orderBy === OrgIdentityOrderBy.Name
+ ? faArrowUp
+ : faArrowDown
+ }
+ />
+ </IconButton>
+ </div>
+ </Th>
+ <Th>Role</Th>
+ {/* <Th>
+ <div className="flex items-center">
+ Role
+ <IconButton
+ variant="plain"
+ className={`ml-2 ${orderBy === OrgIdentityOrderBy.Role ? "" : "opacity-30"}`}
+ ariaLabel="sort"
+ onClick={() => handleSort(OrgIdentityOrderBy.Role)}
+ >
+ <FontAwesomeIcon
+ icon={
+ orderDirection === OrderByDirection.DESC &&
+ orderBy === OrgIdentityOrderBy.Role
+ ? faArrowUp
+ : faArrowDown
+ }
+ />
+ </IconButton>
+ </div>
+ </Th> */}
+ <Th className="w-16">{isFetching ? <Spinner size="xs" /> : null}</Th>
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={3} innerKey="org-identities" />}
+ {!isLoading &&
+ data?.identityMemberships.map(({ identity: { id, name }, role, customRole }) => {
+ return (
+ <Tr
+ className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ key={`identity-${id}`}
+ onClick={() =>
+ navigate({
+ to: "/organization/$organizationId/identities/$identityId",
+ params: {
+ organizationId,
+ identityId: id
+ }
+ })
+ }
+ >
+ <Td>{name}</Td>
+ <Td>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Identity}
+ >
+ {(isAllowed) => {
+ return (
+ <Select
+ value={role === "custom" ? (customRole?.slug as string) : role}
+ isDisabled={!isAllowed}
+ className="w-48 bg-mineshaft-600"
+ dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
+ onValueChange={(selectedRole) =>
+ handleChangeRole({
+ identityId: id,
+ role: selectedRole
+ })
+ }
+ >
+ {(roles || []).map(({ slug, name: roleName }) => (
+ <SelectItem value={slug} key={`owner-option-${slug}`}>
+ {roleName}
+ </SelectItem>
+ ))}
+ </Select>
+ );
+ }}
+ </OrgPermissionCan>
+ </Td>
+ <Td>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <div className="flex justify-center hover:text-primary-400 data-[state=open]:text-primary-400">
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Identity}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ navigate.push(`/org/${organizationId}/identities/${id}`);
+ }}
+ disabled={!isAllowed}
+ >
+ Edit Identity
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Identity}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ isAllowed
+ ? "hover:!bg-red-500 hover:!text-white"
+ : "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("deleteIdentity", {
+ identityId: id,
+ name
+ });
+ }}
+ disabled={!isAllowed}
+ >
+ Delete Identity
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </Td>
+ </Tr>
+ );
+ })}
+ </TBody>
+ </Table>
+ {!isLoading && data && totalCount > 0 && (
+ <Pagination
+ count={totalCount}
+ page={page}
+ perPage={perPage}
+ onChangePage={(newPage) => setPage(newPage)}
+ onChangePerPage={(newPerPage) => setPerPage(newPerPage)}
+ />
+ )}
+ {!isLoading && data && data?.identityMemberships.length === 0 && (
+ <EmptyState
+ title={
+ debouncedSearch.trim().length > 0
+ ? "No identities match search filter"
+ : "No identities have been created in this organization"
+ }
+ icon={faServer}
+ />
+ )}
+ </TableContainer>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthForm.tsx
new file mode 100644
index 0000000000..8511780f9e
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthForm.tsx
@@ -0,0 +1,285 @@
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, IconButton, Input } from "@app/components/v2";
+import { useOrganization, useSubscription } from "@app/context";
+import {
+ useAddIdentityTokenAuth,
+ useGetIdentityTokenAuth,
+ useUpdateIdentityTokenAuth
+} from "@app/hooks/api";
+import { IdentityAuthMethod } from "@app/hooks/api/identities";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z
+ .object({
+ accessTokenTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token TTL cannot be greater than 315360000"
+ }),
+ accessTokenMaxTTL: z.string().refine((val) => Number(val) <= 315360000, {
+ message: "Access Token Max TTL cannot be greater than 315360000"
+ }),
+ accessTokenNumUsesLimit: z.string(),
+ accessTokenTrustedIps: z
+ .array(
+ z.object({
+ ipAddress: z.string().max(50)
+ })
+ )
+ .min(1)
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["identityAuthMethod", "revokeAuthMethod"]>,
+ state?: boolean
+ ) => void;
+ identityAuthMethodData?: {
+ identityId: string;
+ name: string;
+ configuredAuthMethods?: IdentityAuthMethod[];
+ authMethod?: IdentityAuthMethod;
+ };
+};
+
+export const IdentityTokenAuthForm = ({
+ handlePopUpOpen,
+ handlePopUpToggle,
+ identityAuthMethodData
+}: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { subscription } = useSubscription();
+
+ const { mutateAsync: addMutateAsync } = useAddIdentityTokenAuth();
+ const { mutateAsync: updateMutateAsync } = useUpdateIdentityTokenAuth();
+
+ const isUpdate = identityAuthMethodData?.configuredAuthMethods?.includes(
+ identityAuthMethodData.authMethod! || ""
+ );
+
+ const { data } = useGetIdentityTokenAuth(identityAuthMethodData?.identityId ?? "", {
+ enabled: isUpdate
+ });
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ }
+ });
+
+ const {
+ fields: accessTokenTrustedIpsFields,
+ append: appendAccessTokenTrustedIp,
+ remove: removeAccessTokenTrustedIp
+ } = useFieldArray({ control, name: "accessTokenTrustedIps" });
+
+ const onFormSubmit = async ({
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps
+ }: FormData) => {
+ try {
+ if (!identityAuthMethodData) return;
+
+ if (data) {
+ await updateMutateAsync({
+ organizationId: orgId,
+ identityId: identityAuthMethodData.identityId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ } else {
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId: identityAuthMethodData.identityId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ }
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
+ } catch {
+ createNotification({
+ text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenMaxTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="0"
+ name="accessTokenNumUsesLimit"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max Number of Uses"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ </FormControl>
+ )}
+ />
+ {accessTokenTrustedIpsFields.map(({ id }, index) => (
+ <div className="mb-3 flex items-end space-x-2" key={id}>
+ <Controller
+ control={control}
+ name={`accessTokenTrustedIps.${index}.ipAddress`}
+ defaultValue="0.0.0.0/0"
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ label={index === 0 ? "Access Token Trusted IPs" : undefined}
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => {
+ if (subscription?.ipAllowlisting) {
+ field.onChange(e);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ placeholder="123.456.789.0"
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <IconButton
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ removeAccessTokenTrustedIp(index);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ appendAccessTokenTrustedIp({
+ ipAddress: "0.0.0.0/0"
+ });
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add IP Address
+ </Button>
+ </div>
+ <div className="flex justify-between">
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {isUpdate ? "Update" : "Create"}
+ </Button>
+
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("identityAuthMethod", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ {isUpdate && (
+ <Button
+ size="sm"
+ colorSchema="danger"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ onClick={() => handlePopUpToggle("revokeAuthMethod", true)}
+ >
+ Remove Auth Method
+ </Button>
+ )}
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthTokenModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthTokenModal.tsx
new file mode 100644
index 0000000000..f90dae41b9
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthTokenModal.tsx
@@ -0,0 +1,53 @@
+import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { IconButton, Modal, ModalContent, Tooltip } from "@app/components/v2";
+import { useTimedReset } from "@app/hooks";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+type Props = {
+ popUp: UsePopUpState<["tokenAuthToken"]>;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["tokenAuthToken"]>, state?: boolean) => void;
+};
+
+export const IdentityTokenAuthTokenModal = ({ popUp, handlePopUpToggle }: Props) => {
+ const [copyTextAccessToken, isCopyingAccessToken, setCopyTextAccessToken] = useTimedReset<string>(
+ {
+ initialState: "Copy to clipboard"
+ }
+ );
+
+ const popUpData = popUp?.tokenAuthToken?.data as {
+ accessToken: string;
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.tokenAuthToken?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("tokenAuthToken", isOpen);
+ }}
+ >
+ <ModalContent title="Access Token">
+ {popUpData?.accessToken && (
+ <div className="mb-8 flex items-center justify-between rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{popUpData.accessToken}</p>
+ <Tooltip content={copyTextAccessToken}>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(popUpData.accessToken);
+ setCopyTextAccessToken("Copied");
+ }}
+ >
+ <FontAwesomeIcon icon={isCopyingAccessToken ? faCheck : faCopy} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ )}
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthClientSecretModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthClientSecretModal.tsx
new file mode 100644
index 0000000000..668882b9d6
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthClientSecretModal.tsx
@@ -0,0 +1,344 @@
+import { useEffect, useState } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { useTranslation } from "react-i18next";
+import { faCheck, faCopy, faKey, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { yupResolver } from "@hookform/resolvers/yup";
+import { format } from "date-fns";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ // DeleteActionModal,
+ EmptyState,
+ FormControl,
+ IconButton,
+ Input,
+ Modal,
+ ModalContent,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useToggle } from "@app/hooks";
+import {
+ useCreateIdentityUniversalAuthClientSecret,
+ useGetIdentityUniversalAuth,
+ useGetIdentityUniversalAuthClientSecrets
+} from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z.object({
+ description: z.string(),
+ ttl: z
+ .string()
+ .refine((value) => Number(value) <= 315360000, "TTL cannot be greater than 315360000"),
+ numUsesLimit: z.string()
+});
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ popUp: UsePopUpState<["universalAuthClientSecret", "revokeClientSecret"]>;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["revokeClientSecret"]>,
+ data?: {
+ clientSecretPrefix: string;
+ clientSecretId: string;
+ }
+ ) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["universalAuthClientSecret", "revokeClientSecret"]>,
+ state?: boolean
+ ) => void;
+};
+
+export const IdentityUniversalAuthClientSecretModal = ({
+ popUp,
+ handlePopUpOpen,
+ handlePopUpToggle
+}: Props) => {
+ const { t } = useTranslation();
+
+ const [token, setToken] = useState("");
+ const [isClientSecretCopied, setIsClientSecretCopied] = useToggle(false);
+ const [isClientIdCopied, setIsClientIdCopied] = useToggle(false);
+
+ const popUpData = popUp?.universalAuthClientSecret?.data as {
+ identityId?: string;
+ name?: string;
+ };
+
+ const { data, isLoading } = useGetIdentityUniversalAuthClientSecrets(popUpData?.identityId ?? "");
+ const { data: identityUniversalAuth } = useGetIdentityUniversalAuth(popUpData?.identityId ?? "");
+
+ const { mutateAsync: createClientSecretMutateAsync } =
+ useCreateIdentityUniversalAuthClientSecret();
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: yupResolver(schema),
+ defaultValues: {
+ description: "",
+ ttl: "",
+ numUsesLimit: ""
+ }
+ });
+
+ useEffect(() => {
+ let timer: NodeJS.Timeout;
+ if (isClientSecretCopied) {
+ timer = setTimeout(() => setIsClientSecretCopied.off(), 2000);
+ }
+
+ return () => clearTimeout(timer);
+ }, [isClientSecretCopied]);
+
+ useEffect(() => {
+ let timer: NodeJS.Timeout;
+ if (isClientIdCopied) {
+ timer = setTimeout(() => setIsClientIdCopied.off(), 2000);
+ }
+
+ return () => clearTimeout(timer);
+ }, [isClientIdCopied]);
+
+ const onFormSubmit = async ({ description, ttl, numUsesLimit }: FormData) => {
+ try {
+ if (!popUpData?.identityId) return;
+
+ const { clientSecret } = await createClientSecretMutateAsync({
+ identityId: popUpData.identityId,
+ description,
+ ttl: Number(ttl),
+ numUsesLimit: Number(numUsesLimit)
+ });
+
+ setToken(clientSecret);
+
+ createNotification({
+ text: "Successfully created client secret",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to create client secret",
+ type: "error"
+ });
+ }
+ };
+
+ const hasToken = Boolean(token);
+
+ return (
+ <Modal
+ isOpen={popUp?.universalAuthClientSecret?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("universalAuthClientSecret", isOpen);
+ reset();
+ setToken("");
+ }}
+ >
+ <ModalContent title={`Manage Client ID/Secrets for ${popUpData?.name ?? ""}`}>
+ <h2 className="mb-4">Client ID</h2>
+ <div className="mb-8 flex items-center justify-between rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{identityUniversalAuth?.clientId ?? ""}</p>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(identityUniversalAuth?.clientId ?? "");
+ setIsClientIdCopied.on();
+ }}
+ >
+ <FontAwesomeIcon icon={isClientIdCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ {t("common.click-to-copy")}
+ </span>
+ </IconButton>
+ </div>
+ <h2 className="mb-4">New Client Secret</h2>
+ {hasToken ? (
+ <div>
+ <div className="mb-4 flex items-center justify-between">
+ <p>We will only show this secret once</p>
+ <Button
+ colorSchema="secondary"
+ type="submit"
+ onClick={() => {
+ reset();
+ setToken("");
+ }}
+ >
+ Got it
+ </Button>
+ </div>
+ <div className="mb-8 flex items-center justify-between rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{token}</p>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(token);
+ setIsClientSecretCopied.on();
+ }}
+ >
+ <FontAwesomeIcon icon={isClientSecretCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ {t("common.click-to-copy")}
+ </span>
+ </IconButton>
+ </div>
+ </div>
+ ) : (
+ <form onSubmit={handleSubmit(onFormSubmit)} className="mb-8">
+ <Controller
+ control={control}
+ defaultValue=""
+ name="description"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Description (optional)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="Description" />
+ </FormControl>
+ )}
+ />
+ <div className="flex">
+ <Controller
+ control={control}
+ defaultValue=""
+ name="ttl"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="TTL (seconds - optional)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <div className="flex">
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ </div>
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="0"
+ name="numUsesLimit"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Max Number of Uses"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ className="ml-4"
+ >
+ <div className="flex">
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ <Button
+ className="ml-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Create
+ </Button>
+ </div>
+ </FormControl>
+ )}
+ />
+ </div>
+ </form>
+ )}
+ <h2 className="mb-4">Client Secrets</h2>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Description</Th>
+ <Th>Num Uses</Th>
+ <Th>Expires At</Th>
+ <Th>Client Secret</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={5} innerKey="org-identities-client-secrets" />}
+ {!isLoading &&
+ data &&
+ data.length > 0 &&
+ data.map(
+ ({
+ id,
+ description,
+ clientSecretTTL,
+ clientSecretPrefix,
+ clientSecretNumUses,
+ clientSecretNumUsesLimit,
+ createdAt
+ }) => {
+ let expiresAt;
+ if (clientSecretTTL > 0) {
+ expiresAt = new Date(new Date(createdAt).getTime() + clientSecretTTL * 1000);
+ }
+
+ return (
+ <Tr className="h-10 items-center" key={`mi-client-secret-${id}`}>
+ <Td>{description === "" ? "-" : description}</Td>
+ <Td>{`${clientSecretNumUses}${
+ clientSecretNumUsesLimit ? `/${clientSecretNumUsesLimit}` : ""
+ }`}</Td>
+ <Td>{expiresAt ? format(expiresAt, "yyyy-MM-dd") : "-"}</Td>
+ <Td>{`${clientSecretPrefix}****`}</Td>
+ <Td>
+ <IconButton
+ onClick={() => {
+ handlePopUpOpen("revokeClientSecret", {
+ clientSecretPrefix,
+ clientSecretId: id
+ });
+ }}
+ size="lg"
+ colorSchema="primary"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </Td>
+ </Tr>
+ );
+ }
+ )}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState
+ title="No client secrets have been created for this identity yet"
+ icon={faKey}
+ />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx
new file mode 100644
index 0000000000..61d0416ab3
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx
@@ -0,0 +1,414 @@
+import { useEffect } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { yupResolver } from "@hookform/resolvers/yup";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, IconButton, Input } from "@app/components/v2";
+import { useOrganization, useSubscription } from "@app/context";
+import {
+ useAddIdentityUniversalAuth,
+ useGetIdentityUniversalAuth,
+ useUpdateIdentityUniversalAuth
+} from "@app/hooks/api";
+import { IdentityAuthMethod } from "@app/hooks/api/identities";
+import { IdentityTrustedIp } from "@app/hooks/api/identities/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+// TODO(rbr): check these forms validation again
+const schema = z
+ .object({
+ accessTokenTTL: z
+ .string()
+ .refine(
+ (value) => Number(value) <= 315360000,
+ "Access Token TTL cannot be greater than 315360000"
+ ),
+ accessTokenMaxTTL: z
+ .string()
+ .refine(
+ (value) => Number(value) <= 315360000,
+ "Access Max Token TTL cannot be greater than 315360000"
+ ),
+ accessTokenNumUsesLimit: z.string(),
+ clientSecretTrustedIps: z
+ .object({
+ ipAddress: z.string().max(50)
+ })
+ .array()
+ .min(1),
+ accessTokenTrustedIps: z
+ .object({
+ ipAddress: z.string().max(50)
+ })
+ .array()
+ .min(1)
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["identityAuthMethod", "revokeAuthMethod"]>,
+ state?: boolean
+ ) => void;
+ identityAuthMethodData?: {
+ identityId: string;
+ name: string;
+ configuredAuthMethods?: IdentityAuthMethod[];
+ authMethod?: IdentityAuthMethod;
+ };
+};
+
+export const IdentityUniversalAuthForm = ({
+ handlePopUpOpen,
+ handlePopUpToggle,
+ identityAuthMethodData
+}: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { subscription } = useSubscription();
+ const { mutateAsync: addMutateAsync } = useAddIdentityUniversalAuth();
+ const { mutateAsync: updateMutateAsync } = useUpdateIdentityUniversalAuth();
+
+ const isUpdate = identityAuthMethodData?.configuredAuthMethods?.includes(
+ identityAuthMethodData.authMethod! || ""
+ );
+
+ const { data } = useGetIdentityUniversalAuth(identityAuthMethodData?.identityId ?? "", {
+ enabled: isUpdate
+ });
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: yupResolver(schema),
+ defaultValues: {
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ }
+ });
+
+ const {
+ fields: clientSecretTrustedIpsFields,
+ append: appendClientSecretTrustedIp,
+ remove: removeClientSecretTrustedIp
+ } = useFieldArray({ control, name: "clientSecretTrustedIps" });
+ const {
+ fields: accessTokenTrustedIpsFields,
+ append: appendAccessTokenTrustedIp,
+ remove: removeAccessTokenTrustedIp
+ } = useFieldArray({ control, name: "accessTokenTrustedIps" });
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ accessTokenTTL: String(data.accessTokenTTL),
+ accessTokenMaxTTL: String(data.accessTokenMaxTTL),
+ accessTokenNumUsesLimit: String(data.accessTokenNumUsesLimit),
+ clientSecretTrustedIps: data.clientSecretTrustedIps.map(
+ ({ ipAddress, prefix }: IdentityTrustedIp) => {
+ return {
+ ipAddress: `${ipAddress}${prefix !== undefined ? `/${prefix}` : ""}`
+ };
+ }
+ ),
+ accessTokenTrustedIps: data.accessTokenTrustedIps.map(
+ ({ ipAddress, prefix }: IdentityTrustedIp) => {
+ return {
+ ipAddress: `${ipAddress}${prefix !== undefined ? `/${prefix}` : ""}`
+ };
+ }
+ )
+ });
+ } else {
+ reset({
+ accessTokenTTL: "2592000",
+ accessTokenMaxTTL: "2592000",
+ accessTokenNumUsesLimit: "0",
+ clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }]
+ });
+ }
+ }, [data]);
+
+ const onFormSubmit = async ({
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ clientSecretTrustedIps,
+ accessTokenTrustedIps
+ }: FormData) => {
+ try {
+ if (!identityAuthMethodData) return;
+
+ if (data) {
+ // update universal auth configuration
+ await updateMutateAsync({
+ organizationId: orgId,
+ identityId: identityAuthMethodData.identityId,
+ clientSecretTrustedIps,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ } else {
+ // create new universal auth configuration
+
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId: identityAuthMethodData.identityId,
+ clientSecretTrustedIps,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
+ });
+ }
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "created"} auth method`,
+ type: "success"
+ });
+
+ reset();
+ } catch (err) {
+ console.error(err);
+ const error = err as any;
+ const text =
+ error?.response?.data?.message ?? `Failed to ${isUpdate ? "update" : "configure"} identity`;
+
+ createNotification({
+ text,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="2592000"
+ name="accessTokenMaxTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max TTL (seconds)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="2592000" type="number" min="1" step="1" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="0"
+ name="accessTokenNumUsesLimit"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Token Max Number of Uses"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ </FormControl>
+ )}
+ />
+ {clientSecretTrustedIpsFields.map(({ id }, index) => (
+ <div className="mb-3 flex items-end space-x-2" key={id}>
+ <Controller
+ control={control}
+ name={`clientSecretTrustedIps.${index}.ipAddress`}
+ defaultValue="0.0.0.0/0"
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ label={index === 0 ? "Client Secret Trusted IPs" : undefined}
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => {
+ if (subscription?.ipAllowlisting) {
+ field.onChange(e);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ placeholder="123.456.789.0"
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <IconButton
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ removeClientSecretTrustedIp(index);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ appendClientSecretTrustedIp({
+ ipAddress: "0.0.0.0/0"
+ });
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add IP Address
+ </Button>
+ </div>
+ {accessTokenTrustedIpsFields.map(({ id }, index) => (
+ <div className="mb-3 flex items-end space-x-2" key={id}>
+ <Controller
+ control={control}
+ name={`accessTokenTrustedIps.${index}.ipAddress`}
+ defaultValue="0.0.0.0/0"
+ render={({ field, fieldState: { error } }) => {
+ return (
+ <FormControl
+ className="mb-0 flex-grow"
+ label={index === 0 ? "Access Token Trusted IPs" : undefined}
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input
+ value={field.value}
+ onChange={(e) => {
+ if (subscription?.ipAllowlisting) {
+ field.onChange(e);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ placeholder="123.456.789.0"
+ />
+ </FormControl>
+ );
+ }}
+ />
+ <IconButton
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ removeAccessTokenTrustedIp(index);
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ className="p-3"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="my-4 ml-1">
+ <Button
+ variant="outline_bg"
+ onClick={() => {
+ if (subscription?.ipAllowlisting) {
+ appendAccessTokenTrustedIp({
+ ipAddress: "0.0.0.0/0"
+ });
+ return;
+ }
+
+ handlePopUpOpen("upgradePlan");
+ }}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ >
+ Add IP Address
+ </Button>
+ </div>
+ <div className="flex justify-between">
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {isUpdate ? "Edit" : "Create"}
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("identityAuthMethod", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ {isUpdate && (
+ <Button
+ size="sm"
+ colorSchema="danger"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ onClick={() => handlePopUpToggle("revokeAuthMethod", true)}
+ >
+ Delete Auth Method
+ </Button>
+ )}
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/index.tsx
new file mode 100644
index 0000000000..f0663a6a57
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/IdentitySection/index.tsx
@@ -0,0 +1 @@
+export { IdentitySection } from "./IdentitySection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/index.tsx
new file mode 100644
index 0000000000..f0663a6a57
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/components/index.tsx
@@ -0,0 +1 @@
+export { IdentitySection } from "./IdentitySection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/index.tsx
new file mode 100644
index 0000000000..bf193d94f5
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgIdentityTab/index.tsx
@@ -0,0 +1 @@
+export { OrgIdentityTab } from "./OrgIdentityTab";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/OrgMembersTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/OrgMembersTab.tsx
new file mode 100644
index 0000000000..1afb9bfbd0
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/OrgMembersTab.tsx
@@ -0,0 +1,17 @@
+import { motion } from "framer-motion";
+
+import { OrgMembersSection } from "./components";
+
+export const OrgMembersTab = () => {
+ return (
+ <motion.div
+ key="panel-org-members"
+ transition={{ duration: 0.15 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: 30 }}
+ >
+ <OrgMembersSection />
+ </motion.div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/AddOrgMemberModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/AddOrgMemberModal.tsx
new file mode 100644
index 0000000000..15b2cdce13
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/AddOrgMemberModal.tsx
@@ -0,0 +1,321 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FilterableSelect,
+ FormControl,
+ Modal,
+ ModalContent,
+ Select,
+ SelectItem,
+ TextArea
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { findOrgMembershipRole } from "@app/helpers/roles";
+import {
+ useAddUsersToOrg,
+ useFetchServerStatus,
+ useGetOrgRoles,
+ useGetUserWorkspaces
+} from "@app/hooks/api";
+import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
+import { ProjectVersion } from "@app/hooks/api/workspace/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+import { OrgInviteLink } from "./OrgInviteLink";
+
+const DEFAULT_ORG_AND_PROJECT_MEMBER_ROLE_SLUG = "member";
+
+const EmailSchema = z.string().email().min(1).trim().toLowerCase();
+
+const addMemberFormSchema = z.object({
+ emails: z.string().min(1).trim().toLowerCase(),
+ projects: z
+ .array(
+ z.object({
+ name: z.string(),
+ id: z.string(),
+ slug: z.string(),
+ version: z.nativeEnum(ProjectVersion)
+ })
+ )
+ .default([]),
+ projectRoleSlug: z.string().min(1).default(DEFAULT_ORG_AND_PROJECT_MEMBER_ROLE_SLUG),
+ organizationRole: z.object({ name: z.string(), slug: z.string() })
+});
+
+type TAddMemberForm = z.infer<typeof addMemberFormSchema>;
+
+type Props = {
+ popUp: UsePopUpState<["addMember"]>;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["addMember"]>, state?: boolean) => void;
+ completeInviteLinks: Array<{
+ email: string;
+ link: string;
+ }> | null;
+ setCompleteInviteLinks: (links: Array<{ email: string; link: string }> | null) => void;
+};
+
+export const AddOrgMemberModal = ({
+ popUp,
+ handlePopUpToggle,
+ completeInviteLinks,
+ setCompleteInviteLinks
+}: Props) => {
+ const { currentOrg } = useOrganization();
+
+ const { data: organizationRoles } = useGetOrgRoles(currentOrg?.id ?? "");
+ const { data: serverDetails } = useFetchServerStatus();
+ const { mutateAsync: addUsersMutateAsync } = useAddUsersToOrg();
+ const { data: projects, isLoading: isProjectsLoading } = useGetUserWorkspaces({
+ includeRoles: true
+ });
+
+ const {
+ control,
+ handleSubmit,
+ watch,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<TAddMemberForm>({
+ resolver: zodResolver(addMemberFormSchema)
+ });
+
+ // set initial form role based off org default role
+ useEffect(() => {
+ if (organizationRoles) {
+ reset({
+ organizationRole: findOrgMembershipRole(organizationRoles, currentOrg.defaultMembershipRole)
+ });
+ }
+ }, [organizationRoles]);
+
+ const onAddMembers = async ({
+ emails,
+ organizationRole,
+ projects: selectedProjects,
+ projectRoleSlug
+ }: TAddMemberForm) => {
+ if (!currentOrg?.id) return;
+
+ if (selectedProjects?.length) {
+ // eslint-disable-next-line no-restricted-syntax
+ for (const project of selectedProjects) {
+ if (project.version !== ProjectVersion.V3) {
+ createNotification({
+ type: "error",
+ text: `Cannot add users to project "${project.name}" because it's incompatible. Please upgrade the project.`
+ });
+ return;
+ }
+ }
+ }
+
+ try {
+ const parsedEmails = emails
+ .replace(/\s/g, "")
+ .split(",")
+ .map((email) => {
+ if (EmailSchema.safeParse(email).success) {
+ return email.trim();
+ }
+
+ return null;
+ });
+
+ if (parsedEmails.includes(null)) {
+ createNotification({
+ text: "Invalid email addresses provided.",
+ type: "error"
+ });
+ return;
+ }
+
+ const { data } = await addUsersMutateAsync({
+ organizationId: currentOrg?.id,
+ inviteeEmails: emails.split(",").map((email) => email.trim()),
+ organizationRoleSlug: organizationRole.slug,
+ projects: selectedProjects.map(({ id }) => ({ id, projectRoleSlug: [projectRoleSlug] }))
+ });
+
+ setCompleteInviteLinks(data?.completeInviteLinks ?? null);
+
+ // only show this notification when email is configured.
+ // A [completeInviteLink] will not be sent if smtp is configured
+
+ if (!data.completeInviteLinks) {
+ createNotification({
+ text: "Successfully invited user to the organization.",
+ type: "success"
+ });
+ }
+ } catch (error) {
+ console.error(error);
+ createNotification({
+ text: "Failed to invite user to org",
+ type: "error"
+ });
+ }
+
+ if (serverDetails?.emailConfigured) {
+ handlePopUpToggle("addMember", false);
+ }
+
+ reset();
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.addMember?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addMember", isOpen);
+ setCompleteInviteLinks(null);
+ }}
+ >
+ <ModalContent
+ bodyClassName="overflow-visible"
+ title={`Invite others to ${currentOrg?.name}`}
+ subTitle={
+ <div>
+ {!completeInviteLinks && (
+ <div>An invite is specific to an email address and expires after 1 day.</div>
+ )}
+ {completeInviteLinks &&
+ "This Infisical instance does not have a email provider setup. Please share this invite link with the invitee manually"}
+ </div>
+ }
+ >
+ {!completeInviteLinks && (
+ <form onSubmit={handleSubmit(onAddMembers)}>
+ <Controller
+ control={control}
+ name="emails"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Emails" isError={Boolean(error)} errorText={error?.message}>
+ <TextArea
+ {...field}
+ className="mt-1 h-20 w-full min-w-[30rem] rounded-md border border-mineshaft-500 bg-mineshaft-900/70 px-2 py-1 text-sm text-bunker-300 outline-none ring-primary-800 ring-opacity-70 transition-all placeholder:text-bunker-400 focus:ring-2"
+ />
+ </FormControl>
+ )}
+ />
+
+ <Controller
+ control={control}
+ name="organizationRole"
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ tooltipText="Select which organization role you want to assign to the user."
+ label="Assign organization role"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <FilterableSelect
+ placeholder="Select role..."
+ options={organizationRoles}
+ getOptionValue={(option) => option.slug}
+ getOptionLabel={(option) => option.name}
+ value={value}
+ onChange={onChange}
+ />
+ </FormControl>
+ )}
+ />
+
+ <div className="flex items-start justify-between gap-2">
+ <div className="w-full">
+ <Controller
+ control={control}
+ name="projects"
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ label="Assign users to projects"
+ isOptional
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <FilterableSelect
+ isMulti
+ value={value}
+ onChange={onChange}
+ isLoading={isProjectsLoading}
+ getOptionLabel={(project) => project.name}
+ getOptionValue={(project) => project.id}
+ options={projects}
+ placeholder="Select projects..."
+ />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="mt-[0.15rem] flex min-w-fit justify-end">
+ <Controller
+ control={control}
+ name="projectRoleSlug"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ tooltipText="Select which role to assign to the users in the selected projects."
+ label="Role"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <div>
+ <Select
+ isDisabled={watch("projects", []).length === 0}
+ defaultValue={DEFAULT_ORG_AND_PROJECT_MEMBER_ROLE_SLUG}
+ {...field}
+ onValueChange={(val) => field.onChange(val)}
+ >
+ {Object.entries(ProjectMembershipRole).map(
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ ([_, slug]) =>
+ slug !== "custom" && (
+ <SelectItem key={slug} value={slug}>
+ <span className="capitalize">{slug.replace("-", " ")}</span>
+ </SelectItem>
+ )
+ )}
+ </Select>
+ </div>
+ </FormControl>
+ )}
+ />
+ </div>
+ </div>
+
+ <div className="mt-8 flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Add Member
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("addMember", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ )}
+ {completeInviteLinks && (
+ <div className="space-y-3">
+ {completeInviteLinks.map((invite) => (
+ <OrgInviteLink key={`invite-${invite.email}`} invite={invite} />
+ ))}
+ </div>
+ )}
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/OrgInviteLink.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/OrgInviteLink.tsx
new file mode 100644
index 0000000000..007ff1a100
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/OrgInviteLink.tsx
@@ -0,0 +1,55 @@
+import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { twMerge } from "tailwind-merge";
+
+import { createNotification } from "@app/components/notifications";
+import { IconButton, Tooltip } from "@app/components/v2";
+import { useToggle } from "@app/hooks";
+
+type Props = {
+ invite: { email: string; link: string };
+};
+
+export const OrgInviteLink = ({ invite }: Props) => {
+ const [isInviteLinkCopied, setInviteLinkCopied] = useToggle(false);
+
+ const copyTokenToClipboard = () => {
+ if (isInviteLinkCopied) return;
+
+ navigator.clipboard.writeText(invite.link);
+ setInviteLinkCopied.timedToggle();
+
+ createNotification({
+ type: "info",
+ text: "Copied invitation link to clipboard"
+ });
+ };
+
+ return (
+ <div key={`invite-${invite.email}`}>
+ <p className="text-sm text-mineshaft-400">
+ Invite for <span className="font-medium">{invite.email}</span>
+ </p>
+ <div className="flex flex-col gap-1 rounded-md bg-white/[0.04] p-2 text-base text-gray-400">
+ <p
+ className={twMerge(
+ "mr-4 line-clamp-1",
+ window.isSecureContext ? "overflow-hidden text-ellipsis whitespace-nowrap" : "break-all"
+ )}
+ >
+ {invite.link}
+ </p>
+ <Tooltip content={`Copy invitation link for ${invite.email}`}>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => copyTokenToClipboard()}
+ >
+ <FontAwesomeIcon icon={isInviteLinkCopied ? faCheck : faCopy} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
new file mode 100644
index 0000000000..340295c93f
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
@@ -0,0 +1,186 @@
+import { useState } from "react";
+import { faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ DeleteActionModal,
+ EmailServiceSetupModal,
+ UpgradePlanModal
+} from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { useDeleteOrgMembership, useUpdateOrgMembership } from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { AddOrgMemberModal } from "./AddOrgMemberModal";
+import { OrgMembersTable } from "./OrgMembersTable";
+
+export const OrgMembersSection = () => {
+ const { subscription } = useSubscription();
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id ?? "";
+
+ const [completeInviteLinks, setCompleteInviteLinks] = useState<Array<{
+ email: string;
+ link: string;
+ }> | null>(null);
+
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "addMember",
+ "removeMember",
+ "deactivateMember",
+ "upgradePlan",
+ "setUpEmail"
+ ] as const);
+
+ const { mutateAsync: deleteMutateAsync } = useDeleteOrgMembership();
+ const { mutateAsync: updateOrgMembership } = useUpdateOrgMembership();
+
+ const isMoreUsersAllowed = subscription?.memberLimit
+ ? subscription.membersUsed < subscription.memberLimit
+ : true;
+
+ const isMoreIdentitiesAllowed = subscription?.identityLimit
+ ? subscription.identitiesUsed < subscription.identityLimit
+ : true;
+
+ const isEnterprise = subscription?.slug === "enterprise";
+
+ const handleAddMemberModal = () => {
+ if (currentOrg?.authEnforced) {
+ createNotification({
+ text: "You cannot manage users from Infisical when org-level auth is enforced for your organization",
+ type: "error"
+ });
+ return;
+ }
+
+ if ((!isMoreUsersAllowed || !isMoreIdentitiesAllowed) && !isEnterprise) {
+ handlePopUpOpen("upgradePlan", {
+ description: "You can add more members if you upgrade your Infisical plan."
+ });
+ return;
+ }
+
+ handlePopUpOpen("addMember");
+ };
+
+ const onDeactivateMemberSubmit = async (orgMembershipId: string) => {
+ try {
+ await updateOrgMembership({
+ organizationId: orgId,
+ membershipId: orgMembershipId,
+ isActive: false
+ });
+
+ createNotification({
+ text: "Successfully deactivated user in organization",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to deactivate user in organization",
+ type: "error"
+ });
+ }
+
+ handlePopUpClose("deactivateMember");
+ };
+
+ const onRemoveMemberSubmit = async (orgMembershipId: string) => {
+ try {
+ await deleteMutateAsync({
+ orgId,
+ membershipId: orgMembershipId
+ });
+
+ createNotification({
+ text: "Successfully removed user from org",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to remove user from the organization",
+ type: "error"
+ });
+ }
+
+ handlePopUpClose("removeMember");
+ };
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="mb-4 flex justify-between">
+ <p className="text-xl font-semibold text-mineshaft-100">Users</p>
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Member}>
+ {(isAllowed) => (
+ <Button
+ colorSchema="primary"
+ type="submit"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ onClick={() => handleAddMemberModal()}
+ isDisabled={!isAllowed}
+ >
+ Add Member
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <OrgMembersTable
+ handlePopUpOpen={handlePopUpOpen}
+ setCompleteInviteLinks={setCompleteInviteLinks}
+ />
+ <AddOrgMemberModal
+ popUp={popUp}
+ handlePopUpToggle={handlePopUpToggle}
+ completeInviteLinks={completeInviteLinks}
+ setCompleteInviteLinks={setCompleteInviteLinks}
+ />
+ <DeleteActionModal
+ isOpen={popUp.removeMember.isOpen}
+ title={`Are you sure want to remove member with username ${
+ (popUp?.removeMember?.data as { username: string })?.username || ""
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() =>
+ onRemoveMemberSubmit(
+ (popUp?.removeMember?.data as { orgMembershipId: string })?.orgMembershipId
+ )
+ }
+ />
+ <DeleteActionModal
+ isOpen={popUp.deactivateMember.isOpen}
+ title={`Are you sure want to deactivate member with username ${
+ (popUp?.deactivateMember?.data as { username: string })?.username || ""
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle("deactivateMember", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() =>
+ onDeactivateMemberSubmit(
+ (popUp?.deactivateMember?.data as { orgMembershipId: string })?.orgMembershipId
+ )
+ }
+ buttonText="Deactivate"
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text={(popUp.upgradePlan?.data as { description: string })?.description}
+ />
+ <EmailServiceSetupModal
+ isOpen={popUp.setUpEmail?.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("setUpEmail", isOpen)}
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx
new file mode 100644
index 0000000000..0a54826eed
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx
@@ -0,0 +1,532 @@
+import { useCallback, useMemo } from "react";
+import {
+ faArrowDown,
+ faArrowUp,
+ faEllipsis,
+ faMagnifyingGlass,
+ faSearch,
+ faUsers
+} from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { useNavigate } from "@tanstack/react-router";
+import { twMerge } from "tailwind-merge";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Badge,
+ Button,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ EmptyState,
+ IconButton,
+ Input,
+ Pagination,
+ Select,
+ SelectItem,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription,
+ useUser
+} from "@app/context";
+import { usePagination, useResetPageHelper } from "@app/hooks";
+import {
+ useAddUsersToOrg,
+ useFetchServerStatus,
+ useGetOrgRoles,
+ useGetOrgUsers,
+ useUpdateOrgMembership
+} from "@app/hooks/api";
+import { OrderByDirection } from "@app/hooks/api/generic/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+type Props = {
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["removeMember", "deactivateMember", "upgradePlan"]>,
+ data?: {
+ orgMembershipId?: string;
+ username?: string;
+ description?: string;
+ }
+ ) => void;
+ setCompleteInviteLinks: (links: Array<{ email: string; link: string }> | null) => void;
+};
+
+enum OrgMembersOrderBy {
+ Name = "firstName",
+ Email = "email"
+}
+
+export const OrgMembersTable = ({ handlePopUpOpen, setCompleteInviteLinks }: Props) => {
+ const navigate = useNavigate();
+ const { subscription } = useSubscription();
+ const { currentOrg } = useOrganization();
+ const { user } = useUser();
+ const userId = user?.id || "";
+ const orgId = currentOrg?.id || "";
+
+ const { data: roles, isLoading: isRolesLoading } = useGetOrgRoles(orgId);
+
+ const { data: serverDetails } = useFetchServerStatus();
+ const { data: members = [], isLoading: isMembersLoading } = useGetOrgUsers(orgId);
+
+ const { mutateAsync: addUsersMutateAsync } = useAddUsersToOrg();
+ const { mutateAsync: updateOrgMembership } = useUpdateOrgMembership();
+
+ const onRoleChange = async (membershipId: string, role: string) => {
+ if (!currentOrg?.id) return;
+
+ try {
+ // TODO: replace hardcoding default role
+ const isCustomRole = !["admin", "member", "no-access"].includes(role);
+
+ if (isCustomRole && subscription && !subscription?.rbac) {
+ handlePopUpOpen("upgradePlan", {
+ description: "You can assign custom roles to members if you upgrade your Infisical plan."
+ });
+ return;
+ }
+
+ await updateOrgMembership({
+ organizationId: currentOrg?.id,
+ membershipId,
+ role
+ });
+
+ createNotification({
+ text: "Successfully updated user role",
+ type: "success"
+ });
+ } catch (error) {
+ console.error(error);
+ createNotification({
+ text: "Failed to update user role",
+ type: "error"
+ });
+ }
+ };
+
+ const onResendInvite = async (email: string) => {
+ try {
+ const { data } = await addUsersMutateAsync({
+ organizationId: orgId,
+ inviteeEmails: [email],
+ organizationRoleSlug: "member"
+ });
+
+ setCompleteInviteLinks(data?.completeInviteLinks || null);
+
+ if (!data.completeInviteLinks) {
+ createNotification({
+ text: `Successfully resent invite to ${email}`,
+ type: "success"
+ });
+ }
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: `Failed to resend invite to ${email}`,
+ type: "error"
+ });
+ }
+ };
+
+ const isLoading = isMembersLoading || isRolesLoading;
+
+ const isIamOwner = useMemo(
+ () => members?.find(({ user: u }) => userId === u?.id)?.role === "owner",
+ [userId, members]
+ );
+
+ const findRoleFromId = useCallback(
+ (roleId: string) => {
+ return (roles || []).find(({ id }) => id === roleId);
+ },
+ [roles]
+ );
+
+ const {
+ search,
+ setSearch,
+ setPage,
+ page,
+ perPage,
+ setPerPage,
+ offset,
+ orderDirection,
+ orderBy,
+ setOrderBy,
+ setOrderDirection,
+ toggleOrderDirection
+ } = usePagination<OrgMembersOrderBy>(OrgMembersOrderBy.Name, { initPerPage: 20 });
+
+ const filteredUsers = useMemo(
+ () =>
+ members
+ ?.filter(
+ ({ user: u, inviteEmail }) =>
+ u?.firstName?.toLowerCase().includes(search.toLowerCase()) ||
+ u?.lastName?.toLowerCase().includes(search.toLowerCase()) ||
+ u?.username?.toLowerCase().includes(search.toLowerCase()) ||
+ u?.email?.toLowerCase().includes(search.toLowerCase()) ||
+ inviteEmail?.toLowerCase().includes(search.toLowerCase())
+ )
+ .sort((a, b) => {
+ const [memberOne, memberTwo] = orderDirection === OrderByDirection.ASC ? [a, b] : [b, a];
+
+ let valueOne: string;
+ let valueTwo: string;
+
+ switch (orderBy) {
+ case OrgMembersOrderBy.Email:
+ valueOne = memberOne.user.email || memberOne.inviteEmail;
+ valueTwo = memberTwo.user.email || memberTwo.inviteEmail;
+ break;
+ case OrgMembersOrderBy.Name:
+ default:
+ valueOne = memberOne.user.firstName;
+ valueTwo = memberTwo.user.firstName;
+ }
+
+ if (!valueOne) return 1;
+ if (!valueTwo) return -1;
+
+ return valueOne.toLowerCase().localeCompare(valueTwo.toLowerCase());
+ }),
+ [members, search, orderDirection, orderBy]
+ );
+
+ const handleSort = (column: OrgMembersOrderBy) => {
+ if (column === orderBy) {
+ toggleOrderDirection();
+ return;
+ }
+
+ setOrderBy(column);
+ setOrderDirection(OrderByDirection.ASC);
+ };
+
+ useResetPageHelper({
+ totalCount: filteredUsers.length,
+ offset,
+ setPage
+ });
+
+ return (
+ <div>
+ <Input
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search members..."
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="w-1/3">
+ <div className="flex items-center">
+ Name
+ <IconButton
+ variant="plain"
+ className={`ml-2 ${orderBy === OrgMembersOrderBy.Name ? "" : "opacity-30"}`}
+ ariaLabel="sort"
+ onClick={() => handleSort(OrgMembersOrderBy.Name)}
+ >
+ <FontAwesomeIcon
+ icon={
+ orderDirection === OrderByDirection.DESC &&
+ orderBy === OrgMembersOrderBy.Name
+ ? faArrowUp
+ : faArrowDown
+ }
+ />
+ </IconButton>
+ </div>
+ </Th>
+ <Th className="w-1/3">
+ <div className="flex items-center">
+ Email
+ <IconButton
+ variant="plain"
+ className={`ml-2 ${orderBy === OrgMembersOrderBy.Email ? "" : "opacity-30"}`}
+ ariaLabel="sort"
+ onClick={() => handleSort(OrgMembersOrderBy.Email)}
+ >
+ <FontAwesomeIcon
+ icon={
+ orderDirection === OrderByDirection.DESC &&
+ orderBy === OrgMembersOrderBy.Email
+ ? faArrowUp
+ : faArrowDown
+ }
+ />
+ </IconButton>
+ </div>
+ </Th>
+ <Th>Role</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={5} innerKey="org-members" />}
+ {!isLoading &&
+ filteredUsers
+ .slice(offset, perPage * page)
+ .map(
+ ({
+ user: u,
+ inviteEmail,
+ role,
+ roleId,
+ id: orgMembershipId,
+ status,
+ isActive
+ }) => {
+ const name =
+ u && u.firstName ? `${u.firstName} ${u.lastName ?? ""}`.trim() : "-";
+ const email = u?.email || inviteEmail;
+ const username = u?.username ?? inviteEmail ?? "-";
+ return (
+ <Tr
+ key={`org-membership-${orgMembershipId}`}
+ className="h-10 w-full cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ onClick={() =>
+ navigate({
+ to: "/organization/$organizationId/memberships/$membershipId" as const,
+ params: {
+ organizationId: orgId,
+ membershipId: orgMembershipId
+ }
+ })
+ }
+ >
+ <Td className={isActive ? "" : "text-mineshaft-400"}>
+ {name}
+ {u.superAdmin && (
+ <Badge variant="primary" className="ml-2">
+ Server Admin
+ </Badge>
+ )}
+ </Td>
+ <Td className={isActive ? "" : "text-mineshaft-400"}>{username}</Td>
+ <Td>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Member}
+ >
+ {(isAllowed) => (
+ <>
+ {!isActive && (
+ <Button
+ isDisabled
+ className="w-40"
+ colorSchema="primary"
+ variant="outline_bg"
+ onClick={() => {}}
+ >
+ Suspended
+ </Button>
+ )}
+ {isActive && status === "accepted" && (
+ <Select
+ value={role === "custom" ? findRoleFromId(roleId)?.slug : role}
+ isDisabled={userId === u?.id || !isAllowed}
+ className="w-48 bg-mineshaft-600"
+ dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
+ onValueChange={(selectedRole) =>
+ onRoleChange(orgMembershipId, selectedRole)
+ }
+ >
+ {(roles || [])
+ .filter(({ slug }) =>
+ slug === "owner" ? isIamOwner || role === "owner" : true
+ )
+ .map(({ slug, name: roleName }) => (
+ <SelectItem value={slug} key={`owner-option-${slug}`}>
+ {roleName}
+ </SelectItem>
+ ))}
+ </Select>
+ )}
+ {isActive &&
+ (status === "invited" || status === "verified") &&
+ email &&
+ serverDetails?.emailConfigured && (
+ <Button
+ isDisabled={!isAllowed}
+ className="w-48"
+ colorSchema="primary"
+ variant="outline_bg"
+ onClick={() => onResendInvite(email)}
+ >
+ Resend invite
+ </Button>
+ )}
+ </>
+ )}
+ </OrgPermissionCan>
+ </Td>
+ <Td>
+ {userId !== u?.id && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <div className="hover:text-primary-400 data-[state=open]:text-primary-400">
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Member}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ !isAllowed &&
+ "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ navigate({
+ to: "/organization/$organizationId/memberships/$membershipId" as const,
+ params: {
+ organizationId: orgId,
+ membershipId: orgMembershipId
+ }
+ });
+ }}
+ disabled={!isAllowed}
+ >
+ Edit User
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Member}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={
+ isActive
+ ? twMerge(
+ isAllowed
+ ? "hover:!bg-red-500 hover:!text-white"
+ : "pointer-events-none cursor-not-allowed opacity-50"
+ )
+ : ""
+ }
+ onClick={async (e) => {
+ e.stopPropagation();
+
+ if (currentOrg?.scimEnabled) {
+ createNotification({
+ text: "You cannot manage users from Infisical when org-level auth is enforced for your organization",
+ type: "error"
+ });
+ return;
+ }
+
+ if (!isActive) {
+ // activate user
+ await updateOrgMembership({
+ organizationId: orgId,
+ membershipId: orgMembershipId,
+ isActive: true
+ });
+
+ return;
+ }
+
+ // deactivate user
+ handlePopUpOpen("deactivateMember", {
+ orgMembershipId,
+ username
+ });
+ }}
+ disabled={!isAllowed}
+ >
+ {`${isActive ? "Deactivate" : "Activate"} User`}
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Member}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ isAllowed
+ ? "hover:!bg-red-500 hover:!text-white"
+ : "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+
+ if (currentOrg?.scimEnabled) {
+ createNotification({
+ text: "You cannot manage users from Infisical when org-level auth is enforced for your organization",
+ type: "error"
+ });
+ return;
+ }
+
+ handlePopUpOpen("removeMember", {
+ orgMembershipId,
+ username
+ });
+ }}
+ disabled={!isAllowed}
+ >
+ Remove User
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </Td>
+ </Tr>
+ );
+ }
+ )}
+ </TBody>
+ </Table>
+ {Boolean(filteredUsers.length) && (
+ <Pagination
+ count={filteredUsers.length}
+ page={page}
+ perPage={perPage}
+ onChangePage={setPage}
+ onChangePerPage={setPerPage}
+ />
+ )}
+ {!isMembersLoading && !filteredUsers?.length && (
+ <EmptyState
+ title={
+ members.length
+ ? "No organization members match search..."
+ : "No organization members found"
+ }
+ icon={members.length ? faSearch : faUsers}
+ />
+ )}
+ </TableContainer>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/index.tsx
new file mode 100644
index 0000000000..973e12e3e6
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/OrgMembersSection/index.tsx
@@ -0,0 +1 @@
+export { OrgMembersSection } from "./OrgMembersSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/index.tsx
new file mode 100644
index 0000000000..973e12e3e6
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/components/index.tsx
@@ -0,0 +1 @@
+export { OrgMembersSection } from "./OrgMembersSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/index.tsx
new file mode 100644
index 0000000000..eae77c2b3b
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgMembersTab/index.tsx
@@ -0,0 +1 @@
+export { OrgMembersTab } from "./OrgMembersTab";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgRoleTabSection/OrgRoleTabSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgRoleTabSection/OrgRoleTabSection.tsx
new file mode 100644
index 0000000000..8e6c5d591c
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgRoleTabSection/OrgRoleTabSection.tsx
@@ -0,0 +1,17 @@
+import { motion } from "framer-motion";
+
+import { OrgRoleTable } from "./OrgRoleTable";
+
+export const OrgRoleTabSection = () => {
+ return (
+ <motion.div
+ key="role-list"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: -30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <OrgRoleTable />
+ </motion.div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgRoleTabSection/OrgRoleTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgRoleTabSection/OrgRoleTable.tsx
new file mode 100644
index 0000000000..f3d4288b4b
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgRoleTabSection/OrgRoleTable.tsx
@@ -0,0 +1,280 @@
+import { faEllipsis, faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { useNavigate } from "@tanstack/react-router";
+import { twMerge } from "tailwind-merge";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Badge,
+ Button,
+ DeleteActionModal,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tooltip,
+ Tr,
+ UpgradePlanModal
+} from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { isCustomOrgRole } from "@app/helpers/roles";
+import { usePopUp } from "@app/hooks";
+import { useDeleteOrgRole, useGetOrgRoles, useUpdateOrg } from "@app/hooks/api";
+import { TOrgRole } from "@app/hooks/api/roles/types";
+
+import { RoleModal } from "../../../roles/$roleId/-components";
+
+export const OrgRoleTable = () => {
+ const navigate = useNavigate();
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "role",
+ "deleteRole",
+ "upgradePlan"
+ ] as const);
+
+ const { data: roles, isLoading: isRolesLoading } = useGetOrgRoles(orgId);
+ const { mutateAsync: deleteRole } = useDeleteOrgRole();
+ const { mutateAsync: updateOrg } = useUpdateOrg();
+ const { subscription } = useSubscription();
+
+ const handleRoleDelete = async () => {
+ const { id } = popUp?.deleteRole?.data as TOrgRole;
+ try {
+ await deleteRole({
+ orgId,
+ id
+ });
+ createNotification({ type: "success", text: "Successfully removed the role" });
+ handlePopUpClose("deleteRole");
+ } catch (err) {
+ console.log(err);
+ createNotification({ type: "error", text: "Failed to delete role" });
+ }
+ };
+
+ const handleSetRoleAsDefault = async (defaultMembershipRoleSlug: string) => {
+ const isCustomRole = isCustomOrgRole(defaultMembershipRoleSlug);
+
+ if (isCustomRole && subscription && !subscription?.rbac) {
+ handlePopUpOpen("upgradePlan", {
+ description:
+ "You can set the default org role to a custom role if you upgrade your Infisical plan."
+ });
+ return;
+ }
+
+ try {
+ await updateOrg({
+ orgId,
+ defaultMembershipRoleSlug
+ });
+ createNotification({ type: "success", text: "Successfully updated default membership role" });
+ handlePopUpClose("deleteRole");
+ } catch (err) {
+ console.log(err);
+ createNotification({ type: "error", text: "Failed to update default membership role" });
+ }
+ };
+
+ return (
+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="mb-4 flex justify-between">
+ <p className="text-xl font-semibold text-mineshaft-100">Organization Roles</p>
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Role}>
+ {(isAllowed) => (
+ <Button
+ colorSchema="primary"
+ type="submit"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ onClick={() => {
+ handlePopUpOpen("role");
+ }}
+ isDisabled={!isAllowed}
+ >
+ Add Role
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Name</Th>
+ <Th>Slug</Th>
+ <Th aria-label="actions" className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isRolesLoading && <TableSkeleton columns={3} innerKey="org-roles" />}
+ {roles?.map((role) => {
+ const { id, name, slug } = role;
+ const isNonMutatable = ["owner", "admin", "member", "no-access"].includes(slug);
+ const isDefaultOrgRole = isCustomOrgRole(slug)
+ ? id === currentOrg?.defaultMembershipRole
+ : slug === currentOrg?.defaultMembershipRole;
+ return (
+ <Tr
+ key={`role-list-${id}`}
+ className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ onClick={() =>
+ navigate({
+ to: "/organization/$organizationId/roles/$roleId",
+ params: {
+ organizationId: orgId,
+ roleId: id
+ }
+ })
+ }
+ >
+ <Td className="max-w-md">
+ <div className="flex">
+ <p className="overflow-hidden text-ellipsis whitespace-nowrap">{name}</p>
+ {isDefaultOrgRole && (
+ <Tooltip
+ content={`Members joining your organization will be assigned the ${name} role unless otherwise specified.`}
+ >
+ <div>
+ <Badge variant="success" className="ml-1">
+ Default
+ </Badge>
+ </div>
+ </Tooltip>
+ )}
+ </div>
+ </Td>
+ <Td className="max-w-md overflow-hidden text-ellipsis whitespace-nowrap">
+ {slug}
+ </Td>
+ <Td>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <div className="hover:text-primary-400 data-[state=open]:text-primary-400">
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Role}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ navigate({
+ to: "/organization/$organizationId/roles/$roleId",
+ params: {
+ organizationId: orgId,
+ roleId: id
+ }
+ });
+ }}
+ disabled={!isAllowed}
+ >
+ {`${isNonMutatable ? "View" : "Edit"} Role`}
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ {!isDefaultOrgRole && (
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Settings}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ disabled={!isAllowed}
+ onClick={(e) => {
+ e.stopPropagation();
+ handleSetRoleAsDefault(slug);
+ }}
+ >
+ Set as Default Role
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ )}
+ {!isNonMutatable && (
+ <Tooltip
+ position="left"
+ content={
+ isDefaultOrgRole
+ ? "Cannot delete default organization membership role. Re-assign default to allow deletion."
+ : ""
+ }
+ >
+ <div>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Role}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ isAllowed && !isDefaultOrgRole
+ ? "hover:!bg-red-500 hover:!text-white"
+ : "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("deleteRole", role);
+ }}
+ disabled={!isAllowed || isDefaultOrgRole}
+ >
+ Delete Role
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </div>
+ </Tooltip>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </Td>
+ </Tr>
+ );
+ })}
+ </TBody>
+ </Table>
+ </TableContainer>
+ <RoleModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
+ <DeleteActionModal
+ isOpen={popUp.deleteRole.isOpen}
+ title={`Are you sure want to delete ${
+ (popUp?.deleteRole?.data as TOrgRole)?.name || " "
+ } role?`}
+ onChange={(isOpen) => handlePopUpToggle("deleteRole", isOpen)}
+ deleteKey={(popUp?.deleteRole?.data as TOrgRole)?.slug || ""}
+ onClose={() => handlePopUpClose("deleteRole")}
+ onDeleteApproved={handleRoleDelete}
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text={(popUp.upgradePlan?.data as { description: string })?.description}
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgRoleTabSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgRoleTabSection/index.tsx
new file mode 100644
index 0000000000..a78c88bcbb
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/OrgRoleTabSection/index.tsx
@@ -0,0 +1 @@
+export { OrgRoleTabSection } from "./OrgRoleTabSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/index.tsx
new file mode 100644
index 0000000000..f6e98cb5c2
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/-components/index.tsx
@@ -0,0 +1,4 @@
+export { OrgGroupsTab } from "./OrgGroupsTab";
+export { OrgIdentityTab } from "./OrgIdentityTab";
+export { OrgMembersTab } from "./OrgMembersTab";
+export { OrgRoleTabSection } from "./OrgRoleTabSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/index.tsx
new file mode 100644
index 0000000000..920480b14e
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/members/index.tsx
@@ -0,0 +1,102 @@
+/* eslint-disable @typescript-eslint/no-unused-vars */
+import { useEffect, useState } from 'react'
+import { Helmet } from 'react-helmet'
+import { useTranslation } from 'react-i18next'
+import { createFileRoute, useNavigate, useSearch } from '@tanstack/react-router'
+
+import { Tab, TabList, TabPanel, Tabs } from '@app/components/v2'
+import { OrgPermissionActions, OrgPermissionSubjects } from '@app/context'
+import { withPermission } from '@app/hoc'
+import { TabSections } from '@app/types/org'
+
+import {
+ OrgGroupsTab,
+ OrgIdentityTab,
+ OrgMembersTab,
+ OrgRoleTabSection,
+} from './-components'
+
+export const MembersSection = withPermission(
+ () => {
+ const navigate = useNavigate({
+ from: '/_authenticate/_org_details/_org-layout/organization/$organizationId/members',
+ })
+ const search = useSearch({
+ from: '/_authenticate/_org_details/_org-layout/organization/$organizationId/members',
+ })
+ const selectedTab = search.selectedTab as TabSections
+ const [activeTab, setActiveTab] = useState<TabSections>(TabSections.Member)
+
+ useEffect(() => {
+ if (
+ selectedTab &&
+ Object.values(TabSections).includes(selectedTab as TabSections)
+ ) {
+ setActiveTab(selectedTab)
+ }
+ }, [selectedTab])
+
+ const updateSelectedTab = (tab: string) => {
+ navigate({
+ search: { ...search, selectedTab: tab },
+ })
+ }
+
+ return (
+ <div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white">
+ <div className="mx-auto mb-6 w-full max-w-7xl px-6 py-6">
+ <p className="mb-4 mr-4 text-3xl font-semibold text-white">
+ Organization Access Control
+ </p>
+ <Tabs value={activeTab} onValueChange={updateSelectedTab}>
+ <TabList>
+ <Tab value={TabSections.Member}>Users</Tab>
+ <Tab value={TabSections.Groups}>Groups</Tab>
+ <Tab value={TabSections.Identities}>
+ <div className="flex items-center">
+ <p>Machine Identities</p>
+ </div>
+ </Tab>
+ <Tab value={TabSections.Roles}>Organization Roles</Tab>
+ </TabList>
+ <TabPanel value={TabSections.Member}>
+ <OrgMembersTab />
+ </TabPanel>
+ <TabPanel value={TabSections.Groups}>
+ <OrgGroupsTab />
+ </TabPanel>
+ <TabPanel value={TabSections.Identities}>
+ <OrgIdentityTab />
+ </TabPanel>
+ <TabPanel value={TabSections.Roles}>
+ <OrgRoleTabSection />
+ </TabPanel>
+ </Tabs>
+ </div>
+ </div>
+ )
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Member },
+)
+
+const MembersPage = () => {
+ const { t } = useTranslation()
+
+ return (
+ <>
+ <Helmet>
+ <title>
+ {t('common.head-title', { title: t('settings.org.title') })}
+ </title>
+ <link rel="icon" href="/infisical.ico" />
+ </Helmet>
+ <MembersSection />
+ </>
+ )
+}
+
+export const Route = createFileRoute(
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/members/',
+)({
+ component: MembersPage,
+})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserDetailsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserDetailsSection.tsx
new file mode 100644
index 0000000000..b719b8dc44
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserDetailsSection.tsx
@@ -0,0 +1,228 @@
+import {
+ faCheck,
+ faCheckCircle,
+ faCircleXmark,
+ faCopy,
+ faKey,
+ faPencil
+} from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, IconButton, Tag, Tooltip } from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useUser
+} from "@app/context";
+import { useTimedReset } from "@app/hooks";
+import {
+ useAddUsersToOrg,
+ useFetchServerStatus,
+ useGetOrgMembership,
+ useGetOrgRoles
+} from "@app/hooks/api";
+import { OrgUser } from "@app/hooks/api/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+type Props = {
+ membershipId: string;
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["orgMembership"]>, data?: object) => void;
+};
+
+export const UserDetailsSection = ({ membershipId, handlePopUpOpen }: Props) => {
+ const [copyTextUsername, isCopyingUsername, setCopyTextUsername] = useTimedReset<string>({
+ initialState: "Copy username to clipboard"
+ });
+
+ const { user } = useUser();
+ const { currentOrg } = useOrganization();
+ const userId = user?.id || "";
+ const orgId = currentOrg?.id || "";
+
+ const { data: roles } = useGetOrgRoles(orgId);
+ const { data: serverDetails } = useFetchServerStatus();
+ const { data: membership } = useGetOrgMembership(orgId, membershipId);
+ const { mutateAsync: inviteUsers, isLoading } = useAddUsersToOrg();
+
+ const onResendInvite = async (email: string) => {
+ try {
+ const { data } = await inviteUsers({
+ organizationId: orgId,
+ inviteeEmails: [email],
+ organizationRoleSlug: "member"
+ });
+
+ // setCompleteInviteLink(data?.completeInviteLink || "");
+
+ if (!data.completeInviteLinks) {
+ createNotification({
+ text: `Successfully resent invite to ${email}`,
+ type: "success"
+ });
+ }
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: `Failed to resend invite to ${email}`,
+ type: "error"
+ });
+ }
+ };
+
+ const getStatus = (m: OrgUser) => {
+ if (!m.isActive) {
+ return "Deactivated";
+ }
+
+ return m.status === "invited" ? "Invited" : "Active";
+ };
+
+ const roleName = roles?.find((r) => r.slug === membership?.role)?.name;
+
+ return membership ? (
+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <h3 className="text-lg font-semibold text-mineshaft-100">User Details</h3>
+ {userId !== membership.user.id && (
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Identity}>
+ {(isAllowed) => {
+ return (
+ <Tooltip content="Edit Membership">
+ <IconButton
+ isDisabled={!isAllowed}
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={() => {
+ handlePopUpOpen("orgMembership", {
+ membershipId: membership.id,
+ role: membership.role,
+ roleId: membership.roleId,
+ metadata: membership.metadata
+ });
+ }}
+ >
+ <FontAwesomeIcon icon={faPencil} />
+ </IconButton>
+ </Tooltip>
+ );
+ }}
+ </OrgPermissionCan>
+ )}
+ </div>
+ <div className="pt-4">
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Name</p>
+ <p className="text-sm text-mineshaft-300">
+ {membership.user.firstName || membership.user.lastName
+ ? `${membership.user.firstName} ${membership.user.lastName ?? ""}`.trim()
+ : "-"}
+ </p>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Username</p>
+ <div className="group flex align-top">
+ <p className="text-sm text-mineshaft-300">{membership.user.username}</p>
+ <div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
+ <Tooltip content={copyTextUsername}>
+ <IconButton
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative ml-2"
+ onClick={() => {
+ navigator.clipboard.writeText("");
+ setCopyTextUsername("Copied");
+ }}
+ >
+ <FontAwesomeIcon icon={isCopyingUsername ? faCheck : faCopy} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ </div>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Email</p>
+ <div className="flex items-center">
+ <p className="mr-2 text-sm text-mineshaft-300">{membership.user.email ?? "-"}</p>
+ <Tooltip
+ content={
+ membership.user.isEmailVerified
+ ? "Email has been verified"
+ : "Email has not been verified"
+ }
+ >
+ <FontAwesomeIcon
+ size="sm"
+ icon={membership.user.isEmailVerified ? faCheckCircle : faCircleXmark}
+ />
+ </Tooltip>
+ </div>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Organization Role</p>
+ <p className="text-sm text-mineshaft-300">{roleName ?? "-"}</p>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Status</p>
+ <p className="text-sm text-mineshaft-300">{getStatus(membership)}</p>
+ </div>
+ <div>
+ <p className="text-sm font-semibold text-mineshaft-300">Metadata</p>
+ {membership?.metadata?.length ? (
+ <div className="mt-1 flex flex-wrap gap-2 text-sm text-mineshaft-300">
+ {membership.metadata?.map((el) => (
+ <div key={el.id} className="flex items-center">
+ <Tag
+ size="xs"
+ className="mr-0 flex items-center rounded-r-none border border-mineshaft-500"
+ >
+ <FontAwesomeIcon icon={faKey} size="xs" className="mr-1" />
+ <div>{el.key}</div>
+ </Tag>
+ <Tag
+ size="xs"
+ className="flex items-center rounded-l-none border border-mineshaft-500 bg-mineshaft-900 pl-1"
+ >
+ <div className="max-w-[150px] overflow-hidden text-ellipsis whitespace-nowrap">
+ {el.value}
+ </div>
+ </Tag>
+ </div>
+ ))}
+ </div>
+ ) : (
+ <p className="text-sm text-mineshaft-300">-</p>
+ )}
+ </div>
+ {membership.isActive &&
+ (membership.status === "invited" || membership.status === "verified") &&
+ membership.user.email &&
+ serverDetails?.emailConfigured && (
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Identity}>
+ {(isAllowed) => {
+ return (
+ <Button
+ isDisabled={!isAllowed}
+ className="mt-4 w-full"
+ colorSchema="primary"
+ type="submit"
+ isLoading={isLoading}
+ onClick={() => {
+ onResendInvite(membership.user.email as string);
+ }}
+ >
+ Resend Invite
+ </Button>
+ );
+ }}
+ </OrgPermissionCan>
+ )}
+ </div>
+ </div>
+ ) : (
+ <div />
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserOrgMembershipModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserOrgMembershipModal.tsx
new file mode 100644
index 0000000000..581efb4f4f
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserOrgMembershipModal.tsx
@@ -0,0 +1,249 @@
+import { useEffect } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { SingleValue } from "react-select";
+import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FilterableSelect,
+ FormControl,
+ FormLabel,
+ IconButton,
+ Input,
+ Modal,
+ ModalContent
+} from "@app/components/v2";
+import { useOrganization, useSubscription } from "@app/context";
+import { findOrgMembershipRole, isCustomOrgRole } from "@app/helpers/roles";
+import { useGetOrgRoles, useUpdateOrgMembership } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z.object({
+ role: z.object({ name: z.string(), slug: z.string() }),
+ metadata: z
+ .object({
+ key: z.string().trim().min(1),
+ value: z.string().trim().min(1)
+ })
+ .array()
+ .optional()
+});
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ popUp: UsePopUpState<["orgMembership"]>;
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan"]>, data?: object) => void;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["orgMembership"]>, state?: boolean) => void;
+};
+
+export const UserOrgMembershipModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Props) => {
+ const { subscription } = useSubscription();
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+
+ const { data: roles = [] } = useGetOrgRoles(orgId);
+
+ const { mutateAsync: updateOrgMembership } = useUpdateOrgMembership();
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema)
+ });
+
+ const metadataFormFields = useFieldArray({
+ control,
+ name: "metadata"
+ });
+
+ const popUpData = popUp?.orgMembership?.data as {
+ membershipId: string;
+ role: string;
+ roleId?: string;
+ metadata: { key: string; value: string }[];
+ };
+
+ useEffect(() => {
+ if (!roles?.length) return;
+
+ if (popUpData) {
+ reset({
+ role: findOrgMembershipRole(roles, popUpData.roleId ?? popUpData.role),
+ metadata: popUpData.metadata
+ });
+ } else {
+ reset({
+ role: findOrgMembershipRole(roles, currentOrg!.defaultMembershipRole!)
+ });
+ }
+ }, [popUp?.orgMembership?.data, roles]);
+
+ const onFormSubmit = async ({ role, metadata }: FormData) => {
+ try {
+ if (!orgId) return;
+
+ await updateOrgMembership({
+ organizationId: orgId,
+ membershipId: popUpData.membershipId,
+ role: role.slug,
+ metadata
+ });
+
+ handlePopUpToggle("orgMembership", false);
+
+ createNotification({
+ text: "Successfully updated user organization role",
+ type: "success"
+ });
+
+ reset();
+ } catch (err) {
+ console.error(err);
+ const error = err as any;
+ const text = error?.response?.data?.message ?? "Failed to update user organization role";
+
+ createNotification({
+ text,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.orgMembership?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("orgMembership", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent bodyClassName="overflow-visible" title="Update Membership">
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ name="role"
+ render={({ field: { onChange, value }, fieldState: { error } }) => (
+ <FormControl
+ label="Update Organization Role"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <FilterableSelect
+ placeholder="Select role..."
+ options={roles}
+ onChange={(newValue) => {
+ const role = newValue as SingleValue<(typeof roles)[number]>;
+
+ if (!role) return;
+
+ const isCustomRole = isCustomOrgRole(role.slug);
+
+ if (isCustomRole && subscription && !subscription?.rbac) {
+ handlePopUpOpen("upgradePlan", {
+ description:
+ "You can assign custom roles to members if you upgrade your Infisical plan."
+ });
+ return;
+ }
+
+ onChange(role);
+ }}
+ value={value}
+ getOptionValue={(option) => option.slug}
+ getOptionLabel={(option) => option.name}
+ />
+ </FormControl>
+ )}
+ />
+ <div>
+ <FormLabel label="Metadata" />
+ </div>
+ <div className="mb-3 flex flex-col space-y-2">
+ {metadataFormFields.fields.map(({ id: metadataFieldId }, i) => (
+ <div key={metadataFieldId} className="flex items-end space-x-2">
+ <div className="flex-grow">
+ {i === 0 && <span className="text-xs text-mineshaft-400">Key</span>}
+ <Controller
+ control={control}
+ name={`metadata.${i}.key`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="flex-grow">
+ {i === 0 && (
+ <FormLabel label="Value" className="text-xs text-mineshaft-400" isOptional />
+ )}
+ <Controller
+ control={control}
+ name={`metadata.${i}.value`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ </div>
+ <IconButton
+ ariaLabel="delete key"
+ className="bottom-0.5 h-9"
+ variant="outline_bg"
+ onClick={() => metadataFormFields.remove(i)}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ ))}
+ <div className="mt-2 flex justify-end">
+ <Button
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ variant="outline_bg"
+ onClick={() => metadataFormFields.append({ key: "", value: "" })}
+ >
+ Add Key
+ </Button>
+ </div>
+ </div>
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Update
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("orgMembership", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserAddToProjectModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserAddToProjectModal.tsx
new file mode 100644
index 0000000000..713411ec2c
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserAddToProjectModal.tsx
@@ -0,0 +1,145 @@
+import { useMemo } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, Modal, ModalContent, Select, SelectItem } from "@app/components/v2";
+import { useOrganization, useWorkspace } from "@app/context";
+import { useAddUserToWsNonE2EE, useGetOrgMembershipProjectMemberships } from "@app/hooks/api";
+import { ProjectVersion } from "@app/hooks/api/workspace/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z
+ .object({
+ projectId: z.string()
+ })
+ .required();
+
+type FormData = z.infer<typeof schema>;
+
+type Props = {
+ membershipId: string;
+ popUp: UsePopUpState<["addUserToProject"]>;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["addUserToProject"]>,
+ state?: boolean
+ ) => void;
+};
+
+export const UserAddToProjectModal = ({ membershipId, popUp, handlePopUpToggle }: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { workspaces } = useWorkspace();
+
+ const { mutateAsync: addUserToWorkspaceNonE2EE } = useAddUserToWsNonE2EE();
+
+ const popupData = popUp.addUserToProject.data as {
+ username: string;
+ };
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema)
+ });
+
+ const { data: projectMemberships } = useGetOrgMembershipProjectMemberships(orgId, membershipId);
+
+ const filteredWorkspaces = useMemo(() => {
+ const wsWorkspaceIds = new Map();
+
+ projectMemberships?.forEach((projectMembership) => {
+ wsWorkspaceIds.set(projectMembership.project.id, true);
+ });
+
+ return (workspaces || []).filter(
+ ({ id, orgId: projectOrgId, version }) =>
+ !wsWorkspaceIds.has(id) && projectOrgId === currentOrg?.id && version !== ProjectVersion.V1
+ );
+ }, [workspaces, projectMemberships]);
+
+ const onFormSubmit = async ({ projectId }: FormData) => {
+ try {
+ await addUserToWorkspaceNonE2EE({
+ projectId,
+ usernames: [popupData.username],
+ orgId
+ });
+
+ createNotification({
+ text: "Successfully added user to project",
+ type: "success"
+ });
+
+ reset();
+ handlePopUpToggle("addUserToProject", false);
+ } catch (err) {
+ console.error(err);
+ const error = err as any;
+ const text = error?.response?.data?.message ?? "Failed to add identity to project";
+
+ createNotification({
+ text,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.addUserToProject?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addUserToProject", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent title="Add User to Project">
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ name="projectId"
+ defaultValue=""
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl label="Project" errorText={error?.message} isError={Boolean(error)}>
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ className="w-full"
+ >
+ {(filteredWorkspaces || []).map(({ id, name }) => (
+ <SelectItem value={id} key={`project-${id}`}>
+ {name}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Add
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("addUserToProject", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserAuditLogsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserAuditLogsSection.tsx
new file mode 100644
index 0000000000..a5884a9f77
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserAuditLogsSection.tsx
@@ -0,0 +1,54 @@
+import { useState } from "react";
+import { faFilter } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { IconButton, Tooltip } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
+import { withPermission } from "@app/hoc";
+import { OrgUser } from "@app/hooks/api/types";
+
+type Props = {
+ orgMembership: OrgUser;
+};
+
+export const UserAuditLogsSection = withPermission(
+ ({ orgMembership }: Props) => {
+ const [showFilter, setShowFilter] = useState(false);
+ const { subscription } = useSubscription();
+
+ // eslint-disable-next-line no-nested-ternary
+ return (
+ subscription?.auditLogs && (
+ <div className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="mb-4 flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <p className="text-lg font-semibold text-gray-200">Audit Logs</p>
+
+ <Tooltip content="Show audit log filters">
+ <IconButton
+ colorSchema="primary"
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={() => setShowFilter(!showFilter)}
+ >
+ <div className="flex items-center space-x-2">
+ <p>Filter</p>
+ <FontAwesomeIcon icon={faFilter} />
+ </div>
+ </IconButton>
+ </Tooltip>
+ </div>
+ <LogsSection
+ showFilters={showFilter}
+ filterClassName="bg-mineshaft-900 static"
+ presets={{
+ actorId: orgMembership.user.id
+ }}
+ isOrgAuditLogs
+ />
+ </div>
+ )
+ );
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Member }
+);
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserGroupsRow.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserGroupsRow.tsx
new file mode 100644
index 0000000000..5543ac1678
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserGroupsRow.tsx
@@ -0,0 +1,46 @@
+/* eslint-disable react/jsx-no-useless-fragment */
+import { faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { IconButton, Td, Tooltip, Tr } from "@app/components/v2";
+import { TGroupWithProjectMemberships } from "@app/hooks/api/groups/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+type Props = {
+ group: TGroupWithProjectMemberships;
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["removeUserFromGroup"]>, data?: object) => void;
+};
+
+export const UserGroupsRow = ({ group, handlePopUpOpen }: Props) => {
+ return (
+ <>
+ <Tr
+ className="group h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ key={`user-project-membership-${group.id}`}
+ >
+ <Td>{group.name}</Td>
+ <Td>
+ <div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
+ <Tooltip content="Unassign user from group">
+ <IconButton
+ colorSchema="danger"
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("removeUserFromGroup", {
+ groupId: group.id,
+ groupSlug: group.slug
+ });
+ }}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ </Td>
+ </Tr>
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserGroupsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserGroupsSection.tsx
new file mode 100644
index 0000000000..7fc600b2ad
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserGroupsSection.tsx
@@ -0,0 +1,70 @@
+import { useCallback } from "react";
+
+import { createNotification } from "@app/components/notifications";
+import { DeleteActionModal } from "@app/components/v2";
+import { useRemoveUserFromGroup } from "@app/hooks/api";
+import { OrgUser } from "@app/hooks/api/users/types";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { UserGroupsTable } from "./UserGroupsTable";
+
+type Props = {
+ orgMembership: OrgUser;
+};
+
+export const UserGroupsSection = ({ orgMembership }: Props) => {
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "removeUserFromGroup"
+ ] as const);
+
+ const { mutateAsync: removeUserFromGroup } = useRemoveUserFromGroup();
+
+ const handleRemoveUserFromGroup = useCallback(async (groupId: string, groupSlug: string) => {
+ try {
+ await removeUserFromGroup({
+ groupId,
+ slug: groupSlug,
+ username: orgMembership.user.username
+ });
+
+ createNotification({
+ type: "success",
+ text: "User removed from group successfully"
+ });
+
+ handlePopUpClose("removeUserFromGroup");
+ } catch {
+ createNotification({
+ type: "error",
+ text: "Failed to remove user from group"
+ });
+ }
+ }, []);
+
+ return (
+ <>
+ <div className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="mb-4 flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <h3 className="text-lg font-semibold text-mineshaft-100">Groups</h3>
+ </div>
+
+ <UserGroupsTable orgMembership={orgMembership} handlePopUpOpen={handlePopUpOpen} />
+ </div>
+
+ <DeleteActionModal
+ isOpen={popUp.removeUserFromGroup.isOpen}
+ title="Are you sure want to unassign user from group?"
+ onChange={(isOpen) => handlePopUpToggle("removeUserFromGroup", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() => {
+ const popupData = popUp?.removeUserFromGroup?.data as {
+ groupId: string;
+ groupSlug: string;
+ };
+
+ return handleRemoveUserFromGroup(popupData.groupId, popupData.groupSlug);
+ }}
+ />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserGroupsTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserGroupsTable.tsx
new file mode 100644
index 0000000000..7263fb5a7d
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserGroupsTable.tsx
@@ -0,0 +1,138 @@
+import { useMemo } from "react";
+import {
+ faArrowDown,
+ faArrowUp,
+ faMagnifyingGlass,
+ faSearch,
+ faUser
+} from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import {
+ EmptyState,
+ IconButton,
+ Input,
+ Pagination,
+ Table,
+ TableContainer,
+ TBody,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { usePagination, useResetPageHelper } from "@app/hooks";
+import { OrderByDirection } from "@app/hooks/api/generic/types";
+import { OrgUser } from "@app/hooks/api/types";
+import { useListUserGroupMemberships } from "@app/hooks/api/users/queries";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+import { UserGroupsRow } from "./UserGroupsRow";
+
+type Props = {
+ orgMembership: OrgUser;
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["removeUserFromGroup"]>, data?: object) => void;
+};
+
+enum UserGroupsOrderBy {
+ Name = "name"
+}
+
+export const UserGroupsTable = ({ handlePopUpOpen, orgMembership }: Props) => {
+ const { data: groupMemberships = [], isLoading } = useListUserGroupMemberships(
+ orgMembership.user.username
+ );
+
+ const {
+ search,
+ setSearch,
+ setPage,
+ page,
+ perPage,
+ setPerPage,
+ offset,
+ orderDirection,
+ toggleOrderDirection
+ } = usePagination(UserGroupsOrderBy.Name, { initPerPage: 10 });
+
+ const filteredGroupMemberships = useMemo(
+ () =>
+ groupMemberships
+ .filter((group) => group.name.toLowerCase().includes(search.trim().toLowerCase()))
+ .sort((a, b) => {
+ const [membershipOne, membershipTwo] =
+ orderDirection === OrderByDirection.ASC ? [a, b] : [b, a];
+
+ return membershipOne.name.toLowerCase().localeCompare(membershipTwo.name.toLowerCase());
+ }),
+ [groupMemberships, orderDirection, search]
+ );
+
+ useResetPageHelper({
+ totalCount: filteredGroupMemberships.length,
+ offset,
+ setPage
+ });
+
+ return (
+ <div>
+ <Input
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search groups..."
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="w-full">
+ <div className="flex items-center">
+ Name
+ <IconButton
+ variant="plain"
+ className="ml-2"
+ ariaLabel="sort"
+ onClick={toggleOrderDirection}
+ >
+ <FontAwesomeIcon
+ icon={orderDirection === OrderByDirection.DESC ? faArrowUp : faArrowDown}
+ />
+ </IconButton>
+ </div>
+ </Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {filteredGroupMemberships.slice(offset, perPage * page).map((group) => (
+ <UserGroupsRow
+ key={`user-group-${group.id}`}
+ group={group}
+ handlePopUpOpen={handlePopUpOpen}
+ />
+ ))}
+ </TBody>
+ </Table>
+ {Boolean(filteredGroupMemberships.length) && (
+ <Pagination
+ count={filteredGroupMemberships.length}
+ page={page}
+ perPage={perPage}
+ onChangePage={setPage}
+ onChangePerPage={setPerPage}
+ />
+ )}
+ {!isLoading && !filteredGroupMemberships?.length && (
+ <EmptyState
+ title={
+ groupMemberships.length
+ ? "No groups match search..."
+ : "This user has not been assigned to any groups"
+ }
+ icon={groupMemberships.length ? faSearch : faUser}
+ />
+ )}
+ </TableContainer>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserProjectRow.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserProjectRow.tsx
new file mode 100644
index 0000000000..7eba6af933
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserProjectRow.tsx
@@ -0,0 +1,105 @@
+import { useMemo } from "react";
+import { faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { IconButton, Tag, Td, Tooltip, Tr } from "@app/components/v2";
+import { useWorkspace } from "@app/context";
+import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
+import { TWorkspaceUser } from "@app/hooks/api/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+import { useNavigate } from "@tanstack/react-router";
+import { TabSections } from "@app/types/org";
+
+type Props = {
+ membership: TWorkspaceUser;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["removeUserFromProject"]>,
+ data?: object
+ ) => void;
+};
+
+const formatRoleName = (role: string, customRoleName?: string) => {
+ if (role === ProjectMembershipRole.Custom) return customRoleName;
+ if (role === ProjectMembershipRole.Admin) return "Admin";
+ if (role === ProjectMembershipRole.Member) return "Developer";
+ if (role === ProjectMembershipRole.Viewer) return "Viewer";
+ if (role === ProjectMembershipRole.NoAccess) return "No Access";
+ return role;
+};
+
+export const UserProjectRow = ({
+ membership: { id, project, user, roles },
+ handlePopUpOpen
+}: Props) => {
+ const { workspaces } = useWorkspace();
+ const navigate = useNavigate();
+
+ const isAccessible = useMemo(() => {
+ const workspaceIds = new Map();
+
+ workspaces?.forEach((workspace) => {
+ workspaceIds.set(workspace.id, true);
+ });
+
+ return workspaceIds.has(project.id);
+ }, [workspaces, project]);
+
+ return (
+ <Tr
+ className="group h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ key={`user-project-membership-${id}`}
+ onClick={() => {
+ if (isAccessible) {
+ navigate({
+ to: `/${project.type}/$projectId/members` as const,
+ params: {
+ projectId: project.id
+ },
+ search: {
+ selectedTab: TabSections.Member
+ }
+ });
+ return;
+ }
+
+ createNotification({
+ text: "Unable to access project",
+ type: "error"
+ });
+ }}
+ >
+ <Td className="max-w-0 truncate">{project.name}</Td>
+ <Td>
+ <Tag size="xs">{project.type}</Tag>
+ </Td>
+ <Td>{`${formatRoleName(roles[0].role, roles[0].customRoleName)}${
+ roles.length > 1 ? ` (+${roles.length - 1})` : ""
+ }`}</Td>
+ <Td>
+ {isAccessible && (
+ <div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
+ <Tooltip content="Remove">
+ <IconButton
+ colorSchema="danger"
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("removeUserFromProject", {
+ username: user.username,
+ projectId: project.id,
+ projectName: project.name
+ });
+ }}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ )}
+ </Td>
+ </Tr>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserProjectsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserProjectsSection.tsx
new file mode 100644
index 0000000000..c93e1fa8be
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserProjectsSection.tsx
@@ -0,0 +1,98 @@
+import { faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { DeleteActionModal, IconButton } from "@app/components/v2";
+import { useOrganization, useUser } from "@app/context";
+import { useDeleteUserFromWorkspace, useGetOrgMembership } from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { UserAddToProjectModal } from "./UserAddToProjectModal";
+import { UserProjectsTable } from "./UserProjectsTable";
+
+type Props = {
+ membershipId: string;
+};
+
+export const UserProjectsSection = ({ membershipId }: Props) => {
+ const { user } = useUser();
+ const { currentOrg } = useOrganization();
+
+ const userId = user?.id || "";
+ const orgId = currentOrg?.id || "";
+
+ const { data: membership } = useGetOrgMembership(orgId, membershipId);
+
+ const { mutateAsync: removeUserFromWorkspace } = useDeleteUserFromWorkspace();
+
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "addUserToProject",
+ "removeUserFromProject"
+ ] as const);
+
+ const handleRemoveUser = async (projectId: string, username: string) => {
+ try {
+ await removeUserFromWorkspace({ workspaceId: projectId, usernames: [username], orgId });
+ createNotification({
+ text: "Successfully removed user from project",
+ type: "success"
+ });
+ } catch (error) {
+ console.error(error);
+ createNotification({
+ text: "Failed to remove user from the project",
+ type: "error"
+ });
+ }
+ handlePopUpClose("removeUserFromProject");
+ };
+
+ return membership ? (
+ <div className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <h3 className="text-lg font-semibold text-mineshaft-100">Projects</h3>
+ {userId !== membership.user.id && membership.status !== "invited" && (
+ <IconButton
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={() => {
+ handlePopUpOpen("addUserToProject", {
+ username: membership.user.username
+ });
+ }}
+ >
+ <FontAwesomeIcon icon={faPlus} />
+ </IconButton>
+ )}
+ </div>
+ <div className="py-4">
+ <UserProjectsTable membershipId={membershipId} handlePopUpOpen={handlePopUpOpen} />
+ </div>
+ <UserAddToProjectModal
+ membershipId={membershipId}
+ popUp={popUp}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <DeleteActionModal
+ isOpen={popUp.removeUserFromProject.isOpen}
+ deleteKey="remove"
+ title={`Do you want to remove this user from ${
+ (popUp?.removeUserFromProject?.data as { projectName: string })?.projectName || ""
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle("removeUserFromProject", isOpen)}
+ onDeleteApproved={() => {
+ const popupData = popUp?.removeUserFromProject?.data as {
+ username: string;
+ projectId: string;
+ projectName: string;
+ };
+
+ return handleRemoveUser(popupData.projectId, popupData.username);
+ }}
+ />
+ </div>
+ ) : (
+ <div />
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserProjectsTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserProjectsTable.tsx
new file mode 100644
index 0000000000..16c0a03b3f
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/UserProjectsTable.tsx
@@ -0,0 +1,155 @@
+import { useMemo } from "react";
+import {
+ faArrowDown,
+ faArrowUp,
+ faFolder,
+ faMagnifyingGlass,
+ faSearch
+} from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import {
+ EmptyState,
+ IconButton,
+ Input,
+ Pagination,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { usePagination, useResetPageHelper } from "@app/hooks";
+import { useGetOrgMembershipProjectMemberships } from "@app/hooks/api";
+import { OrderByDirection } from "@app/hooks/api/generic/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+import { UserProjectRow } from "./UserProjectRow";
+
+type Props = {
+ membershipId: string;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["removeUserFromProject"]>,
+ data?: object
+ ) => void;
+};
+
+enum UserProjectsOrderBy {
+ Name = "Name"
+}
+
+export const UserProjectsTable = ({ membershipId, handlePopUpOpen }: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const {
+ search,
+ setSearch,
+ setPage,
+ page,
+ perPage,
+ setPerPage,
+ offset,
+ orderDirection,
+ toggleOrderDirection
+ } = usePagination(UserProjectsOrderBy.Name, { initPerPage: 10 });
+
+ const { data: projectMemberships = [], isLoading } = useGetOrgMembershipProjectMemberships(
+ orgId,
+ membershipId
+ );
+
+ const filteredProjectMemberships = useMemo(
+ () =>
+ projectMemberships
+ ?.filter((membership) =>
+ membership.project.name.toLowerCase().includes(search.trim().toLowerCase())
+ )
+ .sort((a, b) => {
+ const [membershipOne, membershipTwo] =
+ orderDirection === OrderByDirection.ASC ? [a, b] : [b, a];
+
+ return membershipOne.project.name
+ .toLowerCase()
+ .localeCompare(membershipTwo.project.name.toLowerCase());
+ }),
+ [projectMemberships, orderDirection, search]
+ );
+
+ useResetPageHelper({
+ totalCount: filteredProjectMemberships.length,
+ offset,
+ setPage
+ });
+
+ return (
+ <div>
+ <Input
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search projects..."
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="w-2/3">
+ <div className="flex items-center">
+ Name
+ <IconButton
+ variant="plain"
+ className="ml-2"
+ ariaLabel="sort"
+ onClick={toggleOrderDirection}
+ >
+ <FontAwesomeIcon
+ icon={orderDirection === OrderByDirection.DESC ? faArrowUp : faArrowDown}
+ />
+ </IconButton>
+ </div>
+ </Th>
+ <Th>Type</Th>
+ <Th>Role</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={3} innerKey="user-project-memberships" />}
+ {!isLoading &&
+ filteredProjectMemberships.slice(offset, perPage * page).map((membership) => {
+ return (
+ <UserProjectRow
+ key={`user-project-membership-${membership.id}`}
+ membership={membership}
+ handlePopUpOpen={handlePopUpOpen}
+ />
+ );
+ })}
+ </TBody>
+ </Table>
+ {Boolean(filteredProjectMemberships.length) && (
+ <Pagination
+ count={filteredProjectMemberships.length}
+ page={page}
+ perPage={perPage}
+ onChangePage={setPage}
+ onChangePerPage={setPerPage}
+ />
+ )}
+ {!isLoading && !filteredProjectMemberships?.length && (
+ <EmptyState
+ title={
+ projectMemberships.length
+ ? "No projects match search..."
+ : "This user has not been assigned to any projects"
+ }
+ icon={projectMemberships.length ? faSearch : faFolder}
+ />
+ )}
+ </TableContainer>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/index.tsx
new file mode 100644
index 0000000000..b298679d5d
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/UserProjectsSection/index.tsx
@@ -0,0 +1 @@
+export { UserProjectsSection } from "./UserProjectsSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/index.tsx
new file mode 100644
index 0000000000..6b13786d49
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/-components/index.tsx
@@ -0,0 +1,3 @@
+export { UserDetailsSection } from "./UserDetailsSection";
+export { UserOrgMembershipModal } from "./UserOrgMembershipModal";
+export { UserProjectsSection } from "./UserProjectsSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/index.tsx
new file mode 100644
index 0000000000..93ab8ccad5
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/memberships/$membershipId/index.tsx
@@ -0,0 +1,338 @@
+import { Helmet } from "react-helmet";
+import { useTranslation } from "react-i18next";
+import { faChevronLeft, faEllipsis } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { createFileRoute, useNavigate, useParams } from "@tanstack/react-router";
+import { twMerge } from "tailwind-merge";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ DeleteActionModal,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ Tooltip,
+ UpgradePlanModal
+} from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useUser
+} from "@app/context";
+import { withPermission } from "@app/hoc";
+import {
+ useDeleteOrgMembership,
+ useGetOrgMembership,
+ useUpdateOrgMembership
+} from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+import { TabSections } from "@app/types/org";
+
+import { UserAuditLogsSection } from "./-components/UserProjectsSection/UserAuditLogsSection";
+import { UserGroupsSection } from "./-components/UserProjectsSection/UserGroupsSection";
+import { UserDetailsSection, UserOrgMembershipModal, UserProjectsSection } from "./-components";
+
+export const OrgUserPage = withPermission(
+ () => {
+ const navigate = useNavigate();
+ const search = useParams({
+ from: "/_authenticate/_org_details/_org-layout/organization/$organizationId/memberships/$membershipId/"
+ });
+ const membershipId = search.membershipId as string;
+ const { user } = useUser();
+ const { currentOrg } = useOrganization();
+
+ const userId = user?.id || "";
+ const orgId = currentOrg?.id || "";
+
+ const { data: membership } = useGetOrgMembership(orgId, membershipId);
+
+ const { mutateAsync: deleteOrgMembership } = useDeleteOrgMembership();
+ const { mutateAsync: updateOrgMembership } = useUpdateOrgMembership();
+
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "removeMember",
+ "orgMembership",
+ "deactivateMember",
+ "upgradePlan"
+ ] as const);
+
+ const onDeactivateMemberSubmit = async (orgMembershipId: string) => {
+ try {
+ await updateOrgMembership({
+ organizationId: orgId,
+ membershipId: orgMembershipId,
+ isActive: false
+ });
+
+ createNotification({
+ text: "Successfully deactivated user in organization",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to deactivate user in organization",
+ type: "error"
+ });
+ }
+
+ handlePopUpClose("deactivateMember");
+ };
+
+ const onRemoveMemberSubmit = async (orgMembershipId: string) => {
+ try {
+ await deleteOrgMembership({
+ orgId,
+ membershipId: orgMembershipId
+ });
+
+ createNotification({
+ text: "Successfully removed user from org",
+ type: "success"
+ });
+
+ handlePopUpClose("removeMember");
+ navigate({
+ to: "/organization/$organizationId/members" as const,
+ params: {
+ organizationId: currentOrg.id
+ },
+ search: {
+ selectedTab: TabSections.Member
+ }
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to remove user from the organization",
+ type: "error"
+ });
+ }
+
+ handlePopUpClose("removeMember");
+ };
+
+ return (
+ <div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white">
+ {membership && (
+ <div className="mx-auto mb-6 w-full max-w-7xl px-6 py-6">
+ <Button
+ variant="link"
+ type="submit"
+ leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
+ onClick={() => {
+ navigate({
+ to: "/organization/$organizationId/members" as const,
+ params: {
+ organizationId: currentOrg.id
+ },
+ search: {
+ selectedTab: TabSections.Member
+ }
+ });
+ }}
+ className="mb-4"
+ >
+ Users
+ </Button>
+ <div className="mb-4 flex items-center justify-between">
+ <p className="text-3xl font-semibold text-white">
+ {membership.user.firstName || membership.user.lastName
+ ? `${membership.user.firstName} ${membership.user.lastName ?? ""}`.trim()
+ : "-"}
+ </p>
+ {userId !== membership.user.id && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <div className="hover:text-primary-400 data-[state=open]:text-primary-400">
+ <Tooltip content="More options">
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </Tooltip>
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Identity}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={() =>
+ handlePopUpOpen("orgMembership", {
+ membershipId: membership.id,
+ role: membership.role,
+ roleId: membership.roleId
+ })
+ }
+ disabled={!isAllowed}
+ >
+ Edit User
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Member}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={
+ membership.isActive
+ ? twMerge(
+ isAllowed
+ ? "hover:!bg-red-500 hover:!text-white"
+ : "pointer-events-none cursor-not-allowed opacity-50"
+ )
+ : ""
+ }
+ onClick={async () => {
+ if (currentOrg?.scimEnabled) {
+ createNotification({
+ text: "You cannot manage users from Infisical when SCIM is enabled for your organization",
+ type: "error"
+ });
+ return;
+ }
+
+ if (!membership.isActive) {
+ // activate user
+ await updateOrgMembership({
+ organizationId: orgId,
+ membershipId,
+ isActive: true
+ });
+
+ return;
+ }
+
+ // deactivate user
+ handlePopUpOpen("deactivateMember", {
+ orgMembershipId: membershipId,
+ username: membership.user.username
+ });
+ }}
+ disabled={!isAllowed}
+ >
+ {`${membership.isActive ? "Deactivate" : "Activate"} User`}
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Member}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ isAllowed
+ ? "hover:!bg-red-500 hover:!text-white"
+ : "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={() => {
+ if (currentOrg?.scimEnabled) {
+ createNotification({
+ text: "You cannot manage users from Infisical when SCIM is enabled for your organization",
+ type: "error"
+ });
+ return;
+ }
+
+ handlePopUpOpen("removeMember", {
+ orgMembershipId: membershipId,
+ username: membership.user.username
+ });
+ }}
+ disabled={!isAllowed}
+ >
+ Remove User
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </div>
+ <div className="flex">
+ <div className="mr-4 w-96">
+ <UserDetailsSection membershipId={membershipId} handlePopUpOpen={handlePopUpOpen} />
+ </div>
+ <div className="w-full space-y-2">
+ <div className="w-full space-y-4">
+ <UserProjectsSection membershipId={membershipId} />
+ <UserGroupsSection orgMembership={membership} />
+ <UserAuditLogsSection orgMembership={membership} />
+ </div>
+ </div>
+ </div>
+ </div>
+ )}
+ <DeleteActionModal
+ isOpen={popUp.removeMember.isOpen}
+ title={`Are you sure want to remove member with username ${
+ (popUp?.removeMember?.data as { username: string })?.username || ""
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() =>
+ onRemoveMemberSubmit(
+ (popUp?.removeMember?.data as { orgMembershipId: string })?.orgMembershipId
+ )
+ }
+ />
+ <DeleteActionModal
+ isOpen={popUp.deactivateMember.isOpen}
+ title={`Are you sure want to deactivate member with username ${
+ (popUp?.deactivateMember?.data as { username: string })?.username || ""
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle("deactivateMember", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() =>
+ onDeactivateMemberSubmit(
+ (popUp?.deactivateMember?.data as { orgMembershipId: string })?.orgMembershipId
+ )
+ }
+ buttonText="Deactivate"
+ />
+
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text={(popUp.upgradePlan?.data as { description: string })?.description}
+ />
+ <UserOrgMembershipModal
+ popUp={popUp}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ </div>
+ );
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Member }
+);
+
+export default function OrgUserRoute() {
+ const { t } = useTranslation();
+ return (
+ <>
+ <Helmet>
+ <title>{t("common.head-title", { title: t("settings.org.title") })}</title>
+ <link rel="icon" href="/infisical.ico" />
+ </Helmet>
+ <OrgUserPage />
+ </>
+ );
+}
+
+export const Route = createFileRoute(
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/memberships/$membershipId/"
+)({
+ component: OrgUserRoute
+});
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/overview/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/overview/index.tsx
new file mode 100644
index 0000000000..2d60819bc6
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/overview/index.tsx
@@ -0,0 +1,15 @@
+import { ProjectType } from '@app/hooks/api/workspace/types'
+import { createFileRoute, redirect } from '@tanstack/react-router'
+
+export const Route = createFileRoute(
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/overview/',
+)({
+ beforeLoad: ({ context }) => {
+ throw redirect({
+ to: `/organization/$organizationId/${ProjectType.SecretManager}` as const,
+ params: {
+ organizationId: context.organizationId,
+ },
+ })
+ },
+})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/OrgRoleModifySection.utils.ts b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/OrgRoleModifySection.utils.ts
new file mode 100644
index 0000000000..aa8c4d7ec0
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/OrgRoleModifySection.utils.ts
@@ -0,0 +1,84 @@
+/* eslint-disable no-param-reassign */
+import { z } from "zod";
+
+import { OrgPermissionSubjects } from "@app/context";
+import { TPermission } from "@app/hooks/api/roles/types";
+
+const generalPermissionSchema = z
+ .object({
+ read: z.boolean().optional(),
+ edit: z.boolean().optional(),
+ delete: z.boolean().optional(),
+ create: z.boolean().optional()
+ })
+ .optional();
+
+const adminConsolePermissionSchmea = z
+ .object({
+ "access-all-projects": z.boolean().optional()
+ })
+ .optional();
+
+export const formSchema = z.object({
+ name: z.string().trim(),
+ description: z.string().trim().optional(),
+ slug: z
+ .string()
+ .trim()
+ .refine((val) => val !== "custom", { message: "Cannot use custom as its a keyword" }),
+ permissions: z
+ .object({
+ workspace: z
+ .object({
+ create: z.boolean().optional()
+ })
+ .optional(),
+
+ "audit-logs": generalPermissionSchema,
+ member: generalPermissionSchema,
+ groups: generalPermissionSchema,
+ role: generalPermissionSchema,
+ settings: generalPermissionSchema,
+ "service-account": generalPermissionSchema,
+ "incident-contact": generalPermissionSchema,
+ "secret-scanning": generalPermissionSchema,
+ sso: generalPermissionSchema,
+ scim: generalPermissionSchema,
+ ldap: generalPermissionSchema,
+ billing: generalPermissionSchema,
+ identity: generalPermissionSchema,
+ "organization-admin-console": adminConsolePermissionSchmea,
+ [OrgPermissionSubjects.Kms]: generalPermissionSchema,
+ [OrgPermissionSubjects.ProjectTemplates]: generalPermissionSchema
+ })
+ .optional()
+});
+
+export type TFormSchema = z.infer<typeof formSchema>;
+
+// convert role permission to form compatiable data structure
+export const rolePermission2Form = (permissions: TPermission[] = []) => {
+ // any because if it set it as form type due to the discriminated union type of ts
+ // i would have to write a if loop with both conditions same
+ const formVal: Record<string, any> = {};
+ permissions.forEach((permission) => {
+ const { subject, action } = permission;
+ if (!formVal?.[subject]) formVal[subject] = {};
+ formVal[subject][action] = true;
+ });
+
+ return formVal;
+};
+
+export const formRolePermission2API = (formVal: TFormSchema["permissions"]) => {
+ const permissions: TPermission[] = [];
+ Object.entries(formVal || {}).forEach(([rule, actions]) => {
+ Object.entries(actions).forEach(([action, isAllowed]) => {
+ if (isAllowed) {
+ permissions.push({ subject: rule, action });
+ }
+ });
+ });
+
+ return permissions;
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RoleDetailsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RoleDetailsSection.tsx
new file mode 100644
index 0000000000..ee93ccfba7
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RoleDetailsSection.tsx
@@ -0,0 +1,95 @@
+import { faCheck, faCopy, faPencil } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { IconButton, Tooltip } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { useTimedReset } from "@app/hooks";
+import { useGetOrgRole } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+type Props = {
+ roleId: string;
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["role"]>, data?: object) => void;
+};
+
+export const RoleDetailsSection = ({ roleId, handlePopUpOpen }: Props) => {
+ const [copyTextId, isCopyingId, setCopyTextId] = useTimedReset<string>({
+ initialState: "Copy ID to clipboard"
+ });
+
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { data } = useGetOrgRole(orgId, roleId);
+ const isCustomRole = !["admin", "member", "no-access"].includes(data?.slug ?? "");
+
+ return data ? (
+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <h3 className="text-lg font-semibold text-mineshaft-100">Org Role Details</h3>
+ {isCustomRole && (
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Role}>
+ {(isAllowed) => {
+ return (
+ <Tooltip content="Edit Role">
+ <IconButton
+ isDisabled={!isAllowed}
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative"
+ onClick={() =>
+ handlePopUpOpen("role", {
+ roleId
+ })
+ }
+ >
+ <FontAwesomeIcon icon={faPencil} />
+ </IconButton>
+ </Tooltip>
+ );
+ }}
+ </OrgPermissionCan>
+ )}
+ </div>
+ <div className="pt-4">
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Role ID</p>
+ <div className="group flex align-top">
+ <p className="text-sm text-mineshaft-300">{roleId}</p>
+ <div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
+ <Tooltip content={copyTextId}>
+ <IconButton
+ ariaLabel="copy icon"
+ variant="plain"
+ className="group relative ml-2"
+ onClick={() => {
+ navigator.clipboard.writeText(roleId);
+ setCopyTextId("Copied");
+ }}
+ >
+ <FontAwesomeIcon icon={isCopyingId ? faCheck : faCopy} />
+ </IconButton>
+ </Tooltip>
+ </div>
+ </div>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Name</p>
+ <p className="text-sm text-mineshaft-300">{data.name}</p>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Slug</p>
+ <p className="text-sm text-mineshaft-300">{data.slug}</p>
+ </div>
+ <div className="mb-4">
+ <p className="text-sm font-semibold text-mineshaft-300">Description</p>
+ <p className="text-sm text-mineshaft-300">
+ {data.description?.length ? data.description : "-"}
+ </p>
+ </div>
+ </div>
+ </div>
+ ) : (
+ <div />
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RoleModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RoleModal.tsx
new file mode 100644
index 0000000000..874f36d665
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RoleModal.tsx
@@ -0,0 +1,207 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useCreateOrgRole, useGetOrgRole, useUpdateOrgRole } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+import { slugSchema } from "@app/lib/schemas";
+import { useNavigate } from "@tanstack/react-router";
+
+const schema = z
+ .object({
+ name: z.string(),
+ description: z.string(),
+ slug: slugSchema({ min: 1 })
+ })
+ .required();
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ popUp: UsePopUpState<["role"]>;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["role"]>, state?: boolean) => void;
+};
+
+export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
+ const navigate = useNavigate();
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+
+ const popupData = popUp?.role?.data as {
+ roleId: string;
+ };
+
+ const { data: role } = useGetOrgRole(orgId, popupData?.roleId ?? "");
+
+ const { mutateAsync: createOrgRole } = useCreateOrgRole();
+ const { mutateAsync: updateOrgRole } = useUpdateOrgRole();
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ name: "",
+ description: ""
+ }
+ });
+
+ useEffect(() => {
+ if (role) {
+ reset({
+ name: role.name,
+ description: role.description,
+ slug: role.slug
+ });
+ } else {
+ reset({
+ name: "",
+ description: "",
+ slug: ""
+ });
+ }
+ }, [role]);
+
+ const onFormSubmit = async ({ name, description, slug }: FormData) => {
+ try {
+ console.log("onFormSubmit args: ", {
+ name,
+ description,
+ slug
+ });
+
+ if (!orgId) return;
+
+ if (role) {
+ // update
+
+ await updateOrgRole({
+ orgId,
+ id: role.id,
+ name,
+ description,
+ slug
+ });
+
+ handlePopUpToggle("role", false);
+ } else {
+ // create
+
+ const newRole = await createOrgRole({
+ orgId,
+ name,
+ description,
+ slug,
+ permissions: []
+ });
+
+ handlePopUpToggle("role", false);
+ navigate({
+ to: "/organization/$organizationId/roles/roleId",
+ params: {
+ organizationId: orgId,
+ roleId: newRole.id
+ }
+ });
+ }
+
+ createNotification({
+ text: `Successfully ${popUp?.role?.data ? "updated" : "created"} role`,
+ type: "success"
+ });
+
+ reset();
+ } catch (err) {
+ console.error(err);
+ const error = err as any;
+ const text =
+ error?.response?.data?.message ??
+ `Failed to ${popUp?.role?.data ? "update" : "create"} role`;
+
+ createNotification({
+ text,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.role?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("role", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent title={`${popUp?.role?.data ? "Update" : "Create"} Role`}>
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Name"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ isRequired
+ >
+ <Input {...field} placeholder="Billing Team" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="slug"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Slug"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ isRequired
+ >
+ <Input {...field} placeholder="billing" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="description"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Description" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} placeholder="To manage billing" />
+ </FormControl>
+ )}
+ />
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {popUp?.role?.data ? "Update" : "Create"}
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("role", false)}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/OrgPermissionAdminConsoleRow.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/OrgPermissionAdminConsoleRow.tsx
new file mode 100644
index 0000000000..2c2ac5dce5
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/OrgPermissionAdminConsoleRow.tsx
@@ -0,0 +1,136 @@
+import { useEffect, useMemo } from "react";
+import { Control, Controller, UseFormSetValue, useWatch } from "react-hook-form";
+import { faChevronDown, faChevronRight } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { Checkbox, Select, SelectItem, Td, Tr } from "@app/components/v2";
+import { useToggle } from "@app/hooks";
+
+import { TFormSchema } from "../OrgRoleModifySection.utils";
+
+type Props = {
+ isEditable: boolean;
+ setValue: UseFormSetValue<TFormSchema>;
+ control: Control<TFormSchema>;
+};
+
+enum Permission {
+ NoAccess = "no-access",
+ Custom = "custom"
+}
+
+const PERMISSION_ACTIONS = [
+ { action: "access-all-projects", label: "Access all organization projects" }
+] as const;
+
+export const OrgPermissionAdminConsoleRow = ({ isEditable, control, setValue }: Props) => {
+ const [isRowExpanded, setIsRowExpanded] = useToggle();
+ const [isCustom, setIsCustom] = useToggle();
+
+ const rule = useWatch({
+ control,
+ name: "permissions.organization-admin-console"
+ });
+
+ const selectedPermissionCategory = useMemo(() => {
+ if (rule?.["access-all-projects"]) {
+ return Permission.Custom;
+ }
+ return Permission.NoAccess;
+ }, [rule, isCustom]);
+
+ useEffect(() => {
+ if (selectedPermissionCategory === Permission.Custom) setIsCustom.on();
+ else setIsCustom.off();
+ }, [selectedPermissionCategory]);
+
+ useEffect(() => {
+ const isRowCustom = selectedPermissionCategory === Permission.Custom;
+ if (isRowCustom) {
+ setIsRowExpanded.on();
+ }
+ }, []);
+
+ const handlePermissionChange = (val: Permission) => {
+ if (!val) return;
+ if (val === Permission.Custom) {
+ setIsRowExpanded.on();
+ setIsCustom.on();
+ return;
+ }
+ setIsCustom.off();
+
+ if (val === Permission.NoAccess) {
+ setValue(
+ "permissions.organization-admin-console",
+ { "access-all-projects": false },
+ { shouldDirty: true }
+ );
+ }
+ };
+
+ return (
+ <>
+ <Tr
+ className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ onClick={() => setIsRowExpanded.toggle()}
+ >
+ <Td>
+ <FontAwesomeIcon icon={isRowExpanded ? faChevronDown : faChevronRight} />
+ </Td>
+ <Td>Organization Admin Console</Td>
+ <Td>
+ <Select
+ value={selectedPermissionCategory}
+ className="w-40 bg-mineshaft-600"
+ dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
+ onValueChange={handlePermissionChange}
+ isDisabled={!isEditable}
+ >
+ <SelectItem value={Permission.NoAccess}>No Access</SelectItem>
+ <SelectItem value={Permission.Custom}>Custom</SelectItem>
+ </Select>
+ </Td>
+ </Tr>
+ {isRowExpanded && (
+ <Tr>
+ <Td
+ colSpan={3}
+ className={`bg-bunker-600 px-0 py-0 ${isRowExpanded && "border-mineshaft-500 p-8"}`}
+ >
+ <div className="grid grid-cols-3 gap-4">
+ {PERMISSION_ACTIONS.map(({ action, label }) => {
+ return (
+ <Controller
+ name={`permissions.organization-admin-console.${action}`}
+ key={`permissions.organization-admin-console.${action}`}
+ control={control}
+ render={({ field }) => (
+ <Checkbox
+ isChecked={field.value}
+ onCheckedChange={(e) => {
+ if (!isEditable) {
+ createNotification({
+ type: "error",
+ text: "Failed to update default role"
+ });
+ return;
+ }
+ field.onChange(e);
+ }}
+ id={`permissions.organization-admin-console.${action}`}
+ >
+ {label}
+ </Checkbox>
+ )}
+ />
+ );
+ })}
+ </div>
+ </Td>
+ </Tr>
+ )}
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/OrgRoleWorkspaceRow.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/OrgRoleWorkspaceRow.tsx
new file mode 100644
index 0000000000..e7986cebdf
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/OrgRoleWorkspaceRow.tsx
@@ -0,0 +1,130 @@
+import { useEffect, useMemo } from "react";
+import { Control, Controller, UseFormSetValue, useWatch } from "react-hook-form";
+import { faChevronDown, faChevronRight } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { Checkbox, Select, SelectItem, Td, Tr } from "@app/components/v2";
+import { useToggle } from "@app/hooks";
+
+import { TFormSchema } from "../OrgRoleModifySection.utils";
+
+type Props = {
+ isEditable: boolean;
+ setValue: UseFormSetValue<TFormSchema>;
+ control: Control<TFormSchema>;
+};
+
+enum Permission {
+ NoAccess = "no-access",
+ Custom = "custom"
+}
+
+const PERMISSION_ACTIONS = [{ action: "create", label: "Create projects" }] as const;
+
+export const OrgRoleWorkspaceRow = ({ isEditable, control, setValue }: Props) => {
+ const [isRowExpanded, setIsRowExpanded] = useToggle();
+ const [isCustom, setIsCustom] = useToggle();
+
+ const rule = useWatch({
+ control,
+ name: "permissions.workspace"
+ });
+
+ const selectedPermissionCategory = useMemo(() => {
+ if (rule?.create) {
+ return Permission.Custom;
+ }
+ return Permission.NoAccess;
+ }, [rule, isCustom]);
+
+ useEffect(() => {
+ if (selectedPermissionCategory === Permission.Custom) setIsCustom.on();
+ else setIsCustom.off();
+ }, [selectedPermissionCategory]);
+
+ useEffect(() => {
+ const isRowCustom = selectedPermissionCategory === Permission.Custom;
+ if (isRowCustom) {
+ setIsRowExpanded.on();
+ }
+ }, []);
+
+ const handlePermissionChange = (val: Permission) => {
+ if (!val) return;
+ if (val === Permission.Custom) {
+ setIsRowExpanded.on();
+ setIsCustom.on();
+ return;
+ }
+ setIsCustom.off();
+
+ if (val === Permission.NoAccess) {
+ setValue("permissions.workspace", { create: false }, { shouldDirty: true });
+ }
+ };
+
+ return (
+ <>
+ <Tr
+ className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ onClick={() => setIsRowExpanded.toggle()}
+ >
+ <Td>
+ <FontAwesomeIcon icon={isRowExpanded ? faChevronDown : faChevronRight} />
+ </Td>
+ <Td>Project</Td>
+ <Td>
+ <Select
+ value={selectedPermissionCategory}
+ className="w-40 bg-mineshaft-600"
+ dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
+ onValueChange={handlePermissionChange}
+ isDisabled={!isEditable}
+ >
+ <SelectItem value={Permission.NoAccess}>No Access</SelectItem>
+ <SelectItem value={Permission.Custom}>Custom</SelectItem>
+ </Select>
+ </Td>
+ </Tr>
+ {isRowExpanded && (
+ <Tr>
+ <Td
+ colSpan={3}
+ className={`bg-bunker-600 px-0 py-0 ${isRowExpanded && "border-mineshaft-500 p-8"}`}
+ >
+ <div className="grid grid-cols-3 gap-4">
+ {PERMISSION_ACTIONS.map(({ action, label }) => {
+ return (
+ <Controller
+ name={`permissions.workspace.${action}`}
+ key={`permissions.workspace.${action}`}
+ control={control}
+ render={({ field }) => (
+ <Checkbox
+ isChecked={field.value}
+ onCheckedChange={(e) => {
+ if (!isEditable) {
+ createNotification({
+ type: "error",
+ text: "Failed to update default role"
+ });
+ return;
+ }
+ field.onChange(e);
+ }}
+ id={`permissions.organization-admin-console.${action}`}
+ >
+ {label}
+ </Checkbox>
+ )}
+ />
+ );
+ })}
+ </div>
+ </Td>
+ </Tr>
+ )}
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/RolePermissionRow.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/RolePermissionRow.tsx
new file mode 100644
index 0000000000..12e44e064f
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/RolePermissionRow.tsx
@@ -0,0 +1,229 @@
+import { useEffect, useMemo } from "react";
+import { Control, Controller, UseFormSetValue, useWatch } from "react-hook-form";
+import { faChevronDown, faChevronRight } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { Checkbox, Select, SelectItem, Td, Tr } from "@app/components/v2";
+import { OrgPermissionSubjects } from "@app/context";
+import { useToggle } from "@app/hooks";
+
+import { TFormSchema } from "../OrgRoleModifySection.utils";
+
+const PERMISSIONS = [
+ { action: "read", label: "View" },
+ { action: "create", label: "Create" },
+ { action: "edit", label: "Modify" },
+ { action: "delete", label: "Remove" }
+] as const;
+
+const SECRET_SCANNING_PERMISSIONS = [
+ { action: "read", label: "View risks" },
+ { action: "create", label: "Add integrations" },
+ { action: "edit", label: "Edit risk status" },
+ { action: "delete", label: "Remove integrations" }
+] as const;
+
+const INCIDENT_CONTACTS_PERMISSIONS = [
+ { action: "read", label: "View contacts" },
+ { action: "create", label: "Add new contacts" },
+ { action: "edit", label: "Edit contacts" },
+ { action: "delete", label: "Remove contacts" }
+] as const;
+
+const MEMBERS_PERMISSIONS = [
+ { action: "read", label: "View all members" },
+ { action: "create", label: "Invite members" },
+ { action: "edit", label: "Edit members" },
+ { action: "delete", label: "Remove members" }
+] as const;
+
+const BILLING_PERMISSIONS = [
+ { action: "read", label: "View bills" },
+ { action: "create", label: "Add payment methods" },
+ { action: "edit", label: "Edit payments" },
+ { action: "delete", label: "Remove payments" }
+] as const;
+
+const PROJECT_TEMPLATES_PERMISSIONS = [
+ { action: "read", label: "View & Apply" },
+ { action: "create", label: "Create" },
+ { action: "edit", label: "Modify" },
+ { action: "delete", label: "Remove" }
+] as const;
+
+const getPermissionList = (option: string) => {
+ switch (option) {
+ case "secret-scanning":
+ return SECRET_SCANNING_PERMISSIONS;
+ case "billing":
+ return BILLING_PERMISSIONS;
+ case "incident-contact":
+ return INCIDENT_CONTACTS_PERMISSIONS;
+ case "member":
+ return MEMBERS_PERMISSIONS;
+ case OrgPermissionSubjects.ProjectTemplates:
+ return PROJECT_TEMPLATES_PERMISSIONS;
+ default:
+ return PERMISSIONS;
+ }
+};
+
+type Props = {
+ isEditable: boolean;
+ title: string;
+ formName: keyof Omit<
+ Exclude<TFormSchema["permissions"], undefined>,
+ "workspace" | "organization-admin-console"
+ >;
+ setValue: UseFormSetValue<TFormSchema>;
+ control: Control<TFormSchema>;
+};
+
+enum Permission {
+ NoAccess = "no-access",
+ ReadOnly = "read-only",
+ FullAccess = "full-acess",
+ Custom = "custom"
+}
+
+export const RolePermissionRow = ({ isEditable, title, formName, control, setValue }: Props) => {
+ const [isRowExpanded, setIsRowExpanded] = useToggle();
+ const [isCustom, setIsCustom] = useToggle();
+
+ const rule = useWatch({
+ control,
+ name: `permissions.${formName}`
+ });
+
+ const selectedPermissionCategory = useMemo(() => {
+ const actions = Object.keys(rule || {}) as Array<keyof typeof rule>;
+ const totalActions = PERMISSIONS.length;
+ const score = actions.map((key) => (rule?.[key] ? 1 : 0)).reduce((a, b) => a + b, 0 as number);
+
+ if (isCustom) return Permission.Custom;
+ if (score === 0) return Permission.NoAccess;
+ if (score === totalActions) return Permission.FullAccess;
+ if (score === 1 && rule?.read) return Permission.ReadOnly;
+
+ return Permission.Custom;
+ }, [rule, isCustom]);
+
+ useEffect(() => {
+ if (selectedPermissionCategory === Permission.Custom) setIsCustom.on();
+ else setIsCustom.off();
+ }, [selectedPermissionCategory]);
+
+ useEffect(() => {
+ const isRowCustom = selectedPermissionCategory === Permission.Custom;
+ if (isRowCustom) {
+ setIsRowExpanded.on();
+ }
+ }, []);
+
+ const handlePermissionChange = (val: Permission) => {
+ if (val === Permission.Custom) {
+ setIsRowExpanded.on();
+ setIsCustom.on();
+ return;
+ }
+ setIsCustom.off();
+
+ switch (val) {
+ case Permission.NoAccess:
+ setValue(
+ `permissions.${formName}`,
+ { read: false, edit: false, create: false, delete: false },
+ { shouldDirty: true }
+ );
+ break;
+ case Permission.FullAccess:
+ setValue(
+ `permissions.${formName}`,
+ { read: true, edit: true, create: true, delete: true },
+ { shouldDirty: true }
+ );
+ break;
+ case Permission.ReadOnly:
+ setValue(
+ `permissions.${formName}`,
+ { read: true, edit: false, create: false, delete: false },
+ { shouldDirty: true }
+ );
+ break;
+ default:
+ setValue(
+ `permissions.${formName}`,
+ { read: false, edit: false, create: false, delete: false },
+ { shouldDirty: true }
+ );
+ break;
+ }
+ };
+
+ return (
+ <>
+ <Tr
+ className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ onClick={() => setIsRowExpanded.toggle()}
+ >
+ <Td>
+ <FontAwesomeIcon icon={isRowExpanded ? faChevronDown : faChevronRight} />
+ </Td>
+ <Td>{title}</Td>
+ <Td>
+ <Select
+ value={selectedPermissionCategory}
+ className="w-40 bg-mineshaft-600"
+ dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
+ onValueChange={handlePermissionChange}
+ isDisabled={!isEditable}
+ >
+ <SelectItem value={Permission.NoAccess}>No Access</SelectItem>
+ <SelectItem value={Permission.ReadOnly}>Read Only</SelectItem>
+ <SelectItem value={Permission.FullAccess}>Full Access</SelectItem>
+ <SelectItem value={Permission.Custom}>Custom</SelectItem>
+ </Select>
+ </Td>
+ </Tr>
+ {isRowExpanded && (
+ <Tr>
+ <Td
+ colSpan={3}
+ className={`bg-bunker-600 px-0 py-0 ${isRowExpanded && "border-mineshaft-500 p-8"}`}
+ >
+ <div className="grid grid-cols-3 gap-4">
+ {getPermissionList(formName).map(({ action, label }) => {
+ return (
+ <Controller
+ name={`permissions.${formName}.${action}`}
+ key={`permissions.${formName}.${action}`}
+ control={control}
+ render={({ field }) => (
+ <Checkbox
+ isChecked={field.value}
+ onCheckedChange={(e) => {
+ if (!isEditable) {
+ createNotification({
+ type: "error",
+ text: "Failed to update default role"
+ });
+ return;
+ }
+ field.onChange(e);
+ }}
+ id={`permissions.${formName}.${action}`}
+ >
+ {label}
+ </Checkbox>
+ )}
+ />
+ );
+ })}
+ </div>
+ </Td>
+ </Tr>
+ )}
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/RolePermissionsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/RolePermissionsSection.tsx
new file mode 100644
index 0000000000..38bf47b2bd
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/RolePermissionsSection.tsx
@@ -0,0 +1,183 @@
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, Table, TableContainer, TBody, Th, THead, Tr } from "@app/components/v2";
+import { OrgPermissionSubjects, useOrganization } from "@app/context";
+import { useGetOrgRole, useUpdateOrgRole } from "@app/hooks/api";
+
+import {
+ formRolePermission2API,
+ formSchema,
+ rolePermission2Form,
+ TFormSchema
+} from "../OrgRoleModifySection.utils";
+import { OrgPermissionAdminConsoleRow } from "./OrgPermissionAdminConsoleRow";
+import { OrgRoleWorkspaceRow } from "./OrgRoleWorkspaceRow";
+import { RolePermissionRow } from "./RolePermissionRow";
+
+const SIMPLE_PERMISSION_OPTIONS = [
+ {
+ title: "User Management",
+ formName: "member"
+ },
+ {
+ title: "Group Management",
+ formName: "groups"
+ },
+ {
+ title: "Machine Identity Management",
+ formName: "identity"
+ },
+ {
+ title: "Usage & Billing",
+ formName: "billing"
+ },
+ {
+ title: "Role Management",
+ formName: "role"
+ },
+ {
+ title: "Incident Contacts",
+ formName: "incident-contact"
+ },
+ {
+ title: "Audit Logs",
+ formName: "audit-logs"
+ },
+ {
+ title: "Organization Profile",
+ formName: "settings"
+ },
+ {
+ title: "Secret Scanning",
+ formName: "secret-scanning"
+ },
+ {
+ title: "SSO",
+ formName: "sso"
+ },
+ {
+ title: "LDAP",
+ formName: "ldap"
+ },
+ {
+ title: "SCIM",
+ formName: "scim"
+ },
+ {
+ title: "External KMS",
+ formName: OrgPermissionSubjects.Kms
+ },
+ { title: "Project Templates", formName: OrgPermissionSubjects.ProjectTemplates }
+] as const;
+
+type Props = {
+ roleId: string;
+};
+
+export const RolePermissionsSection = ({ roleId }: Props) => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+
+ const { data: role } = useGetOrgRole(orgId, roleId);
+
+ const {
+ setValue,
+ control,
+ handleSubmit,
+ formState: { isDirty, isSubmitting },
+ reset
+ } = useForm<TFormSchema>({
+ defaultValues: role ? { ...role, permissions: rolePermission2Form(role.permissions) } : {},
+ resolver: zodResolver(formSchema)
+ });
+
+ const { mutateAsync: updateRole } = useUpdateOrgRole();
+
+ const onSubmit = async (el: TFormSchema) => {
+ try {
+ await updateRole({
+ orgId,
+ id: roleId,
+ ...el,
+ permissions: formRolePermission2API(el.permissions)
+ });
+ createNotification({ type: "success", text: "Successfully updated role" });
+ } catch (err) {
+ console.log(err);
+ createNotification({ type: "error", text: "Failed to update role" });
+ }
+ };
+
+ const isCustomRole = !["admin", "member", "no-access"].includes(role?.slug ?? "");
+
+ return (
+ <form
+ onSubmit={handleSubmit(onSubmit)}
+ className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"
+ >
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <h3 className="text-lg font-semibold text-mineshaft-100">Permissions</h3>
+ {isCustomRole && (
+ <div className="flex items-center">
+ <Button
+ colorSchema="primary"
+ type="submit"
+ isDisabled={isSubmitting || !isDirty}
+ isLoading={isSubmitting}
+ >
+ Save
+ </Button>
+ <Button
+ className="ml-4 text-mineshaft-300"
+ variant="link"
+ isDisabled={isSubmitting || !isDirty}
+ isLoading={isSubmitting}
+ onClick={() => reset()}
+ >
+ Cancel
+ </Button>
+ </div>
+ )}
+ </div>
+ <div className="py-4">
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="w-5" />
+ <Th>Resource</Th>
+ <Th>Permission</Th>
+ </Tr>
+ </THead>
+ <TBody>
+ {SIMPLE_PERMISSION_OPTIONS.map((permission) => {
+ return (
+ <RolePermissionRow
+ title={permission.title}
+ formName={permission.formName}
+ control={control}
+ setValue={setValue}
+ key={`org-role-${roleId}-permission-${permission.formName}`}
+ isEditable={isCustomRole}
+ />
+ );
+ })}
+ <OrgRoleWorkspaceRow
+ control={control}
+ setValue={setValue}
+ isEditable={isCustomRole}
+ />
+ <OrgPermissionAdminConsoleRow
+ control={control}
+ setValue={setValue}
+ isEditable={isCustomRole}
+ />
+ </TBody>
+ </Table>
+ </TableContainer>
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/index.tsx
new file mode 100644
index 0000000000..104e2144ec
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/RolePermissionsSection/index.tsx
@@ -0,0 +1 @@
+export { RolePermissionsSection } from "./RolePermissionsSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/index.tsx
new file mode 100644
index 0000000000..3f57cd670e
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/-components/index.tsx
@@ -0,0 +1,3 @@
+export { RoleDetailsSection } from "./RoleDetailsSection";
+export { RoleModal } from "./RoleModal";
+export { RolePermissionsSection } from "./RolePermissionsSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/index.tsx
new file mode 100644
index 0000000000..3378bd546c
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/roles/$roleId/index.tsx
@@ -0,0 +1,215 @@
+import { Helmet } from 'react-helmet'
+import { useTranslation } from 'react-i18next'
+import { faChevronLeft, faEllipsis } from '@fortawesome/free-solid-svg-icons'
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
+import { createFileRoute, useNavigate, useParams } from '@tanstack/react-router'
+import { twMerge } from 'tailwind-merge'
+
+import { createNotification } from '@app/components/notifications'
+import { OrgPermissionCan } from '@app/components/permissions'
+import {
+ Button,
+ DeleteActionModal,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ Tooltip,
+} from '@app/components/v2'
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+} from '@app/context'
+import { withPermission } from '@app/hoc'
+import { useDeleteOrgRole, useGetOrgRole } from '@app/hooks/api'
+import { usePopUp } from '@app/hooks/usePopUp'
+import { TabSections } from '@app/types/org'
+
+import {
+ RoleDetailsSection,
+ RoleModal,
+ RolePermissionsSection,
+} from './-components'
+
+export const RolePage = withPermission(
+ () => {
+ const navigate = useNavigate()
+ const params = useParams({
+ from: '/_authenticate/_org_details/_org-layout/organization/$organizationId/roles/$roleId',
+ })
+ const roleId = params.roleId as string
+ const { currentOrg } = useOrganization()
+ const orgId = currentOrg?.id || ''
+ const { data } = useGetOrgRole(orgId, roleId)
+ const { mutateAsync: deleteOrgRole } = useDeleteOrgRole()
+
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } =
+ usePopUp(['role', 'deleteOrgRole'] as const)
+
+ const onDeleteOrgRoleSubmit = async () => {
+ try {
+ if (!orgId || !roleId) return
+
+ await deleteOrgRole({
+ orgId,
+ id: roleId,
+ })
+
+ createNotification({
+ text: 'Successfully deleted organization role',
+ type: 'success',
+ })
+
+ handlePopUpClose('deleteOrgRole')
+ navigate({
+ to: '/organization/$organizationId/members' as const,
+ params: {
+ organizationId: currentOrg.id,
+ },
+ search: {
+ selectedTab: TabSections.Roles,
+ },
+ })
+ } catch (err) {
+ console.error(err)
+ const error = err as any
+ const text =
+ error?.response?.data?.message ?? 'Failed to delete organization role'
+
+ createNotification({
+ text,
+ type: 'error',
+ })
+ }
+ }
+
+ const isCustomRole = !['admin', 'member', 'no-access'].includes(
+ data?.slug ?? '',
+ )
+
+ return (
+ <div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white">
+ {data && (
+ <div className="mx-auto mb-6 w-full max-w-7xl px-6 py-6">
+ <Button
+ variant="link"
+ type="submit"
+ leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
+ onClick={() => {
+ navigate({
+ to: '/organization/$organizationId/members' as const,
+ params: {
+ organizationId: currentOrg.id,
+ },
+ search: {
+ selectedTab: TabSections.Roles,
+ },
+ })
+ }}
+ className="mb-4"
+ >
+ Roles
+ </Button>
+ <div className="mb-4 flex items-center justify-between">
+ <p className="text-3xl font-semibold text-white">{data.name}</p>
+ {isCustomRole && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <div className="hover:text-primary-400 data-[state=open]:text-primary-400">
+ <Tooltip content="More options">
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </Tooltip>
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Role}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ !isAllowed &&
+ 'pointer-events-none cursor-not-allowed opacity-50',
+ )}
+ onClick={async () => {
+ handlePopUpOpen('role', {
+ roleId,
+ })
+ }}
+ disabled={!isAllowed}
+ >
+ Edit Role
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Role}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ className={twMerge(
+ isAllowed
+ ? 'hover:!bg-red-500 hover:!text-white'
+ : 'pointer-events-none cursor-not-allowed opacity-50',
+ )}
+ onClick={async () => {
+ handlePopUpOpen('deleteOrgRole')
+ }}
+ disabled={!isAllowed}
+ >
+ Delete Role
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </div>
+ <div className="flex">
+ <div className="mr-4 w-96">
+ <RoleDetailsSection
+ roleId={roleId}
+ handlePopUpOpen={handlePopUpOpen}
+ />
+ </div>
+ <RolePermissionsSection roleId={roleId} />
+ </div>
+ </div>
+ )}
+ <RoleModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
+ <DeleteActionModal
+ isOpen={popUp.deleteOrgRole.isOpen}
+ title={`Are you sure want to delete the organization role ${data?.name ?? ''}?`}
+ onChange={(isOpen) => handlePopUpToggle('deleteOrgRole', isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() => onDeleteOrgRoleSubmit()}
+ />
+ </div>
+ )
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Role },
+)
+
+const OrgRoleRoute = () => {
+ const { t } = useTranslation()
+ return (
+ <>
+ <Helmet>
+ <title>
+ {t('common.head-title', { title: t('settings.org.title') })}
+ </title>
+ <link rel="icon" href="/infisical.ico" />
+ </Helmet>
+ <RolePage />
+ </>
+ )
+}
+
+export const Route = createFileRoute(
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/roles/$roleId/',
+)({
+ component: OrgRoleRoute,
+})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-manager.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-manager.tsx
deleted file mode 100644
index 202a5c0538..0000000000
--- a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-manager.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { createFileRoute } from '@tanstack/react-router'
-
-function SecretManagerOverviewPage() {
- return <div>Hello "/organization/secret-manager"!</div>
-}
-
-export const Route = createFileRoute(
- '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager',
-)({
- component: SecretManagerOverviewPage,
-})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-manager/overview.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-manager/overview.tsx
new file mode 100644
index 0000000000..b308dbdc99
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-manager/overview.tsx
@@ -0,0 +1,571 @@
+// REFACTOR(akhilmhdh): This file needs to be split into multiple components too complex
+
+import { ReactNode, useMemo, useState } from 'react'
+import { Helmet } from 'react-helmet'
+import { useTranslation } from 'react-i18next'
+import { faFolderOpen, faStar } from '@fortawesome/free-regular-svg-icons'
+import {
+ faArrowDownAZ,
+ faArrowRight,
+ faArrowUpZA,
+ faBorderAll,
+ faExclamationCircle,
+ faList,
+ faMagnifyingGlass,
+ faPlus,
+ faSearch,
+ faStar as faSolidStar,
+} from '@fortawesome/free-solid-svg-icons'
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
+import { createFileRoute, useNavigate } from '@tanstack/react-router'
+
+import { createNotification } from '@app/components/notifications'
+import { OrgPermissionCan } from '@app/components/permissions'
+import { NewProjectModal } from '@app/components/projects'
+import {
+ Button,
+ IconButton,
+ Input,
+ Pagination,
+ Skeleton,
+ Tooltip,
+ UpgradePlanModal,
+} from '@app/components/v2'
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription,
+} from '@app/context'
+import { getProjectHomePage } from '@app/helpers/project'
+import { usePagination, useResetPageHelper } from '@app/hooks'
+import { useGetUserWorkspaces } from '@app/hooks/api'
+import { OrderByDirection } from '@app/hooks/api/generic/types'
+// import { fetchUserWsKey } from "@app/hooks/api/keys/queries";
+import { useFetchServerStatus } from '@app/hooks/api/serverDetails'
+import { Workspace } from '@app/hooks/api/types'
+import { useUpdateUserProjectFavorites } from '@app/hooks/api/users/mutation'
+import { useGetUserProjectFavorites } from '@app/hooks/api/users/queries'
+import { ProjectType } from '@app/hooks/api/workspace/types'
+import { usePopUp } from '@app/hooks/usePopUp'
+
+enum ProjectsViewMode {
+ GRID = 'grid',
+ LIST = 'list',
+}
+
+enum ProjectOrderBy {
+ Name = 'name',
+}
+
+const formatTitle = (type: ProjectType) => {
+ if (type === ProjectType.SecretManager) return 'Secret Management'
+ if (type === ProjectType.CertificateManager) return 'Cert Management'
+ return 'Key Management'
+}
+
+const formatDescription = (type: ProjectType) => {
+ if (type === ProjectType.SecretManager)
+ return 'Securely store, manage, and rotate various application secrets, such as database credentials, API keys, etc.'
+ if (type === ProjectType.CertificateManager)
+ return 'Manage your PKI infrastructure and issue digital certificates for services, applications, and devices.'
+ return 'Centralize the management of keys for cryptographic operations, such as encryption and decryption.'
+}
+
+type Props = {
+ type: ProjectType
+}
+
+// #TODO: Update all the workspaceIds
+export const ProductOverview = ({ type }: Props) => {
+ const { t } = useTranslation()
+
+ const navigate = useNavigate()
+
+ const { data: workspaces, isLoading: isWorkspaceLoading } =
+ useGetUserWorkspaces({ type })
+ const { currentOrg } = useOrganization()
+ const orgWorkspaces = workspaces || []
+ const { data: projectFavorites, isLoading: isProjectFavoritesLoading } =
+ useGetUserProjectFavorites(currentOrg?.id)
+ const { mutateAsync: updateUserProjectFavorites } =
+ useUpdateUserProjectFavorites()
+
+ const isProjectViewLoading = isWorkspaceLoading || isProjectFavoritesLoading
+
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([
+ 'addNewWs',
+ 'upgradePlan',
+ ] as const)
+
+ const [searchFilter, setSearchFilter] = useState('')
+ const { data: serverDetails } = useFetchServerStatus()
+ const [projectsViewMode, setProjectsViewMode] = useState<ProjectsViewMode>(
+ (localStorage.getItem('projectsViewMode') as ProjectsViewMode) ||
+ ProjectsViewMode.GRID,
+ )
+
+ const { subscription } = useSubscription()
+
+ const isAddingProjectsAllowed = subscription?.workspaceLimit
+ ? subscription.workspacesUsed < subscription.workspaceLimit
+ : true
+
+ const isWorkspaceEmpty = !isProjectViewLoading && orgWorkspaces?.length === 0
+
+ const {
+ setPage,
+ perPage,
+ setPerPage,
+ page,
+ offset,
+ limit,
+ toggleOrderDirection,
+ orderDirection,
+ } = usePagination(ProjectOrderBy.Name, { initPerPage: 24 })
+
+ const filteredWorkspaces = useMemo(
+ () =>
+ orgWorkspaces
+ .filter((ws) =>
+ ws?.name?.toLowerCase().includes(searchFilter.toLowerCase()),
+ )
+ .sort((a, b) =>
+ orderDirection === OrderByDirection.ASC
+ ? a.name.toLowerCase().localeCompare(b.name.toLowerCase())
+ : b.name.toLowerCase().localeCompare(a.name.toLowerCase()),
+ ),
+ [searchFilter, orderDirection, orgWorkspaces],
+ )
+
+ useResetPageHelper({
+ setPage,
+ offset,
+ totalCount: filteredWorkspaces.length,
+ })
+
+ const { workspacesWithFaveProp } = useMemo(() => {
+ const workspacesWithFav = filteredWorkspaces
+ .map((w): Workspace & { isFavorite: boolean } => ({
+ ...w,
+ isFavorite: Boolean(projectFavorites?.includes(w.id)),
+ }))
+ .sort((a, b) => Number(b.isFavorite) - Number(a.isFavorite))
+ .slice(offset, limit * page)
+
+ return {
+ workspacesWithFaveProp: workspacesWithFav,
+ }
+ }, [filteredWorkspaces, projectFavorites])
+
+ const addProjectToFavorites = async (projectId: string) => {
+ try {
+ if (currentOrg?.id) {
+ await updateUserProjectFavorites({
+ orgId: currentOrg?.id,
+ projectFavorites: [...(projectFavorites || []), projectId],
+ })
+ }
+ } catch {
+ createNotification({
+ text: 'Failed to add project to favorites.',
+ type: 'error',
+ })
+ }
+ }
+
+ const removeProjectFromFavorites = async (projectId: string) => {
+ try {
+ if (currentOrg?.id) {
+ await updateUserProjectFavorites({
+ orgId: currentOrg?.id,
+ projectFavorites: [
+ ...(projectFavorites || []).filter((entry) => entry !== projectId),
+ ],
+ })
+ }
+ } catch {
+ createNotification({
+ text: 'Failed to remove project from favorites.',
+ type: 'error',
+ })
+ }
+ }
+
+ const renderProjectGridItem = (workspace: Workspace, isFavorite: boolean) => (
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
+ <div
+ onClick={() => {
+ // TODO(rbr): fix this
+ navigate({
+ to: getProjectHomePage(workspace),
+ })
+ localStorage.setItem('projectData.id', workspace.id)
+ }}
+ key={workspace.id}
+ className="flex h-40 min-w-72 cursor-pointer flex-col rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4"
+ >
+ <div className="flex flex-row justify-between">
+ <div className="mt-0 truncate text-lg text-mineshaft-100">
+ {workspace.name}
+ </div>
+ {isFavorite ? (
+ <FontAwesomeIcon
+ icon={faSolidStar}
+ className="text-sm text-yellow-600 hover:text-mineshaft-400"
+ onClick={(e) => {
+ e.stopPropagation()
+ removeProjectFromFavorites(workspace.id)
+ }}
+ />
+ ) : (
+ <FontAwesomeIcon
+ icon={faStar}
+ className="text-sm text-mineshaft-400 hover:text-mineshaft-300"
+ onClick={(e) => {
+ e.stopPropagation()
+ addProjectToFavorites(workspace.id)
+ }}
+ />
+ )}
+ </div>
+
+ <div
+ className="mb-2.5 mt-1 grow text-sm text-mineshaft-300"
+ style={{
+ overflow: 'hidden',
+ display: '-webkit-box',
+ WebkitBoxOrient: 'vertical',
+ WebkitLineClamp: 2,
+ }}
+ >
+ {workspace.description}
+ </div>
+
+ <div className="flex w-full flex-row items-end justify-between place-self-end">
+ {type === ProjectType.SecretManager && (
+ <div className="mt-0 text-xs text-mineshaft-400">
+ {workspace.environments?.length || 0} environments
+ </div>
+ )}
+ <button type="button">
+ <div className="group ml-auto w-max cursor-pointer rounded-full border border-mineshaft-600 bg-mineshaft-900 px-4 py-2 text-sm text-mineshaft-300 transition-all hover:border-primary-500/80 hover:bg-primary-800/20 hover:text-mineshaft-200">
+ Explore{' '}
+ <FontAwesomeIcon
+ icon={faArrowRight}
+ className="pl-1.5 pr-0.5 duration-200 hover:pl-2 hover:pr-0"
+ />
+ </div>
+ </button>
+ </div>
+ </div>
+ )
+
+ const renderProjectListItem = (
+ workspace: Workspace,
+ isFavorite: boolean,
+ index: number,
+ ) => (
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
+ <div
+ onClick={() => {
+ // TODO(rbr): fix this
+ navigate({
+ to: getProjectHomePage(workspace),
+ })
+ localStorage.setItem('projectData.id', workspace.id)
+ }}
+ key={workspace.id}
+ className={`group grid h-14 min-w-72 cursor-pointer grid-cols-6 border-l border-r border-t border-mineshaft-600 bg-mineshaft-800 px-6 hover:bg-mineshaft-700 ${
+ index === 0 && 'rounded-t-md'
+ }`}
+ >
+ <div className="flex items-center sm:col-span-3 lg:col-span-4">
+ <div className="truncate text-sm text-mineshaft-100">
+ {workspace.name}
+ </div>
+ </div>
+ <div className="flex items-center justify-end sm:col-span-3 lg:col-span-2">
+ <div className="text-center text-sm text-mineshaft-300">
+ {workspace.environments?.length || 0} environments
+ </div>
+ {isFavorite ? (
+ <FontAwesomeIcon
+ icon={faSolidStar}
+ className="ml-6 text-sm text-yellow-600 hover:text-mineshaft-400"
+ onClick={(e) => {
+ e.stopPropagation()
+ removeProjectFromFavorites(workspace.id)
+ }}
+ />
+ ) : (
+ <FontAwesomeIcon
+ icon={faStar}
+ className="ml-6 text-sm text-mineshaft-400 hover:text-mineshaft-300"
+ onClick={(e) => {
+ e.stopPropagation()
+ addProjectToFavorites(workspace.id)
+ }}
+ />
+ )}
+ </div>
+ </div>
+ )
+
+ let projectsComponents: ReactNode
+
+ if (filteredWorkspaces.length || isProjectViewLoading) {
+ switch (projectsViewMode) {
+ case ProjectsViewMode.GRID:
+ projectsComponents = (
+ <div className="mt-4 grid w-full grid-cols-1 gap-4 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
+ {isProjectViewLoading &&
+ Array.apply(0, Array(3)).map((_x, i) => (
+ <div
+ key={`workspace-cards-loading-${i + 1}`}
+ className="flex h-40 min-w-72 flex-col justify-between rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4"
+ >
+ <div className="mt-0 text-lg text-mineshaft-100">
+ <Skeleton className="w-3/4 bg-mineshaft-600" />
+ </div>
+ <div className="mt-0 pb-6 text-sm text-mineshaft-300">
+ <Skeleton className="w-1/2 bg-mineshaft-600" />
+ </div>
+ <div className="flex justify-end">
+ <Skeleton className="w-1/2 bg-mineshaft-600" />
+ </div>
+ </div>
+ ))}
+ {!isProjectViewLoading && (
+ <>
+ {workspacesWithFaveProp.map((workspace) =>
+ renderProjectGridItem(workspace, workspace.isFavorite),
+ )}
+ </>
+ )}
+ </div>
+ )
+
+ break
+ case ProjectsViewMode.LIST:
+ default:
+ projectsComponents = (
+ <div className="mt-4 w-full rounded-md">
+ {isProjectViewLoading &&
+ Array.apply(0, Array(3)).map((_x, i) => (
+ <div
+ key={`workspace-cards-loading-${i + 1}`}
+ className={`group flex h-12 min-w-72 cursor-pointer flex-row items-center justify-between border border-mineshaft-600 bg-mineshaft-800 px-6 hover:bg-mineshaft-700 ${
+ i === 0 && 'rounded-t-md'
+ } ${i === 2 && 'rounded-b-md border-b'}`}
+ >
+ <Skeleton className="w-full bg-mineshaft-600" />
+ </div>
+ ))}
+ {!isProjectViewLoading &&
+ workspacesWithFaveProp.map((workspace, ind) =>
+ renderProjectListItem(workspace, workspace.isFavorite, ind),
+ )}
+ </div>
+ )
+ break
+ }
+ } else if (orgWorkspaces.length && searchFilter) {
+ projectsComponents = (
+ <div className="mt-4 w-full rounded-md border border-mineshaft-700 bg-mineshaft-800 px-4 py-6 text-base text-mineshaft-300">
+ <FontAwesomeIcon
+ icon={faSearch}
+ className="mb-4 mt-2 w-full text-center text-5xl text-mineshaft-400"
+ />
+ <div className="text-center font-light">
+ No projects match search...
+ </div>
+ </div>
+ )
+ }
+
+ return (
+ <div className="mx-auto flex max-w-7xl flex-col justify-start bg-bunker-800 md:h-screen">
+ <Helmet>
+ <title>
+ {t('common.head-title', { title: t('settings.members.title') })}
+ </title>
+ <link rel="icon" href="/infisical.ico" />
+ </Helmet>
+ {!serverDetails?.redisConfigured && (
+ <div className="mb-4 flex flex-col items-start justify-start px-6 py-6 pb-0 text-3xl">
+ <p className="mb-4 mr-4 font-semibold text-white">Announcements</p>
+ <div className="flex w-full items-center rounded-md border border-blue-400/70 bg-blue-900/70 p-2 text-base text-mineshaft-100">
+ <FontAwesomeIcon
+ icon={faExclamationCircle}
+ className="mr-4 p-4 text-2xl text-mineshaft-50"
+ />
+ Attention: Updated versions of Infisical now require Redis for full
+ functionality. Learn how to configure it
+ <a
+ href="https://infisical.com/docs/self-hosting/configuration/redis"
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ <span className="cursor-pointer pl-1 text-white underline underline-offset-2 duration-100 hover:text-blue-200 hover:decoration-blue-400">
+ here
+ </span>
+ </a>
+ .
+ </div>
+ </div>
+ )}
+ <div className="mb-4 flex flex-col items-start justify-start px-6 py-6 pb-0">
+ <div className="flex w-full justify-between">
+ <p className="mr-4 text-3xl font-semibold text-white">
+ {formatTitle(type)}
+ </p>
+ </div>
+ <div>
+ <p className="mr-4 mt-2 text-gray-400">{formatDescription(type)}</p>
+ </div>
+ <div className="mt-6 flex w-full flex-row">
+ <Input
+ className="h-[2.3rem] bg-mineshaft-800 text-sm placeholder-mineshaft-50 duration-200 focus:bg-mineshaft-700/80"
+ placeholder="Search by project name..."
+ value={searchFilter}
+ onChange={(e) => setSearchFilter(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ />
+ <div className="ml-2 flex rounded-md border border-mineshaft-600 bg-mineshaft-800 p-1">
+ <Tooltip content="Toggle Sort Direction">
+ <IconButton
+ className="min-w-[2.4rem] border-none hover:bg-mineshaft-600"
+ ariaLabel={`Sort ${
+ orderDirection === OrderByDirection.ASC
+ ? 'descending'
+ : 'ascending'
+ }`}
+ variant="plain"
+ size="xs"
+ colorSchema="secondary"
+ onClick={toggleOrderDirection}
+ >
+ <FontAwesomeIcon
+ icon={
+ orderDirection === OrderByDirection.ASC
+ ? faArrowDownAZ
+ : faArrowUpZA
+ }
+ />
+ </IconButton>
+ </Tooltip>
+ </div>
+ <div className="ml-2 flex rounded-md border border-mineshaft-600 bg-mineshaft-800 p-1">
+ <IconButton
+ variant="outline_bg"
+ onClick={() => {
+ localStorage.setItem('projectsViewMode', ProjectsViewMode.GRID)
+ setProjectsViewMode(ProjectsViewMode.GRID)
+ }}
+ ariaLabel="grid"
+ size="xs"
+ className={`${
+ projectsViewMode === ProjectsViewMode.GRID
+ ? 'bg-mineshaft-500'
+ : 'bg-transparent'
+ } min-w-[2.4rem] border-none hover:bg-mineshaft-600`}
+ >
+ <FontAwesomeIcon icon={faBorderAll} />
+ </IconButton>
+ <IconButton
+ variant="outline_bg"
+ onClick={() => {
+ localStorage.setItem('projectsViewMode', ProjectsViewMode.LIST)
+ setProjectsViewMode(ProjectsViewMode.LIST)
+ }}
+ ariaLabel="list"
+ size="xs"
+ className={`${
+ projectsViewMode === ProjectsViewMode.LIST
+ ? 'bg-mineshaft-500'
+ : 'bg-transparent'
+ } min-w-[2.4rem] border-none hover:bg-mineshaft-600`}
+ >
+ <FontAwesomeIcon icon={faList} />
+ </IconButton>
+ </div>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Create}
+ an={OrgPermissionSubjects.Workspace}
+ >
+ {(isAllowed) => (
+ <Button
+ isDisabled={!isAllowed}
+ colorSchema="primary"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ onClick={() => {
+ if (isAddingProjectsAllowed) {
+ handlePopUpOpen('addNewWs')
+ } else {
+ handlePopUpOpen('upgradePlan')
+ }
+ }}
+ className="ml-2"
+ >
+ Add New Project
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ {projectsComponents}
+ {!isProjectViewLoading && Boolean(filteredWorkspaces.length) && (
+ <Pagination
+ className={
+ projectsViewMode === ProjectsViewMode.GRID
+ ? 'col-span-full !justify-start border-transparent bg-transparent pl-2'
+ : 'rounded-b-md border border-mineshaft-600'
+ }
+ perPage={perPage}
+ perPageList={[12, 24, 48, 96]}
+ count={filteredWorkspaces.length}
+ page={page}
+ onChangePage={setPage}
+ onChangePerPage={setPerPage}
+ />
+ )}
+ {isWorkspaceEmpty && (
+ <div className="mt-4 w-full rounded-md border border-mineshaft-700 bg-mineshaft-800 px-4 py-6 text-base text-mineshaft-300">
+ <FontAwesomeIcon
+ icon={faFolderOpen}
+ className="mb-4 mt-2 w-full text-center text-5xl text-mineshaft-400"
+ />
+ <div className="text-center font-light">
+ You are not part of any projects in this organization yet. When
+ you are, they will appear here.
+ </div>
+ <div className="mt-0.5 text-center font-light">
+ Create a new project, or ask other organization members to give
+ you necessary permissions.
+ </div>
+ </div>
+ )}
+ </div>
+ <NewProjectModal
+ isOpen={popUp.addNewWs.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle('addNewWs', isOpen)}
+ projectType={type}
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle('upgradePlan', isOpen)}
+ text="You have exceeded the number of projects allowed on the free plan."
+ />
+ </div>
+ )
+}
+
+const SecretManagerOverviewPage = () => (
+ <ProductOverview type={ProjectType.SecretManager} />
+)
+
+export const Route = createFileRoute(
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-manager/overview',
+)({
+ component: SecretManagerOverviewPage,
+})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/-components/RiskStatusSelection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/-components/RiskStatusSelection.tsx
new file mode 100644
index 0000000000..3d7c1de1d4
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/-components/RiskStatusSelection.tsx
@@ -0,0 +1,46 @@
+import { useState } from "react";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { useUpdateRiskStatus } from "@app/hooks/api/secretScanning";
+import { RiskStatus } from "@app/hooks/api/secretScanning/types";
+
+export const RiskStatusSelection = ({
+ riskId,
+ currentSelection
+}: {
+ riskId: any;
+ currentSelection: any;
+}) => {
+ const [selectedRiskStatus, setSelectedRiskStatus] = useState(currentSelection);
+ const { mutate: updateRiskStatus } = useUpdateRiskStatus();
+ const { currentOrg } = useOrganization();
+ const organizationId = currentOrg.id;
+
+ return (
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.SecretScanning}>
+ {(isAllowed) => (
+ <select
+ disabled={!isAllowed}
+ value={selectedRiskStatus}
+ onChange={(e) => {
+ setSelectedRiskStatus(e.target.value);
+ updateRiskStatus({
+ organizationId,
+ status: e.target.value as RiskStatus,
+ riskId
+ });
+ }}
+ className="block w-full rounded-md px-3 py-2 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-blue-500"
+ >
+ <option>Unresolved</option>
+ <option value={RiskStatus.RESOLVED_FALSE_POSITIVE}>
+ This is a false positive, resolved
+ </option>
+ <option value={RiskStatus.RESOLVED_REVOKED}>I have rotated the secret, resolved</option>
+ <option value={RiskStatus.RESOLVED_NOT_REVOKED}>No rotate needed, resolved</option>
+ </select>
+ )}
+ </OrgPermissionCan>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/-components/SecretScanningLogsTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/-components/SecretScanningLogsTable.tsx
new file mode 100644
index 0000000000..30b2171ab9
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/-components/SecretScanningLogsTable.tsx
@@ -0,0 +1,91 @@
+import { faCheck } from "@fortawesome/free-solid-svg-icons";
+import { formatDistance } from "date-fns";
+
+import {
+ EmptyState,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useGetSecretScanningRisks } from "@app/hooks/api/secretScanning";
+
+import { RiskStatusSelection } from "./RiskStatusSelection";
+
+export const SecretScanningLogsTable = () => {
+ const { currentOrg } = useOrganization();
+ const organizationId = currentOrg.id;
+ const { isLoading, data: gitRisks } = useGetSecretScanningRisks(organizationId);
+
+ return (
+ <TableContainer className="mt-8">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="flex-1">Date</Th>
+ <Th className="flex-1">Secret Type</Th>
+ <Th className="flex-1">View Risk</Th>
+ <Th className="flex-1">Info</Th>
+ <Th className="flex-1">Status</Th>
+ <Th className="flex-1">Action</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ gitRisks &&
+ gitRisks?.map((risk) => {
+ return (
+ <Tr key={risk.ruleID} className="h-10">
+ <Td>{formatDistance(new Date(risk.createdAt), new Date())}</Td>
+ <Td>{risk.ruleID}</Td>
+ <Td>
+ <a
+ href={`https://github.com/${risk.repositoryFullName}/blob/${risk.commit}/${risk.file}#L${risk.startLine}-L${risk.endLine}`}
+ target="_blank"
+ className="text-red-500"
+ rel="noreferrer"
+ >
+ View Exposed Secret
+ </a>
+ </Td>
+ <Td>
+ <div className="font-bold">
+ <a href={`https://github.com/${risk.repositoryFullName}`}>
+ {risk.repositoryFullName}
+ </a>
+ </div>
+ <div className="text-xs">
+ <span>{risk.file}</span>
+ <br />
+ <br />
+ <span className="font-bold">{risk.author}</span>
+ <br />
+ <span>{risk.email}</span>
+ </div>
+ </Td>
+ <Td>{risk.isResolved ? "Resolved" : "Needs Attention"}</Td>
+ <Td>
+ <RiskStatusSelection riskId={risk.id} currentSelection={risk.status} />
+ </Td>
+ </Tr>
+ );
+ })}
+ {isLoading && <TableSkeleton columns={7} innerKey="gitRisks" />}
+ {!isLoading && gitRisks && gitRisks?.length === 0 && (
+ <Tr>
+ <Td colSpan={7}>
+ <EmptyState title="No risks detected." icon={faCheck} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/-components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/-components/index.tsx
new file mode 100644
index 0000000000..52f5165936
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/-components/index.tsx
@@ -0,0 +1 @@
+export { SecretScanningLogsTable } from "./SecretScanningLogsTable";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/index.tsx
new file mode 100644
index 0000000000..7cab3109be
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-scanning/index.tsx
@@ -0,0 +1,163 @@
+import { useEffect } from 'react'
+import { Helmet } from 'react-helmet'
+import { createFileRoute, useSearch } from '@tanstack/react-router'
+
+import { OrgPermissionCan } from '@app/components/permissions'
+import { Button, NoticeBanner } from '@app/components/v2'
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useServerConfig,
+} from '@app/context'
+import { withPermission } from '@app/hoc'
+import {
+ useCreateNewInstallationSession,
+ useGetSecretScanningInstallationStatus,
+ useLinkGitAppInstallationWithOrg,
+} from '@app/hooks/api/secretScanning'
+
+import { SecretScanningLogsTable } from './-components'
+
+const SecretScanning = withPermission(
+ () => {
+ const queryParams = useSearch({
+ from: '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-scanning',
+ })
+ const { config } = useServerConfig()
+ const { currentOrg } = useOrganization()
+ const organizationId = currentOrg.id
+
+ const { mutateAsync: linkGitAppInstallationWithOrganization } =
+ useLinkGitAppInstallationWithOrg()
+ const { mutateAsync: createNewIntegrationSession } =
+ useCreateNewInstallationSession()
+ const {
+ data: installationStatus,
+ isLoading: isSecretScanningInstatllationStatusLoading,
+ } = useGetSecretScanningInstallationStatus(organizationId)
+ const integrationEnabled =
+ !isSecretScanningInstatllationStatusLoading &&
+ installationStatus?.appInstallationCompleted
+
+ useEffect(() => {
+ const linkInstallation = async () => {
+ if (
+ typeof queryParams.state === 'string' &&
+ typeof queryParams.installation_id === 'string'
+ ) {
+ try {
+ const isLinked = await linkGitAppInstallationWithOrganization({
+ installationId: queryParams.installation_id as string,
+ sessionId: queryParams.state as string,
+ })
+ if (isLinked) {
+ window.location.reload()
+ }
+
+ console.log('installation verification complete')
+ } catch (e) {
+ console.log('app installation is stale, start new session', e)
+ }
+ }
+ }
+ linkInstallation()
+ }, [queryParams.state, queryParams.installation_id])
+
+ const generateNewIntegrationSession = async () => {
+ const session = await createNewIntegrationSession({ organizationId })
+ window.location.href = `https://github.com/apps/infisical-radar/installations/new?state=${session.sessionId}`
+ }
+
+ return (
+ <div>
+ <Helmet>
+ <title>Secret scanning</title>
+ <link rel="icon" href="/infisical.ico" />
+ <meta property="og:image" content="/images/message.png" />
+ </Helmet>
+ <div className="flex h-full w-full justify-center bg-bunker-800 text-white">
+ <div className="w-full max-w-7xl px-6">
+ <div className="mt-6 text-3xl font-semibold text-gray-200">
+ Secret Scanning
+ </div>
+ <div className="mb-6 text-lg text-mineshaft-300">
+ Automatically monitor your GitHub activity and prevent secret
+ leaks
+ </div>
+ {config.isSecretScanningDisabled && (
+ <NoticeBanner
+ title="Secret scanning is in maintenance"
+ className="mb-4"
+ >
+ We are working on improving the performance of secret scanning
+ due to increased usage.
+ </NoticeBanner>
+ )}
+ <div className="relative mb-6 flex justify-between rounded-md border border-mineshaft-600 bg-mineshaft-800 p-6">
+ <div className="flex flex-col items-start">
+ <div className="mb-1 flex flex-row">
+ Secret Scanning Status:{' '}
+ {integrationEnabled ? (
+ <p className="ml-1.5 font-semibold text-green">Enabled</p>
+ ) : (
+ <p className="ml-1.5 font-semibold text-red">Not enabled</p>
+ )}
+ </div>
+ <div>
+ {integrationEnabled ? (
+ <p className="text-mineshaft-300">
+ Your GitHub organization is connected to Infisical, and is
+ being continuously monitored for secret leaks.
+ </p>
+ ) : (
+ <p className="text-mineshaft-300">
+ Connect your GitHub organization to Infisical.
+ </p>
+ )}
+ </div>
+ </div>
+ {integrationEnabled ? (
+ <div>
+ <div className="absolute right-[2.5rem] top-[2.5rem] flex h-6 w-6 animate-ping items-center justify-center rounded-full bg-green" />
+ <div className="absolute right-[2.63rem] top-[2.63rem] flex h-5 w-5 animate-ping items-center justify-center rounded-full bg-green" />
+ <div className="absolute right-[2.82rem] top-[2.82rem] flex h-3.5 w-3.5 animate-ping items-center justify-center rounded-full bg-green" />
+ </div>
+ ) : (
+ <div className="flex h-[3.25rem] items-center">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Create}
+ a={OrgPermissionSubjects.SecretScanning}
+ >
+ {(isAllowed) => (
+ <Button
+ variant="solid"
+ colorSchema="primary"
+ onClick={generateNewIntegrationSession}
+ className="h-min py-2"
+ isDisabled={!isAllowed}
+ >
+ Integrate with GitHub
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ )}
+ </div>
+ <SecretScanningLogsTable />
+ </div>
+ </div>
+ </div>
+ )
+ },
+ {
+ action: OrgPermissionActions.Read,
+ subject: OrgPermissionSubjects.SecretScanning,
+ },
+)
+
+export const Route = createFileRoute(
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-scanning/',
+)({
+ component: SecretScanning,
+})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/AddShareSecretModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/AddShareSecretModal.tsx
new file mode 100644
index 0000000000..561e565e6a
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/AddShareSecretModal.tsx
@@ -0,0 +1,35 @@
+import { Modal, ModalContent } from "@app/components/v2";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+// TODO(rbr): bring it back
+// import { ShareSecretForm } from "@app/views/ShareSecretPublicPage/components";
+
+type Props = {
+ popUp: UsePopUpState<["createSharedSecret"]>;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["createSharedSecret"]>,
+ state?: boolean
+ ) => void;
+};
+
+export const AddShareSecretModal = ({ popUp, handlePopUpToggle }: Props) => {
+ return (
+ <Modal
+ isOpen={popUp?.createSharedSecret?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("createSharedSecret", isOpen);
+ }}
+ >
+ <ModalContent
+ title="Share a Secret"
+ subTitle="Securely share one off secrets with your team."
+ >
+ {
+ // <ShareSecretForm
+ // isPublic={false}
+ // value={(popUp.createSharedSecret.data as { value?: string })?.value}
+ // />
+ }
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/ShareSecretSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/ShareSecretSection.tsx
new file mode 100644
index 0000000000..1de78ca235
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/ShareSecretSection.tsx
@@ -0,0 +1,75 @@
+import { Helmet } from "react-helmet";
+import { faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, DeleteActionModal } from "@app/components/v2";
+import { usePopUp } from "@app/hooks";
+import { useDeleteSharedSecret } from "@app/hooks/api/secretSharing";
+
+import { AddShareSecretModal } from "./AddShareSecretModal";
+import { ShareSecretsTable } from "./ShareSecretsTable";
+
+type DeleteModalData = { name: string; id: string };
+
+export const ShareSecretSection = () => {
+ const deleteSharedSecret = useDeleteSharedSecret();
+ const { popUp, handlePopUpToggle, handlePopUpClose, handlePopUpOpen } = usePopUp([
+ "createSharedSecret",
+ "deleteSharedSecretConfirmation"
+ ] as const);
+
+ const onDeleteApproved = async () => {
+ try {
+ deleteSharedSecret.mutateAsync({
+ sharedSecretId: (popUp?.deleteSharedSecretConfirmation?.data as DeleteModalData)?.id
+ });
+ createNotification({
+ text: "Successfully deleted shared secret",
+ type: "success"
+ });
+
+ handlePopUpClose("deleteSharedSecretConfirmation");
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to delete shared secret",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <Helmet>
+ <title>Secret Sharing</title>
+ <link rel="icon" href="/infisical.ico" />
+ <meta property="og:image" content="/images/message.png" />
+ </Helmet>
+ <div className="mb-4 flex justify-between">
+ <p className="text-xl font-semibold text-mineshaft-100">Shared Secrets</p>
+ <Button
+ colorSchema="primary"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ onClick={() => {
+ handlePopUpOpen("createSharedSecret");
+ }}
+ >
+ Share Secret
+ </Button>
+ </div>
+ <ShareSecretsTable handlePopUpOpen={handlePopUpOpen} />
+ <AddShareSecretModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
+ <DeleteActionModal
+ isOpen={popUp.deleteSharedSecretConfirmation.isOpen}
+ title={`Delete ${
+ (popUp?.deleteSharedSecretConfirmation?.data as DeleteModalData)?.name || " "
+ } shared secret?`}
+ onChange={(isOpen) => handlePopUpToggle("deleteSharedSecretConfirmation", isOpen)}
+ deleteKey={(popUp?.deleteSharedSecretConfirmation?.data as DeleteModalData)?.name}
+ onClose={() => handlePopUpClose("deleteSharedSecretConfirmation")}
+ onDeleteApproved={onDeleteApproved}
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/ShareSecretsRow.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/ShareSecretsRow.tsx
new file mode 100644
index 0000000000..2394253e73
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/ShareSecretsRow.tsx
@@ -0,0 +1,75 @@
+import { faEnvelope, faEnvelopeOpen, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { format } from "date-fns";
+
+import { IconButton, Td, Tooltip, Tr } from "@app/components/v2";
+import { Badge } from "@app/components/v2/Badge";
+import { TSharedSecret } from "@app/hooks/api/secretSharing";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+export const ShareSecretsRow = ({
+ row,
+ handlePopUpOpen
+}: {
+ row: TSharedSecret;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["deleteSharedSecretConfirmation"]>,
+ {
+ name,
+ id
+ }: {
+ name: string;
+ id: string;
+ }
+ ) => void;
+}) => {
+ // const [isRowExpanded, setIsRowExpanded] = useToggle();
+ const lastViewedAt = row.lastViewedAt
+ ? format(new Date(row.lastViewedAt), "yyyy-MM-dd - HH:mm a")
+ : undefined;
+
+ let isExpired = false;
+ if (row.expiresAfterViews !== null && row.expiresAfterViews <= 0) {
+ isExpired = true;
+ }
+
+ if (row.expiresAt !== null && new Date(row.expiresAt) < new Date()) {
+ isExpired = true;
+ }
+
+ return (
+ <Tr
+ key={row.id}
+ // className="h-10 cursor-pointer transition-colors duration-300 hover:bg-mineshaft-700"
+ // onClick={() => setIsRowExpanded.toggle()}
+ >
+ <Td>
+ <Tooltip content={lastViewedAt ? `Last opened at ${lastViewedAt}` : "Not yet opened"}>
+ <FontAwesomeIcon icon={lastViewedAt ? faEnvelopeOpen : faEnvelope} />
+ </Tooltip>
+ </Td>
+ <Td>{row.name ? `${row.name}` : "-"}</Td>
+ <Td>
+ <Badge variant={isExpired ? "danger" : "success"}>{isExpired ? "Expired" : "Active"}</Badge>
+ </Td>
+ <Td>{`${format(new Date(row.createdAt), "yyyy-MM-dd - HH:mm a")}`}</Td>
+ <Td>{format(new Date(row.expiresAt), "yyyy-MM-dd - HH:mm a")}</Td>
+ <Td>{row.expiresAfterViews !== null ? row.expiresAfterViews : "-"}</Td>
+ <Td>
+ <IconButton
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("deleteSharedSecretConfirmation", {
+ name: "delete",
+ id: row.id
+ });
+ }}
+ variant="plain"
+ ariaLabel="delete"
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </Td>
+ </Tr>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/ShareSecretsTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/ShareSecretsTable.tsx
new file mode 100644
index 0000000000..bdb2b2ffa1
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/ShareSecretsTable.tsx
@@ -0,0 +1,79 @@
+import { useState } from "react";
+import { faKey } from "@fortawesome/free-solid-svg-icons";
+
+import {
+ EmptyState,
+ Pagination,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useGetSharedSecrets } from "@app/hooks/api/secretSharing";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+import { ShareSecretsRow } from "./ShareSecretsRow";
+
+type Props = {
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["deleteSharedSecretConfirmation"]>,
+ {
+ name,
+ id
+ }: {
+ name: string;
+ id: string;
+ }
+ ) => void;
+};
+
+export const ShareSecretsTable = ({ handlePopUpOpen }: Props) => {
+ const [page, setPage] = useState(1);
+ const [perPage, setPerPage] = useState(10);
+ const { isLoading, data } = useGetSharedSecrets({
+ offset: (page - 1) * perPage,
+ limit: perPage
+ });
+ return (
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="w-5" />
+ <Th>Name</Th>
+ <Th>Status</Th>
+ <Th>Created At</Th>
+ <Th>Valid Until</Th>
+ <Th>Views Left</Th>
+ <Th aria-label="button" className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={7} innerKey="shared-secrets" />}
+ {!isLoading &&
+ data?.secrets?.map((row) => (
+ <ShareSecretsRow key={row.id} row={row} handlePopUpOpen={handlePopUpOpen} />
+ ))}
+ </TBody>
+ </Table>
+ {!isLoading &&
+ data?.secrets &&
+ data?.totalCount >= perPage &&
+ data?.totalCount !== undefined && (
+ <Pagination
+ count={data.totalCount}
+ page={page}
+ perPage={perPage}
+ onChangePage={(newPage) => setPage(newPage)}
+ onChangePerPage={(newPerPage) => setPerPage(newPerPage)}
+ />
+ )}
+ {!isLoading && !data?.secrets?.length && (
+ <EmptyState title="No secrets shared yet" icon={faKey} />
+ )}
+ </TableContainer>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/index.tsx
new file mode 100644
index 0000000000..64a0c27747
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/-components/index.tsx
@@ -0,0 +1 @@
+export { ShareSecretSection } from "./ShareSecretSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/index.tsx
new file mode 100644
index 0000000000..d1028009a7
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/secret-sharing/index.tsx
@@ -0,0 +1,55 @@
+import { Helmet } from "react-helmet";
+import { useTranslation } from "react-i18next";
+import { faArrowUpRightFromSquare } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { createFileRoute } from "@tanstack/react-router";
+
+import { ShareSecretSection } from "./-components";
+
+const SecretSharing = () => {
+ const { t } = useTranslation();
+
+ return (
+ <>
+ <Helmet>
+ <title>{t("common.head-title", { title: t("approval.title") })}</title>
+ <link rel="icon" href="/infisical.ico" />
+ <meta property="og:image" content="/images/message.png" />
+ <meta property="og:title" content={String(t("approval.og-title"))} />
+ <meta name="og:description" content={String(t("approval.og-description"))} />
+ </Helmet>
+ <div className="h-full">
+ <div className="container mx-auto h-full w-full max-w-7xl bg-bunker-800 px-6 text-white">
+ <div className="flex items-center justify-between py-6">
+ <div className="flex w-full flex-col">
+ <h2 className="text-3xl font-semibold text-gray-200">Secret Sharing</h2>
+ <p className="text-bunker-300">Share secrets securely using a shareable link</p>
+ </div>
+ <div className="flex w-max justify-center">
+ <a
+ target="_blank"
+ rel="noopener noreferrer"
+ href="https://infisical.com/docs/documentation/platform/secret-sharing"
+ >
+ <div className="w-max cursor-pointer rounded-md border border-mineshaft-500 bg-mineshaft-600 px-4 py-2 text-mineshaft-200 duration-200 hover:border-primary/40 hover:bg-primary/10 hover:text-white">
+ Documentation{" "}
+ <FontAwesomeIcon
+ icon={faArrowUpRightFromSquare}
+ className="mb-[0.06rem] ml-1 text-xs"
+ />
+ </div>
+ </a>
+ </div>
+ </div>
+ <ShareSecretSection />
+ </div>
+ </div>
+ </>
+ );
+};
+
+export const Route = createFileRoute(
+ "/_authenticate/_org_details/_org-layout/organization/$organizationId/secret-sharing/"
+)({
+ component: SecretSharing
+});
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/AuditLogStreamTab/AuditLogStreamForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/AuditLogStreamTab/AuditLogStreamForm.tsx
new file mode 100644
index 0000000000..d4bc35ac9f
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/AuditLogStreamTab/AuditLogStreamForm.tsx
@@ -0,0 +1,207 @@
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, FormLabel, IconButton, Input, Spinner } from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import {
+ useCreateAuditLogStream,
+ useGetAuditLogStreamDetails,
+ useUpdateAuditLogStream
+} from "@app/hooks/api";
+
+type Props = {
+ id?: string;
+ onClose: () => void;
+};
+
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+const formSchema = z.object({
+ url: z.string().url().min(1),
+ headers: z
+ .object({
+ key: z.string(),
+ value: z.string()
+ })
+ .array()
+ .optional()
+});
+type TForm = z.infer<typeof formSchema>;
+
+export const AuditLogStreamForm = ({ id = "", onClose }: Props) => {
+ const isEdit = Boolean(id);
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+
+ const auditLogStream = useGetAuditLogStreamDetails(id);
+ const createAuditLogStream = useCreateAuditLogStream();
+ const updateAuditLogStream = useUpdateAuditLogStream();
+
+ const {
+ handleSubmit,
+ control,
+ setValue,
+ getValues,
+ formState: { isSubmitting }
+ } = useForm<TForm>({
+ values: auditLogStream?.data,
+ defaultValues: {
+ headers: [{ key: "", value: "" }]
+ }
+ });
+
+ const headerFields = useFieldArray({
+ control,
+ name: "headers"
+ });
+
+ const handleAuditLogStreamEdit = async ({ headers, url }: TForm) => {
+ if (!id) return;
+ try {
+ await updateAuditLogStream.mutateAsync({
+ id,
+ orgId,
+ headers,
+ url
+ });
+ createNotification({
+ type: "success",
+ text: "Successfully updated stream"
+ });
+ onClose();
+ } catch (err) {
+ console.log(err);
+ createNotification({
+ type: "error",
+ text: "Failed to update stream"
+ });
+ }
+ };
+
+ const handleFormSubmit = async ({ headers = [], url }: TForm) => {
+ if (isSubmitting) return;
+ const sanitizedHeaders = headers.filter(({ key, value }) => Boolean(key) && Boolean(value));
+ const streamHeaders = sanitizedHeaders.length ? sanitizedHeaders : undefined;
+ if (isEdit) {
+ await handleAuditLogStreamEdit({ headers: streamHeaders, url });
+ return;
+ }
+ try {
+ await createAuditLogStream.mutateAsync({
+ orgId,
+ headers: streamHeaders,
+ url
+ });
+ createNotification({
+ type: "success",
+ text: "Successfully created stream"
+ });
+ onClose();
+ } catch (err) {
+ console.log(err);
+ createNotification({
+ type: "error",
+ text: "Failed to create stream"
+ });
+ }
+ };
+
+ if (isEdit && auditLogStream.isLoading) {
+ return (
+ <div className="flex items-center justify-center p-8">
+ <Spinner size="lg" />
+ </div>
+ );
+ }
+
+ return (
+ <form onSubmit={handleSubmit(handleFormSubmit)} autoComplete="off">
+ <div>
+ <Controller
+ control={control}
+ name="url"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Endpoint URL"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ <FormLabel label="Headers" isOptional />
+ {headerFields.fields.map(({ id: headerFieldId }, i) => (
+ <div key={headerFieldId} className="flex space-x-2">
+ <Controller
+ control={control}
+ name={`headers.${i}.key`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="w-1/3"
+ >
+ <Input {...field} placeholder="Authorization" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name={`headers.${i}.value`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="flex-grow"
+ >
+ <Input
+ {...field}
+ type="password"
+ placeholder="Bearer <token>"
+ autoComplete="new-password"
+ />
+ </FormControl>
+ )}
+ />
+ <IconButton
+ ariaLabel="delete key"
+ className="h-9"
+ variant="outline_bg"
+ onClick={() => {
+ const header = getValues("headers");
+ if (header && header?.length > 1) {
+ headerFields.remove(i);
+ } else {
+ setValue("headers", [{ key: "", value: "" }]);
+ }
+ }}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ ))}
+ <div>
+ <Button
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ variant="outline_bg"
+ onClick={() => headerFields.append({ value: "", key: "" })}
+ >
+ Add Key
+ </Button>
+ </div>
+ </div>
+ <div className="mt-8 flex items-center">
+ <Button className="mr-4" type="submit" isLoading={isSubmitting}>
+ {isEdit ? "Save" : "Create"}
+ </Button>
+ <Button variant="plain" colorSchema="secondary" onClick={onClose}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/AuditLogStreamTab/AuditLogStreamTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/AuditLogStreamTab/AuditLogStreamTab.tsx
new file mode 100644
index 0000000000..ddbcc79599
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/AuditLogStreamTab/AuditLogStreamTab.tsx
@@ -0,0 +1,197 @@
+import { faPlug, faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ DeleteActionModal,
+ EmptyState,
+ Modal,
+ ModalContent,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ THead,
+ Tr,
+ UpgradePlanModal
+} from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { withPermission } from "@app/hoc";
+import { usePopUp } from "@app/hooks";
+import { useDeleteAuditLogStream, useGetAuditLogStreams } from "@app/hooks/api";
+
+import { AuditLogStreamForm } from "./AuditLogStreamForm";
+
+export const AuditLogStreamsTab = withPermission(
+ () => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg?.id || "";
+ const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([
+ "auditLogStreamForm",
+ "deleteAuditLogStream",
+ "upgradePlan"
+ ] as const);
+ const { subscription } = useSubscription();
+
+ const { data: auditLogStreams, isLoading: isAuditLogStreamsLoading } =
+ useGetAuditLogStreams(orgId);
+
+ // mutation
+ const { mutateAsync: deleteAuditLogStream } = useDeleteAuditLogStream();
+
+ const handleAuditLogStreamDelete = async () => {
+ try {
+ const auditLogStreamId = popUp?.deleteAuditLogStream?.data as string;
+ await deleteAuditLogStream({
+ id: auditLogStreamId,
+ orgId
+ });
+ handlePopUpClose("deleteAuditLogStream");
+ createNotification({
+ type: "success",
+ text: "Successfully deleted stream"
+ });
+ } catch (err) {
+ console.log(err);
+ createNotification({
+ type: "error",
+ text: "Failed to delete stream"
+ });
+ }
+ };
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex justify-between">
+ <p className="text-xl font-semibold text-mineshaft-100">Audit Log Streams</p>
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Settings}>
+ {(isAllowed) => (
+ <Button
+ onClick={() => {
+ if (subscription && !subscription?.auditLogStreams) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+ handlePopUpOpen("auditLogStreamForm");
+ }}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ isDisabled={!isAllowed}
+ >
+ Create
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="mb-8 text-gray-400">
+ Send audit logs from Infisical to external logging providers via HTTP
+ </p>
+ <div>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Td>URL</Td>
+ <Td className="text-right">Action</Td>
+ </Tr>
+ </THead>
+ <TBody>
+ {isAuditLogStreamsLoading && (
+ <TableSkeleton columns={2} innerKey="stream-loading" />
+ )}
+ {!isAuditLogStreamsLoading && auditLogStreams && auditLogStreams?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No audit log streams found" icon={faPlug} />
+ </Td>
+ </Tr>
+ )}
+ {!isAuditLogStreamsLoading &&
+ auditLogStreams?.map(({ id, url }) => (
+ <Tr key={id}>
+ <Td className="max-w-xs overflow-hidden text-ellipsis hover:overflow-auto hover:break-all">
+ {url}
+ </Td>
+ <Td>
+ <div className="flex items-center justify-end space-x-2">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.Settings}
+ >
+ {(isAllowed) => (
+ <Button
+ variant="outline_bg"
+ size="xs"
+ isDisabled={!isAllowed}
+ onClick={() => handlePopUpOpen("auditLogStreamForm", id)}
+ >
+ Edit
+ </Button>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.Settings}
+ >
+ {(isAllowed) => (
+ <Button
+ variant="outline_bg"
+ className="border-red-800 bg-red-800 hover:border-red-700 hover:bg-red-700"
+ colorSchema="danger"
+ size="xs"
+ isDisabled={!isAllowed}
+ onClick={() => handlePopUpOpen("deleteAuditLogStream", id)}
+ >
+ Delete
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ </Td>
+ </Tr>
+ ))}
+ </TBody>
+ </Table>
+ </TableContainer>
+ </div>
+ <Modal
+ isOpen={popUp.auditLogStreamForm.isOpen}
+ onOpenChange={(isModalOpen) => {
+ handlePopUpToggle("auditLogStreamForm", isModalOpen);
+ }}
+ >
+ <ModalContent
+ title={`${popUp?.auditLogStreamForm?.data ? "Update" : "Create"} Audit Log Stream `}
+ subTitle="Continuously stream logs from Infisical to third-party logging providers."
+ >
+ <AuditLogStreamForm
+ id={popUp?.auditLogStreamForm?.data as string}
+ onClose={() => handlePopUpToggle("auditLogStreamForm")}
+ />
+ </ModalContent>
+ </Modal>
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text="You can add audit log streams if you switch to Infisical's Enterprise plan."
+ />
+ <DeleteActionModal
+ isOpen={popUp.deleteAuditLogStream.isOpen}
+ deleteKey="delete"
+ title="Are you sure you want to remove this stream?"
+ onChange={(isOpen) => handlePopUpToggle("deleteAuditLogStream", isOpen)}
+ onClose={() => handlePopUpClose("deleteAuditLogStream")}
+ onDeleteApproved={handleAuditLogStreamDelete}
+ />
+ </div>
+ );
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Settings }
+);
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/AuditLogStreamTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/AuditLogStreamTab/index.tsx
new file mode 100644
index 0000000000..ecce21f3b6
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/AuditLogStreamTab/index.tsx
@@ -0,0 +1 @@
+export { AuditLogStreamsTab } from "./AuditLogStreamTab";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/ImportTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/ImportTab.tsx
new file mode 100644
index 0000000000..4dbd517815
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/ImportTab.tsx
@@ -0,0 +1,58 @@
+import { faArrowUpRightFromSquare, faBookOpen, faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { Button } from "@app/components/v2";
+import { useOrgPermission } from "@app/context";
+import { usePopUp } from "@app/hooks";
+import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
+
+import { SelectImportFromPlatformModal } from "./components/SelectImportFromPlatformModal";
+
+export const ImportTab = () => {
+ const { membership } = useOrgPermission();
+
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["selectImportPlatform"] as const);
+
+ return (
+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex justify-between">
+ <div className="flex items-center gap-2">
+ <p className="text-xl font-semibold text-mineshaft-100">Import from external source</p>
+
+ <div>
+ <a
+ target="_blank"
+ rel="noopener noreferrer"
+ href="https://infisical.com/docs/documentation/guides/migrating-from-envkey"
+ >
+ <div className="ml-2 inline-block rounded-md bg-yellow/20 px-1.5 pb-[0.03rem] pt-[0.04rem] text-sm text-yellow opacity-80 hover:opacity-100">
+ <FontAwesomeIcon icon={faBookOpen} className="mr-1.5" />
+ Docs
+ <FontAwesomeIcon
+ icon={faArrowUpRightFromSquare}
+ className="mb-[0.07rem] ml-1.5 text-xxs"
+ />
+ </div>
+ </a>
+ </div>
+ </div>
+
+ <Button
+ onClick={() => {
+ handlePopUpOpen("selectImportPlatform");
+ }}
+ isDisabled={membership?.role !== ProjectMembershipRole.Admin}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ >
+ Import
+ </Button>
+ </div>
+ <p className="mb-4 text-gray-400">Import data from another platform to Infisical.</p>
+
+ <SelectImportFromPlatformModal
+ isOpen={popUp.selectImportPlatform.isOpen}
+ onToggle={(state) => handlePopUpToggle("selectImportPlatform", state)}
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/components/EnvKeyPlatformModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/components/EnvKeyPlatformModal.tsx
new file mode 100644
index 0000000000..c05fd6ab08
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/components/EnvKeyPlatformModal.tsx
@@ -0,0 +1,121 @@
+import { useRef } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, Input } from "@app/components/v2";
+import { useImportEnvKey } from "@app/hooks/api/migration/mutations";
+// TODO(rbr): Bring back this later
+// import { GenericDropzone } from "@app/views/SecretMainPage/components/SecretDropzone/GenericDropzone";
+
+type Props = {
+ id?: string;
+ onClose: () => void;
+};
+
+export const EnvKeyPlatformModal = ({ onClose }: Props) => {
+ const formSchema = z.object({
+ encryptionKey: z.string().min(1),
+ file: z.instanceof(File)
+ });
+ type TFormData = z.infer<typeof formSchema>;
+
+ const fileUploadRef = useRef<HTMLInputElement>(null);
+
+ const { mutateAsync: importEnvKey } = useImportEnvKey();
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ setValue,
+ setError,
+ formState: { isLoading, isDirty, isSubmitting, isValid }
+ } = useForm<TFormData>({
+ resolver: zodResolver(formSchema)
+ });
+
+ const onSubmit = async (data: TFormData) => {
+ if (!data.file) {
+ setError("file", {
+ type: "required",
+ message: "File is required"
+ });
+ return;
+ }
+
+ try {
+ await importEnvKey({
+ file: data.file,
+ decryptionKey: data.encryptionKey
+ });
+ createNotification({
+ title: "Import started",
+ text: "Your data is being imported. You will receive an email when the import is complete or if the import fails. This may take up to 10 minutes.",
+ type: "info"
+ });
+
+ onClose();
+ reset();
+
+ if (fileUploadRef.current) {
+ fileUploadRef.current.value = "";
+ }
+ } catch {
+ reset();
+ }
+ };
+
+ const onImportFileDrop = (file?: File) => {
+ if (!file) {
+ createNotification({
+ text: "No file selected.",
+ type: "error"
+ });
+ return;
+ }
+
+ setValue("file", file, { shouldDirty: true, shouldValidate: true });
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onSubmit)} autoComplete="off">
+ <Controller
+ control={control}
+ name="encryptionKey"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Encryption key"
+ isRequired
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input type="password" placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+
+ {
+ // <GenericDropzone
+ // ref={fileUploadRef}
+ // text="Select Env Key export file"
+ // onData={onImportFileDrop}
+ // isSmaller
+ // />
+ }
+ <div className="mt-6 flex items-center space-x-4">
+ <Button
+ type="submit"
+ isLoading={isLoading}
+ isDisabled={!isDirty || isSubmitting || isLoading || !isValid}
+ >
+ Import data
+ </Button>
+ <Button variant="outline_bg" onClick={onClose}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/components/SelectImportFromPlatformModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/components/SelectImportFromPlatformModal.tsx
new file mode 100644
index 0000000000..3dfbd9b7bd
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/components/SelectImportFromPlatformModal.tsx
@@ -0,0 +1,101 @@
+import { useState } from "react";
+import { faKey } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { AnimatePresence, motion } from "framer-motion";
+
+import { Modal, ModalContent } from "@app/components/v2";
+
+import { EnvKeyPlatformModal } from "./EnvKeyPlatformModal";
+
+type Props = {
+ isOpen?: boolean;
+ onToggle: (isOpen: boolean) => void;
+};
+
+enum WizardSteps {
+ SelectPlatform = "select-platform",
+ PlatformInputs = "platform-inputs"
+}
+
+const PLATFORM_LIST = [
+ {
+ icon: faKey,
+ platform: "env-key",
+ title: "Env Key"
+ }
+] as const;
+
+export const SelectImportFromPlatformModal = ({ isOpen, onToggle }: Props) => {
+ const [wizardStep, setWizardStep] = useState(WizardSteps.SelectPlatform);
+ const [selectedPlatform, setSelectedPlatform] = useState<(typeof PLATFORM_LIST)[number] | null>(
+ null
+ );
+
+ const handleFormReset = (state: boolean = false) => {
+ onToggle(state);
+ setWizardStep(WizardSteps.SelectPlatform);
+ setSelectedPlatform(null);
+ };
+
+ return (
+ <Modal isOpen={isOpen} onOpenChange={(state) => handleFormReset(state)}>
+ <ModalContent
+ title={
+ selectedPlatform ? `Import from ${selectedPlatform.title}` : "Import from external source"
+ }
+ className="my-4"
+ >
+ <AnimatePresence exitBeforeEnter>
+ {wizardStep === WizardSteps.SelectPlatform && (
+ <motion.div
+ key="select-type-step"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <div className="mb-4 text-sm text-mineshaft-300">
+ Select a platform to import from
+ </div>
+ <div className="flex items-center space-x-4">
+ {PLATFORM_LIST.map((platform, idx) => (
+ <div
+ key={`platform-${idx + 1}`}
+ className="flex h-28 w-32 cursor-pointer flex-col items-center space-y-4 rounded border border-mineshaft-500 bg-bunker-600 p-6 transition-all hover:border-primary/70 hover:bg-primary/10 hover:text-white"
+ role="button"
+ tabIndex={0}
+ onClick={() => {
+ setSelectedPlatform(platform);
+ setWizardStep(WizardSteps.PlatformInputs);
+ }}
+ onKeyDown={(evt) => {
+ if (evt.key === "Enter") {
+ setSelectedPlatform(platform);
+ setWizardStep(WizardSteps.PlatformInputs);
+ }
+ }}
+ >
+ <FontAwesomeIcon icon={platform.icon} size="lg" />
+ <div className="whitespace-pre-wrap text-center text-sm">{platform.title}</div>
+ </div>
+ ))}
+ </div>
+ </motion.div>
+ )}
+ {wizardStep === WizardSteps.PlatformInputs &&
+ selectedPlatform?.platform === "env-key" && (
+ <motion.div
+ key="env-key-step"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <EnvKeyPlatformModal onClose={() => handleFormReset(false)} />
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/index.tsx
new file mode 100644
index 0000000000..0679ab33f5
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ImportTab/index.tsx
@@ -0,0 +1 @@
+export { ImportTab } from "./ImportTab";
\ No newline at end of file
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/ExternalGroupOrgRoleMappings.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/ExternalGroupOrgRoleMappings.tsx
new file mode 100644
index 0000000000..4972d8d6d8
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/ExternalGroupOrgRoleMappings.tsx
@@ -0,0 +1,214 @@
+import { useEffect } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ FormControl,
+ FormLabel,
+ IconButton,
+ Input,
+ Select,
+ SelectItem,
+ Spinner
+} from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useOrgPermission
+} from "@app/context";
+import { isCustomOrgRole } from "@app/helpers/roles";
+import { useGetOrgRoles } from "@app/hooks/api";
+import {
+ useGetExternalGroupOrgRoleMappings,
+ useUpdateExternalGroupOrgRoleMappings
+} from "@app/hooks/api/externalGroupOrgRoleMappings";
+
+const formSchema = z.object({
+ mappings: z
+ .object({
+ groupName: z.string().trim().min(1, { message: "Group name is required" }),
+ roleSlug: z.string()
+ })
+ .array()
+});
+
+type TForm = z.infer<typeof formSchema>;
+
+export const ExternalGroupOrgRoleMappings = () => {
+ const { currentOrg } = useOrganization();
+ const { data: roles, isLoading: isRolesLoading } = useGetOrgRoles(currentOrg.id);
+ const { data: mappings } = useGetExternalGroupOrgRoleMappings();
+ const updateMappings = useUpdateExternalGroupOrgRoleMappings();
+ const { permission } = useOrgPermission();
+
+ const {
+ control,
+ formState: { isDirty },
+ handleSubmit,
+ reset
+ } = useForm<TForm>({
+ defaultValues: { mappings: [] },
+ resolver: zodResolver(formSchema)
+ });
+
+ useEffect(() => {
+ if (!mappings || !roles) return;
+
+ reset({
+ mappings: mappings.map((mapping) => ({
+ groupName: mapping.groupName,
+ roleSlug:
+ mapping.role === "custom"
+ ? roles.find((role) => mapping.roleId === role.id)!.slug
+ : mapping.role
+ }))
+ });
+ }, [mappings, roles]);
+
+ const mappingField = useFieldArray({ control, name: "mappings" });
+
+ const handleUpdateMappings = async (form: TForm) => {
+ try {
+ await updateMappings.mutateAsync(form);
+ createNotification({
+ text: "Group organization role mappings updated.",
+ type: "success"
+ });
+ } catch (e) {
+ console.error(e);
+ createNotification({
+ text: "Failed to update group organization role mappings.",
+ type: "error"
+ });
+ }
+ };
+
+ const disableScimEdit = permission.cannot(OrgPermissionActions.Edit, OrgPermissionSubjects.Scim);
+
+ return (
+ <div className="py-4">
+ <h2 className="text-md text-mineshaft-100">SCIM Group to Organization Role Mappings</h2>
+ <p className="text-sm text-mineshaft-300">
+ Assign newly provisioned users a default organization role based on their SCIM group.
+ </p>
+ <form onSubmit={handleSubmit(handleUpdateMappings)} className="pt-4">
+ {isRolesLoading || isRolesLoading ? (
+ <Spinner className="self-center" size="sm" />
+ ) : (
+ <div className="mb-2 flex flex-col space-y-2">
+ {mappingField.fields.map(({ id: scopeFieldId }, i) => (
+ <div key={scopeFieldId} className="flex items-end space-x-2">
+ <div className="flex-grow">
+ {i === 0 && (
+ <FormLabel
+ label="SCIM Group Name"
+ className="text-xs text-mineshaft-400"
+ tooltipClassName="max-w-md whitespace-pre-line"
+ tooltipText="The name associated with this group in your SCIM provider"
+ />
+ )}
+ <Controller
+ control={control}
+ name={`mappings.${i}.groupName`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0 flex-grow"
+ >
+ <Input
+ isDisabled={disableScimEdit}
+ {...field}
+ placeholder="SCIM group identifier..."
+ />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="flex-1">
+ {i === 0 && (
+ <span className="text-xs text-mineshaft-400">
+ Role to Assign Users in this Group
+ </span>
+ )}
+ <Controller
+ control={control}
+ name={`mappings.${i}.roleSlug`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0 flex-grow"
+ >
+ <Select
+ isDisabled={disableScimEdit}
+ {...field}
+ onValueChange={(e) => field.onChange(e)}
+ className="w-full"
+ >
+ {roles?.map((role) => (
+ <SelectItem value={role.slug} key={`role-${role.id}`}>
+ {role.name}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ </div>
+ <IconButton
+ ariaLabel="delete key"
+ className="bottom-0.5 h-9"
+ variant="outline_bg"
+ isDisabled={disableScimEdit}
+ onClick={() => {
+ mappingField.remove(i);
+ }}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ ))}
+ <div>
+ <Button
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ variant="outline_bg"
+ isDisabled={disableScimEdit}
+ onClick={() =>
+ mappingField.append({
+ groupName: "",
+ roleSlug: isCustomOrgRole(currentOrg!.defaultMembershipRole)
+ ? roles?.find((role) => currentOrg?.defaultMembershipRole === role.id)
+ ?.slug || ""
+ : currentOrg!.defaultMembershipRole
+ })
+ }
+ >
+ Add Mapping
+ </Button>
+ </div>
+ {isDirty && (
+ <div className="flex w-full justify-end">
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Scim}>
+ {(isAllowed) => (
+ <Button isDisabled={!isAllowed} colorSchema="secondary" type="submit">
+ Update Mappings
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ )}
+ </div>
+ )}
+ </form>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/LDAPGroupMapModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/LDAPGroupMapModal.tsx
new file mode 100644
index 0000000000..882d5f918c
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/LDAPGroupMapModal.tsx
@@ -0,0 +1,296 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { faUsers, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ DeleteActionModal,
+ EmptyState,
+ FormControl,
+ IconButton,
+ Input,
+ Modal,
+ ModalContent,
+ Select,
+ SelectItem,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import {
+ useCreateLDAPGroupMapping,
+ useDeleteLDAPGroupMapping,
+ useGetLDAPConfig,
+ useGetLDAPGroupMaps,
+ useGetOrganizationGroups
+} from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+import { useNavigate } from "@tanstack/react-router";
+
+const schema = z.object({
+ ldapGroupCN: z.string().min(1, "LDAP Group CN is required"),
+ groupSlug: z.string().min(1, "Group Slug is required")
+});
+
+export type TFormData = z.infer<typeof schema>;
+
+type Props = {
+ popUp: UsePopUpState<["ldapGroupMap", "deleteLdapGroupMap"]>;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["deleteLdapGroupMap"]>,
+ data?: {
+ ldapGroupMapId: string;
+ ldapGroupCN: string;
+ }
+ ) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["ldapGroupMap", "deleteLdapGroupMap"]>,
+ state?: boolean
+ ) => void;
+};
+
+export const LDAPGroupMapModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Props) => {
+ const { currentOrg } = useOrganization();
+
+ const { data: ldapConfig } = useGetLDAPConfig(currentOrg?.id ?? "");
+ const { data: groups } = useGetOrganizationGroups(currentOrg?.id ?? "");
+ const { data: groupMaps, isLoading } = useGetLDAPGroupMaps(ldapConfig?.id ?? "");
+ const { mutateAsync: createLDAPGroupMapping, isLoading: createIsLoading } =
+ useCreateLDAPGroupMapping();
+ const { mutateAsync: deleteLDAPGroupMapping } = useDeleteLDAPGroupMapping();
+ const navigate = useNavigate();
+
+ const { control, handleSubmit, reset, setValue } = useForm<TFormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ ldapGroupCN: "",
+ groupSlug: ""
+ }
+ });
+
+ const onFormSubmit = async ({ groupSlug, ldapGroupCN }: TFormData) => {
+ try {
+ if (!ldapConfig) return;
+
+ await createLDAPGroupMapping({
+ ldapConfigId: ldapConfig.id,
+ groupSlug,
+ ldapGroupCN
+ });
+
+ reset();
+
+ createNotification({
+ text: `Successfully added LDAP group mapping for ${ldapGroupCN}`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: `Failed to add LDAP group mapping for ${ldapGroupCN}`,
+ type: "error"
+ });
+ }
+ };
+
+ const onDeleteGroupMapSubmit = async ({
+ ldapConfigId,
+ ldapGroupMapId,
+ ldapGroupCN
+ }: {
+ ldapConfigId: string;
+ ldapGroupMapId: string;
+ ldapGroupCN: string;
+ }) => {
+ try {
+ await deleteLDAPGroupMapping({
+ ldapConfigId,
+ ldapGroupMapId
+ });
+
+ handlePopUpToggle("deleteLdapGroupMap", false);
+
+ createNotification({
+ text: `Successfully deleted LDAP group mapping ${ldapGroupCN}`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: `Failed to delete LDAP group mapping ${ldapGroupCN}`,
+ type: "error"
+ });
+ }
+ };
+
+ useEffect(() => {
+ if (groups && groups.length > 0) {
+ setValue("groupSlug", groups[0].slug);
+ }
+ }, [groups, popUp.ldapGroupMap.isOpen]);
+
+ return (
+ <Modal
+ isOpen={popUp?.ldapGroupMap?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("ldapGroupMap", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent title="Manage LDAP Group Mappings">
+ {groups && groups.length > 0 && (
+ <>
+ <h2 className="mb-4">New Group Mapping</h2>
+ <form onSubmit={handleSubmit(onFormSubmit)} className="mb-8">
+ <div className="flex">
+ <Controller
+ control={control}
+ name="ldapGroupCN"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="LDAP Group CN"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input {...field} placeholder="Engineering" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="groupSlug"
+ defaultValue=""
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl
+ label="Infisical Group"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ className="ml-4 w-full"
+ >
+ <div className="flex">
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ className="w-full"
+ >
+ {(groups || []).map(({ name, id, slug }) => (
+ <SelectItem value={slug} key={`internal-group-${id}`}>
+ {name}
+ </SelectItem>
+ ))}
+ </Select>
+ <Button
+ className="ml-4"
+ size="sm"
+ type="submit"
+ isLoading={createIsLoading}
+ >
+ Add mapping
+ </Button>
+ </div>
+ </FormControl>
+ )}
+ />
+ </div>
+ </form>
+ <h2 className="mb-4">Group Mappings</h2>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th>LDAP Group CN</Th>
+ <Th>Infisical Group</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={3} innerKey="ldap-group-maps" />}
+ {!isLoading &&
+ groupMaps?.map(({ id, ldapGroupCN, group }) => {
+ return (
+ <Tr className="h-10 items-center" key={`ldap-group-map-${id}`}>
+ <Td>{ldapGroupCN}</Td>
+ <Td>{group.name}</Td>
+ <Td>
+ <IconButton
+ onClick={() => {
+ handlePopUpOpen("deleteLdapGroupMap", {
+ ldapGroupMapId: id,
+ ldapGroupCN
+ });
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </Td>
+ </Tr>
+ );
+ })}
+ </TBody>
+ </Table>
+ {groupMaps?.length === 0 && (
+ <EmptyState title="No LDAP group mappings found" icon={faUsers} />
+ )}
+ </TableContainer>
+ <DeleteActionModal
+ isOpen={popUp.deleteLdapGroupMap.isOpen}
+ title={`Are you sure want to delete the group mapping for ${
+ (popUp?.deleteLdapGroupMap?.data as { ldapGroupCN: string })?.ldapGroupCN || ""
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle("deleteLdapGroupMap", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() => {
+ const deleteLdapGroupMapData = popUp?.deleteLdapGroupMap?.data as {
+ ldapGroupMapId: string;
+ ldapGroupCN: string;
+ };
+ return onDeleteGroupMapSubmit({
+ ldapConfigId: ldapConfig?.id ?? "",
+ ldapGroupMapId: deleteLdapGroupMapData.ldapGroupMapId,
+ ldapGroupCN: deleteLdapGroupMapData.ldapGroupCN
+ });
+ }}
+ />
+ </>
+ )}
+ {groups && groups.length === 0 && (
+ <div>
+ <div>
+ You do not have any Infisical groups in your organization. Create one in order to
+ proceed.
+ </div>
+ <Button
+ className="mt-4"
+ size="sm"
+ onClick={() =>
+ navigate({
+ to: "/organization/$organizationId/members",
+ params: {
+ organizationId: currentOrg.id
+ }
+ })
+ }
+ >
+ Create
+ </Button>
+ </div>
+ )}
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/LDAPModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/LDAPModal.tsx
new file mode 100644
index 0000000000..136141bae6
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/LDAPModal.tsx
@@ -0,0 +1,371 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ DeleteActionModal,
+ FormControl,
+ Input,
+ Modal,
+ ModalContent,
+ TextArea
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useToggle } from "@app/hooks";
+import {
+ useCreateLDAPConfig,
+ useGetLDAPConfig,
+ useTestLDAPConnection,
+ useUpdateLDAPConfig
+} from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const LDAPFormSchema = z.object({
+ url: z.string().default(""),
+ bindDN: z.string().default(""),
+ bindPass: z.string().default(""),
+ searchBase: z.string().default(""),
+ searchFilter: z.string().default(""),
+ uniqueUserAttribute: z.string().default(""),
+ groupSearchBase: z.string().default(""),
+ groupSearchFilter: z.string().default(""),
+ caCert: z.string().optional()
+});
+
+export type TLDAPFormData = z.infer<typeof LDAPFormSchema>;
+
+type Props = {
+ popUp: UsePopUpState<["addLDAP"]>;
+ handlePopUpClose: (popUpName: keyof UsePopUpState<["addLDAP"]>) => void;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["addLDAP"]>, state?: boolean) => void;
+ hideDelete?: boolean;
+};
+
+export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelete }: Props) => {
+ const { currentOrg } = useOrganization();
+
+ const { mutateAsync: createMutateAsync, isLoading: createIsLoading } = useCreateLDAPConfig();
+ const { mutateAsync: updateMutateAsync, isLoading: updateIsLoading } = useUpdateLDAPConfig();
+ const { mutateAsync: testLDAPConnection } = useTestLDAPConnection();
+ const { data } = useGetLDAPConfig(currentOrg?.id ?? "");
+
+ const { control, handleSubmit, reset, watch } = useForm<TLDAPFormData>({
+ resolver: zodResolver(LDAPFormSchema)
+ });
+
+ const [isDeletePopupOpen, setIsDeletePopupOpen] = useToggle();
+
+ const handleLdapSoftDelete = async () => {
+ if (!currentOrg) {
+ return;
+ }
+ try {
+ await updateMutateAsync({
+ organizationId: currentOrg.id,
+ isActive: false,
+ url: "",
+ bindDN: "",
+ bindPass: "",
+ searchBase: "",
+ searchFilter: "",
+ uniqueUserAttribute: "",
+ groupSearchBase: "",
+ groupSearchFilter: "",
+ caCert: ""
+ });
+
+ createNotification({
+ text: "Successfully deleted OIDC configuration.",
+ type: "success"
+ });
+ } catch {
+ createNotification({
+ text: "Failed deleting OIDC configuration.",
+ type: "error"
+ });
+ }
+ };
+
+ const watchUrl = watch("url");
+ const watchBindDN = watch("bindDN");
+ const watchBindPass = watch("bindPass");
+ const watchSearchBase = watch("searchBase");
+ const watchSearchFilter = watch("searchFilter");
+ const watchGroupSearchBase = watch("groupSearchBase");
+ const watchGroupSearchFilter = watch("groupSearchFilter");
+ const watchCaCert = watch("caCert");
+ const watchUniqueUserAttribute = watch("uniqueUserAttribute");
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ url: data?.url ?? "",
+ bindDN: data?.bindDN ?? "",
+ bindPass: data?.bindPass ?? "",
+ searchBase: data?.searchBase ?? "",
+ searchFilter: data?.searchFilter ?? "",
+ groupSearchBase: data?.groupSearchBase ?? "",
+ groupSearchFilter: data?.groupSearchFilter ?? "",
+ caCert: data?.caCert ?? "",
+ uniqueUserAttribute: data?.uniqueUserAttribute ?? ""
+ });
+ }
+ }, [data]);
+
+ const onSSOModalSubmit = async ({
+ url,
+ bindDN,
+ bindPass,
+ uniqueUserAttribute,
+ searchBase,
+ searchFilter,
+ groupSearchBase,
+ groupSearchFilter,
+ caCert,
+ shouldCloseModal = true
+ }: TLDAPFormData & { shouldCloseModal?: boolean }) => {
+ try {
+ if (!currentOrg) return;
+
+ if (!data) {
+ await createMutateAsync({
+ organizationId: currentOrg.id,
+ isActive: false,
+ url,
+ bindDN,
+ bindPass,
+ searchBase,
+ searchFilter,
+ uniqueUserAttribute,
+ groupSearchBase,
+ groupSearchFilter,
+ caCert
+ });
+ } else {
+ await updateMutateAsync({
+ organizationId: currentOrg.id,
+ isActive: false,
+ url,
+ bindDN,
+ bindPass,
+ searchBase,
+ searchFilter,
+ uniqueUserAttribute,
+ groupSearchBase,
+ groupSearchFilter,
+ caCert
+ });
+ }
+
+ if (shouldCloseModal) {
+ handlePopUpClose("addLDAP");
+ }
+
+ createNotification({
+ text: `Successfully ${!data ? "added" : "updated"} LDAP configuration`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: `Failed to ${!data ? "add" : "update"} LDAP configuration`,
+ type: "error"
+ });
+ }
+ };
+
+ const handleTestLDAPConnection = async () => {
+ try {
+ await onSSOModalSubmit({
+ url: watchUrl,
+ bindDN: watchBindDN,
+ bindPass: watchBindPass,
+ searchBase: watchSearchBase,
+ searchFilter: watchSearchFilter,
+ groupSearchBase: watchGroupSearchBase,
+ groupSearchFilter: watchGroupSearchFilter,
+ uniqueUserAttribute: watchUniqueUserAttribute,
+ caCert: watchCaCert,
+ shouldCloseModal: false
+ });
+
+ if (!data) return;
+
+ const result = await testLDAPConnection(data.id);
+
+ if (!result) {
+ createNotification({
+ text: "Failed to test the LDAP connection: Bind operation was unsuccessful",
+ type: "error"
+ });
+ return;
+ }
+
+ createNotification({
+ text: "Successfully tested the LDAP connection: Bind operation was successful",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to test the LDAP connection",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <>
+ <Modal
+ isOpen={popUp?.addLDAP?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addLDAP", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent title="Manage LDAP configuration">
+ <form onSubmit={handleSubmit(onSSOModalSubmit)}>
+ <Controller
+ control={control}
+ name="url"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="URL" errorText={error?.message} isError={Boolean(error)}>
+ <Input {...field} placeholder="ldaps://ldap.myorg.com:636" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="bindDN"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Bind DN" errorText={error?.message} isError={Boolean(error)}>
+ <Input {...field} placeholder="cn=infisical,ou=Users,dc=example,dc=com" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="bindPass"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Bind Pass" errorText={error?.message} isError={Boolean(error)}>
+ <Input {...field} type="password" placeholder="********" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="searchBase"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="User Search Base / User DN"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input {...field} placeholder="ou=people,dc=acme,dc=com" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="uniqueUserAttribute"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Unique User Attribute (Optional)"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input {...field} placeholder="uidNumber" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="searchFilter"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="User Search Filter (Optional)"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input {...field} placeholder="(uid={{username}})" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="groupSearchBase"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Group Search Base / Group DN (Optional)"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input {...field} placeholder="ou=groups,dc=acme,dc=com" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="groupSearchFilter"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Group Filter (Optional)"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input
+ {...field}
+ placeholder="(&(objectClass=posixGroup)(memberUid={{.Username}}))"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="caCert"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="CA Certificate"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <TextArea {...field} placeholder="-----BEGIN CERTIFICATE----- ..." />
+ </FormControl>
+ )}
+ />
+ <div className="mt-8 flex justify-between">
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={createIsLoading || updateIsLoading}
+ >
+ {!data ? "Add" : "Update"}
+ </Button>
+ <Button colorSchema="secondary" onClick={handleTestLDAPConnection}>
+ Test Connection
+ </Button>
+ </div>
+ {!hideDelete && (
+ <Button colorSchema="danger" onClick={() => setIsDeletePopupOpen.on()}>
+ Delete
+ </Button>
+ )}
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ <DeleteActionModal
+ isOpen={isDeletePopupOpen}
+ title="Are you sure want to delete LDAP?"
+ onChange={() => setIsDeletePopupOpen.toggle()}
+ deleteKey="confirm"
+ onDeleteApproved={handleLdapSoftDelete}
+ />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OIDCModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OIDCModal.tsx
new file mode 100644
index 0000000000..6df9a118f1
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OIDCModal.tsx
@@ -0,0 +1,458 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ DeleteActionModal,
+ FormControl,
+ Input,
+ Modal,
+ ModalContent,
+ Select,
+ SelectItem
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useToggle } from "@app/hooks";
+import { useGetOIDCConfig } from "@app/hooks/api";
+import { useCreateOIDCConfig, useUpdateOIDCConfig } from "@app/hooks/api/oidcConfig/mutations";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+enum ConfigurationType {
+ CUSTOM = "custom",
+ DISCOVERY_URL = "discoveryURL"
+}
+
+type Props = {
+ popUp: UsePopUpState<["addOIDC"]>;
+ handlePopUpClose: (popUpName: keyof UsePopUpState<["addOIDC"]>) => void;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["addOIDC"]>, state?: boolean) => void;
+ hideDelete?: boolean;
+};
+
+const schema = z
+ .object({
+ configurationType: z.string(),
+ issuer: z.string().optional(),
+ discoveryURL: z.string().optional(),
+ authorizationEndpoint: z.string().optional(),
+ jwksUri: z.string().optional(),
+ tokenEndpoint: z.string().optional(),
+ userinfoEndpoint: z.string().optional(),
+ clientId: z.string().min(1),
+ clientSecret: z.string().min(1),
+ allowedEmailDomains: z.string().optional()
+ })
+ .superRefine((data, ctx) => {
+ if (data.configurationType === ConfigurationType.CUSTOM) {
+ if (!data.issuer) {
+ ctx.addIssue({
+ path: ["issuer"],
+ message: "Issuer is required",
+ code: z.ZodIssueCode.custom
+ });
+ }
+ if (!data.authorizationEndpoint) {
+ ctx.addIssue({
+ path: ["authorizationEndpoint"],
+ message: "Authorization endpoint is required",
+ code: z.ZodIssueCode.custom
+ });
+ }
+ if (!data.jwksUri) {
+ ctx.addIssue({
+ path: ["jwksUri"],
+ message: "JWKS URI is required",
+ code: z.ZodIssueCode.custom
+ });
+ }
+ if (!data.tokenEndpoint) {
+ ctx.addIssue({
+ path: ["tokenEndpoint"],
+ message: "Token endpoint is required",
+ code: z.ZodIssueCode.custom
+ });
+ }
+ if (!data.userinfoEndpoint) {
+ ctx.addIssue({
+ path: ["userinfoEndpoint"],
+ message: "Userinfo endpoint is required",
+ code: z.ZodIssueCode.custom
+ });
+ }
+ } else {
+ // eslint-disable-next-line no-lonely-if
+ if (!data.discoveryURL) {
+ ctx.addIssue({
+ path: ["discoveryURL"],
+ message: "Discovery URL is required",
+ code: z.ZodIssueCode.custom
+ });
+ }
+ }
+ });
+
+export type OIDCFormData = z.infer<typeof schema>;
+
+export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelete }: Props) => {
+ const { currentOrg } = useOrganization();
+
+ const { mutateAsync: createMutateAsync, isLoading: createIsLoading } = useCreateOIDCConfig();
+ const { mutateAsync: updateMutateAsync, isLoading: updateIsLoading } = useUpdateOIDCConfig();
+ const [isDeletePopupOpen, setIsDeletePopupOpen] = useToggle(false);
+
+ const { data } = useGetOIDCConfig(currentOrg?.slug ?? "");
+
+ const { control, handleSubmit, reset, setValue, watch } = useForm<OIDCFormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ configurationType: ConfigurationType.DISCOVERY_URL
+ }
+ });
+
+ const [isClientIdFocused, setIsClientIdFocused] = useToggle();
+ const [isClientSecretFocused, setIsClientSecretFocused] = useToggle();
+
+ const configurationTypeValue = watch("configurationType");
+ const handleOidcSoftDelete = async () => {
+ if (!currentOrg) {
+ return;
+ }
+ try {
+ await updateMutateAsync({
+ issuer: "",
+ discoveryURL: "",
+ authorizationEndpoint: "",
+ allowedEmailDomains: "",
+ jwksUri: "",
+ tokenEndpoint: "",
+ userinfoEndpoint: "",
+ clientId: "",
+ clientSecret: "",
+ isActive: false,
+ orgSlug: currentOrg.slug
+ });
+
+ createNotification({
+ text: "Successfully deleted OIDC configuration.",
+ type: "success"
+ });
+ } catch {
+ createNotification({
+ text: "Failed deleting OIDC configuration.",
+ type: "error"
+ });
+ }
+ };
+
+ useEffect(() => {
+ if (data) {
+ setValue("issuer", data.issuer);
+ setValue("authorizationEndpoint", data.authorizationEndpoint);
+ setValue("jwksUri", data.jwksUri);
+ setValue("tokenEndpoint", data.tokenEndpoint);
+ setValue("userinfoEndpoint", data.userinfoEndpoint);
+ setValue("discoveryURL", data.discoveryURL);
+ setValue("clientId", data.clientId);
+ setValue("clientSecret", data.clientSecret);
+ setValue("allowedEmailDomains", data.allowedEmailDomains);
+ setValue("configurationType", data.configurationType);
+ }
+ }, [data]);
+
+ const onOIDCModalSubmit = async ({
+ issuer,
+ authorizationEndpoint,
+ allowedEmailDomains,
+ jwksUri,
+ tokenEndpoint,
+ userinfoEndpoint,
+ configurationType,
+ discoveryURL,
+ clientId,
+ clientSecret
+ }: OIDCFormData) => {
+ try {
+ if (!currentOrg) {
+ return;
+ }
+
+ if (!data) {
+ await createMutateAsync({
+ issuer,
+ configurationType,
+ discoveryURL,
+ authorizationEndpoint,
+ allowedEmailDomains,
+ jwksUri,
+ tokenEndpoint,
+ userinfoEndpoint,
+ clientId,
+ clientSecret,
+ isActive: true,
+ orgSlug: currentOrg.slug
+ });
+ } else {
+ await updateMutateAsync({
+ issuer,
+ configurationType,
+ discoveryURL,
+ authorizationEndpoint,
+ allowedEmailDomains,
+ jwksUri,
+ tokenEndpoint,
+ userinfoEndpoint,
+ clientId,
+ clientSecret,
+ isActive: true,
+ orgSlug: currentOrg.slug
+ });
+ }
+
+ handlePopUpClose("addOIDC");
+
+ createNotification({
+ text: `Successfully ${!data ? "added" : "updated"} OIDC SSO configuration`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: `Failed to ${!data ? "add" : "update"} OIDC SSO configuration`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <>
+ <Modal
+ isOpen={popUp?.addOIDC?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addOIDC", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent title="Manage OIDC configuration">
+ <form onSubmit={handleSubmit(onOIDCModalSubmit)}>
+ <Controller
+ control={control}
+ name="configurationType"
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl
+ label="Configuration Type"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Select
+ className="w-full"
+ defaultValue="discoveryURL"
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ >
+ <SelectItem value={ConfigurationType.DISCOVERY_URL}>Discovery URL</SelectItem>
+ <SelectItem value={ConfigurationType.CUSTOM}>Custom</SelectItem>
+ </Select>
+ </FormControl>
+ )}
+ />
+ {configurationTypeValue === ConfigurationType.DISCOVERY_URL && (
+ <Controller
+ control={control}
+ name="discoveryURL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Discovery Document URL"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input
+ {...field}
+ placeholder="https://accounts.google.com/.well-known/openid-configuration"
+ autoComplete="off"
+ />
+ </FormControl>
+ )}
+ />
+ )}
+ {configurationTypeValue === ConfigurationType.CUSTOM && (
+ <>
+ <Controller
+ control={control}
+ name="issuer"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Issuer" errorText={error?.message} isError={Boolean(error)}>
+ <Input
+ {...field}
+ placeholder="https://accounts.google.com"
+ autoComplete="off"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="authorizationEndpoint"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Authorization Endpoint"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input
+ {...field}
+ placeholder="https://accounts.google.com/o/oauth2/v2/auth"
+ autoComplete="off"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="tokenEndpoint"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Token Endpoint"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input
+ {...field}
+ placeholder="https://oauth2.googleapis.com/token"
+ autoComplete="off"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="userinfoEndpoint"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="User info endpoint"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input
+ {...field}
+ placeholder="https://openidconnect.googleapis.com/v1/userinfo"
+ autoComplete="off"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="jwksUri"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="JWKS URI"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input
+ {...field}
+ placeholder="https://www.googleapis.com/oauth2/v3/certs"
+ autoComplete="off"
+ />
+ </FormControl>
+ )}
+ />
+ </>
+ )}
+ <Controller
+ control={control}
+ name="allowedEmailDomains"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Allowed Email Domains (defaults to any)"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input {...field} placeholder="infisical.com, google.com" autoComplete="off" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="clientId"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Client ID" errorText={error?.message} isError={Boolean(error)}>
+ <Input
+ placeholder="Client ID"
+ type={isClientIdFocused ? "text" : "password"}
+ onFocus={() => setIsClientIdFocused.on()}
+ {...field}
+ onBlur={() => {
+ field.onBlur();
+ setIsClientIdFocused.off();
+ }}
+ autoComplete="off"
+ className="bg-mineshaft-800"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="clientSecret"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Client Secret"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input
+ {...field}
+ placeholder="Client Secret"
+ type={isClientSecretFocused ? "text" : "password"}
+ autoComplete="off"
+ onFocus={() => setIsClientSecretFocused.on()}
+ onBlur={() => {
+ field.onBlur();
+ setIsClientSecretFocused.off();
+ }}
+ className="bg-mineshaft-800"
+ />
+ </FormControl>
+ )}
+ />
+ <div className="mt-8 flex justify-between">
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={createIsLoading || updateIsLoading}
+ >
+ {!data ? "Add" : "Update"}
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpClose("addOIDC")}
+ >
+ Cancel
+ </Button>
+ </div>
+ {!hideDelete && (
+ <Button colorSchema="danger" onClick={() => setIsDeletePopupOpen.on()}>
+ Delete
+ </Button>
+ )}
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ <DeleteActionModal
+ isOpen={isDeletePopupOpen}
+ title="Are you sure want to delete OIDC?"
+ onChange={() => setIsDeletePopupOpen.toggle()}
+ deleteKey="confirm"
+ onDeleteApproved={handleOidcSoftDelete}
+ />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgAuthTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgAuthTab.tsx
new file mode 100644
index 0000000000..c0ff17ae6d
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgAuthTab.tsx
@@ -0,0 +1,194 @@
+import { twMerge } from "tailwind-merge";
+
+import { Button, ContentLoader, UpgradePlanModal } from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useServerConfig,
+ useSubscription
+} from "@app/context";
+import { withPermission } from "@app/hoc";
+import { usePopUp } from "@app/hooks";
+import { useGetLDAPConfig, useGetOIDCConfig, useGetSSOConfig } from "@app/hooks/api";
+import { LoginMethod } from "@app/hooks/api/admin/types";
+
+import { LDAPModal } from "./LDAPModal";
+import { OIDCModal } from "./OIDCModal";
+import { OrgGeneralAuthSection } from "./OrgGeneralAuthSection";
+import { OrgGenericAuthSection } from "./OrgGenericAuthSection";
+import { OrgLDAPSection } from "./OrgLDAPSection";
+import { OrgOIDCSection } from "./OrgOIDCSection";
+import { OrgScimSection } from "./OrgSCIMSection";
+import { OrgSSOSection } from "./OrgSSOSection";
+import { SSOModal } from "./SSOModal";
+
+export const OrgAuthTab = withPermission(
+ () => {
+ const {
+ config: { enabledLoginMethods }
+ } = useServerConfig();
+ const { currentOrg } = useOrganization();
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "addLDAP",
+ "addSSO",
+ "addOIDC",
+ "upgradePlan"
+ ] as const);
+
+ const { subscription } = useSubscription();
+
+ const { data: oidcConfig, isLoading: isLoadingOidcConfig } = useGetOIDCConfig(
+ currentOrg?.slug ?? ""
+ );
+ const { data: samlConfig, isLoading: isLoadingSamlConfig } = useGetSSOConfig(
+ currentOrg?.id ?? ""
+ );
+ const { data: ldapConfig, isLoading: isLoadingLdapConfig } = useGetLDAPConfig(
+ currentOrg?.id ?? ""
+ );
+ const areConfigsLoading = isLoadingOidcConfig || isLoadingSamlConfig || isLoadingLdapConfig;
+
+ const shouldDisplaySection = (method: LoginMethod) =>
+ !enabledLoginMethods || enabledLoginMethods.includes(method);
+
+ const isOidcConfigured = oidcConfig && (oidcConfig.discoveryURL || oidcConfig.issuer);
+ const isSamlConfigured = samlConfig && samlConfig.entryPoint;
+ const isLdapConfigured = ldapConfig && ldapConfig.url;
+
+ const shouldShowCreateIdentityProviderView =
+ !isOidcConfigured && !isSamlConfigured && !isLdapConfigured;
+
+ const createIdentityProviderView = (shouldDisplaySection(LoginMethod.SAML) ||
+ shouldDisplaySection(LoginMethod.OIDC) ||
+ shouldDisplaySection(LoginMethod.LDAP)) && (
+ <>
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
+ <p className="text-xl font-semibold text-gray-200">Connect an Identity Provider</p>
+ <p className="mb-2 mt-1 text-gray-400">
+ Connect your identity provider to simplify user management
+ </p>
+ {shouldDisplaySection(LoginMethod.SAML) && (
+ <div
+ className={twMerge(
+ "mt-4 flex items-center justify-between",
+ (shouldDisplaySection(LoginMethod.OIDC) ||
+ shouldDisplaySection(LoginMethod.LDAP)) &&
+ "border-b border-mineshaft-500 pb-4"
+ )}
+ >
+ <p className="text-lg text-gray-200">SAML</p>
+ <Button
+ colorSchema="secondary"
+ onClick={() => {
+ if (!subscription?.samlSSO) {
+ handlePopUpOpen("upgradePlan", { feature: "SAML SSO", plan: "Pro" });
+ return;
+ }
+
+ handlePopUpOpen("addSSO");
+ }}
+ >
+ Connect
+ </Button>
+ </div>
+ )}
+ {shouldDisplaySection(LoginMethod.OIDC) && (
+ <div
+ className={twMerge(
+ "mt-4 flex items-center justify-between",
+ shouldDisplaySection(LoginMethod.LDAP) && "border-b border-mineshaft-500 pb-4"
+ )}
+ >
+ <p className="text-lg text-gray-200">OIDC</p>
+ <Button
+ colorSchema="secondary"
+ onClick={() => {
+ if (!subscription?.oidcSSO) {
+ handlePopUpOpen("upgradePlan", { feature: "OIDC SSO", plan: "Pro" });
+ return;
+ }
+
+ handlePopUpOpen("addOIDC");
+ }}
+ >
+ Connect
+ </Button>
+ </div>
+ )}
+ {shouldDisplaySection(LoginMethod.LDAP) && (
+ <div className="mt-4 flex items-center justify-between">
+ <p className="text-lg text-gray-200">LDAP</p>
+ <Button
+ colorSchema="secondary"
+ onClick={() => {
+ if (!subscription?.ldap) {
+ handlePopUpOpen("upgradePlan", { feature: "LDAP", plan: "Enterprise" });
+ return;
+ }
+
+ handlePopUpOpen("addLDAP");
+ }}
+ >
+ Connect
+ </Button>
+ </div>
+ )}
+ </div>
+ <SSOModal
+ hideDelete
+ popUp={popUp}
+ handlePopUpClose={handlePopUpClose}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <OIDCModal
+ hideDelete
+ popUp={popUp}
+ handlePopUpClose={handlePopUpClose}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <LDAPModal
+ hideDelete
+ popUp={popUp}
+ handlePopUpClose={handlePopUpClose}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ </>
+ );
+
+ if (areConfigsLoading) {
+ return <ContentLoader />;
+ }
+
+ return (
+ <>
+ <OrgGenericAuthSection />
+ {shouldShowCreateIdentityProviderView ? (
+ createIdentityProviderView
+ ) : (
+ <>
+ {isSamlConfigured && shouldDisplaySection(LoginMethod.SAML) && (
+ <div className="mb-4 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
+ <OrgGeneralAuthSection />
+ <OrgSSOSection />
+ </div>
+ )}
+ {isOidcConfigured && shouldDisplaySection(LoginMethod.OIDC) && <OrgOIDCSection />}
+ {isLdapConfigured && shouldDisplaySection(LoginMethod.LDAP) && <OrgLDAPSection />}
+ </>
+ )}
+ <OrgScimSection />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text={`You can use ${
+ (popUp.upgradePlan.data as { feature: string })?.feature
+ } if you switch to Infisical's ${
+ (popUp.upgradePlan.data as { plan: string })?.plan
+ } plan.`}
+ />
+ </>
+ );
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Sso }
+);
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgGeneralAuthSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgGeneralAuthSection.tsx
new file mode 100644
index 0000000000..778215f07b
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgGeneralAuthSection.tsx
@@ -0,0 +1,97 @@
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Switch, UpgradePlanModal } from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { useLogoutUser, useUpdateOrg } from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+export const OrgGeneralAuthSection = () => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["upgradePlan"] as const);
+
+ const { mutateAsync } = useUpdateOrg();
+
+ const logout = useLogoutUser();
+
+ const handleEnforceOrgAuthToggle = async (value: boolean) => {
+ try {
+ if (!currentOrg?.id) return;
+ if (!subscription?.samlSSO) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ await mutateAsync({
+ orgId: currentOrg?.id,
+ authEnforced: value
+ });
+
+ createNotification({
+ text: `Successfully ${value ? "enforced" : "un-enforced"} org-level auth`,
+ type: "success"
+ });
+
+ if (value) {
+ await logout.mutateAsync();
+ window.open(`/api/v1/sso/redirect/saml2/organizations/${currentOrg.slug}`);
+ window.close();
+ }
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: (err as { response: { data: { message: string } } }).response.data.message,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <>
+ {/* <div className="py-4">
+ <div className="mb-2 flex justify-between">
+ <h3 className="text-md text-mineshaft-100">Allow users to send invites</h3>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Switch
+ id="allow-org-invites"
+ onCheckedChange={(value) => handleEnforceOrgAuthToggle(value)}
+ isChecked={currentOrg?.authEnforced ?? false}
+ isDisabled={!isAllowed}
+ />
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="text-sm text-mineshaft-300">Allow members to invite new users to this organization</p>
+ </div> */}
+ <div className="py-4">
+ <div className="mb-2 flex justify-between">
+ <h3 className="text-md text-mineshaft-100">Enforce SAML SSO</h3>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Switch
+ id="enforce-org-auth"
+ onCheckedChange={(value) => handleEnforceOrgAuthToggle(value)}
+ isChecked={currentOrg?.authEnforced ?? false}
+ isDisabled={!isAllowed}
+ />
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="text-sm text-mineshaft-300">
+ Enforce members to authenticate via SAML to access this organization
+ </p>
+ </div>
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text="You can enforce SAML SSO if you switch to Infisical's Pro plan."
+ />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgGenericAuthSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgGenericAuthSection.tsx
new file mode 100644
index 0000000000..9b9aa65532
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgGenericAuthSection.tsx
@@ -0,0 +1,116 @@
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { FormControl, Select, SelectItem, Switch, UpgradePlanModal } from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { useUpdateOrg } from "@app/hooks/api";
+import { MfaMethod } from "@app/hooks/api/auth/types";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+export const OrgGenericAuthSection = () => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["upgradePlan"] as const);
+
+ const { mutateAsync } = useUpdateOrg();
+
+ const handleEnforceMfaToggle = async (value: boolean) => {
+ try {
+ if (!currentOrg?.id) return;
+ if (!subscription?.enforceMfa) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ await mutateAsync({
+ orgId: currentOrg?.id,
+ enforceMfa: value
+ });
+
+ createNotification({
+ text: `Successfully ${value ? "enforced" : "un-enforced"} MFA`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: (err as { response: { data: { message: string } } }).response.data.message,
+ type: "error"
+ });
+ }
+ };
+
+ const handleUpdateSelectedMfa = async (selectedMfaMethod: MfaMethod) => {
+ try {
+ if (!currentOrg?.id) return;
+ if (!subscription?.enforceMfa) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ await mutateAsync({
+ orgId: currentOrg?.id,
+ selectedMfaMethod
+ });
+
+ createNotification({
+ text: "Successfully updated selected MFA method",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: (err as { response: { data: { message: string } } }).response.data.message,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <div className="mb-4 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
+ <div className="py-4">
+ <div className="mb-2 flex justify-between">
+ <h3 className="text-md text-mineshaft-100">Enforce Multi-factor Authentication</h3>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Switch
+ id="enforce-org-mfa"
+ onCheckedChange={(value) => handleEnforceMfaToggle(value)}
+ isChecked={currentOrg?.enforceMfa ?? false}
+ isDisabled={!isAllowed}
+ />
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="text-sm text-mineshaft-300">
+ Enforce members to authenticate with MFA in order to access the organization
+ </p>
+ {currentOrg?.enforceMfa && (
+ <FormControl label="Selected 2FA method" className="mt-3">
+ <Select
+ className="min-w-[20rem] border border-mineshaft-500"
+ onValueChange={handleUpdateSelectedMfa}
+ defaultValue={currentOrg.selectedMfaMethod ?? MfaMethod.EMAIL}
+ >
+ <SelectItem value={MfaMethod.EMAIL} key="mfa-method-email">
+ Email
+ </SelectItem>
+ <SelectItem value={MfaMethod.TOTP} key="mfa-method-totp">
+ Mobile Authenticator
+ </SelectItem>
+ </Select>
+ </FormControl>
+ )}
+ </div>
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text="You can enforce user MFA if you switch to Infisical's Pro plan."
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgLDAPSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgLDAPSection.tsx
new file mode 100644
index 0000000000..49e07f8617
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgLDAPSection.tsx
@@ -0,0 +1,171 @@
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, Switch, UpgradePlanModal } from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { useCreateLDAPConfig, useGetLDAPConfig, useUpdateLDAPConfig } from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { LDAPGroupMapModal } from "./LDAPGroupMapModal";
+import { LDAPModal } from "./LDAPModal";
+
+export const OrgLDAPSection = (): JSX.Element => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+
+ const { data } = useGetLDAPConfig(currentOrg?.id ?? "");
+
+ const { mutateAsync } = useUpdateLDAPConfig();
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "addLDAP",
+ "ldapGroupMap",
+ "deleteLdapGroupMap",
+ "upgradePlan"
+ ] as const);
+
+ const { mutateAsync: createMutateAsync } = useCreateLDAPConfig();
+
+ const handleLDAPToggle = async (value: boolean) => {
+ try {
+ if (!currentOrg?.id) return;
+ if (!subscription?.ldap) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ await mutateAsync({
+ organizationId: currentOrg?.id,
+ isActive: value
+ });
+
+ createNotification({
+ text: `Successfully ${value ? "enabled" : "disabled"} LDAP`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: `Failed to ${value ? "enable" : "disable"} LDAP`,
+ type: "error"
+ });
+ }
+ };
+
+ const addLDAPBtnClick = async () => {
+ try {
+ if (subscription?.ldap && currentOrg) {
+ if (!data) {
+ // case: LDAP is not configured
+ // -> initialize empty LDAP configuration
+ await createMutateAsync({
+ organizationId: currentOrg.id,
+ isActive: false,
+ url: "",
+ bindDN: "",
+ bindPass: "",
+ uniqueUserAttribute: "",
+ searchBase: "",
+ searchFilter: "",
+ groupSearchBase: "",
+ groupSearchFilter: ""
+ });
+ }
+
+ handlePopUpOpen("addLDAP");
+ } else {
+ handlePopUpOpen("upgradePlan");
+ }
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
+ const openLDAPGroupMapModal = () => {
+ if (!subscription?.ldap) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ handlePopUpOpen("ldapGroupMap");
+ };
+
+ return (
+ <div className="mb-4 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
+ <div className="py-4">
+ <div className="mb-2 flex items-center justify-between">
+ <h2 className="text-md text-mineshaft-100">LDAP</h2>
+ <div className="flex">
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Ldap}>
+ {(isAllowed) => (
+ <Button onClick={addLDAPBtnClick} colorSchema="secondary" isDisabled={!isAllowed}>
+ Manage
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ </div>
+ <p className="text-sm text-mineshaft-300">Manage LDAP authentication configuration</p>
+ </div>
+ <div className="py-4">
+ <div className="mb-2 flex items-center justify-between">
+ <h2 className="text-md text-mineshaft-100">LDAP Group Mappings</h2>
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Ldap}>
+ {(isAllowed) => (
+ <Button
+ onClick={openLDAPGroupMapModal}
+ colorSchema="secondary"
+ isDisabled={!isAllowed}
+ >
+ Manage
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="text-sm text-mineshaft-300">
+ Manage how LDAP groups are mapped to internal groups in Infisical
+ </p>
+ </div>
+ {data && (
+ <div className="py-4">
+ <div className="mb-2 flex items-center justify-between">
+ <h2 className="text-md text-mineshaft-100">Enable LDAP</h2>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Ldap}>
+ {(isAllowed) => (
+ <Switch
+ id="enable-saml-sso"
+ onCheckedChange={(value) => handleLDAPToggle(value)}
+ isChecked={data ? data.isActive : false}
+ isDisabled={!isAllowed}
+ >
+ Enable
+ </Switch>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="text-sm text-mineshaft-300">
+ Allow members to authenticate into Infisical with LDAP
+ </p>
+ </div>
+ )}
+ <LDAPModal
+ popUp={popUp}
+ handlePopUpClose={handlePopUpClose}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <LDAPGroupMapModal
+ popUp={popUp}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text="You can use LDAP authentication if you switch to Infisical's Enterprise plan."
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgOIDCSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgOIDCSection.tsx
new file mode 100644
index 0000000000..c277e90f1b
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgOIDCSection.tsx
@@ -0,0 +1,162 @@
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, Switch, UpgradePlanModal } from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { useGetOIDCConfig, useLogoutUser, useUpdateOrg } from "@app/hooks/api";
+import { useUpdateOIDCConfig } from "@app/hooks/api/oidcConfig/mutations";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { OIDCModal } from "./OIDCModal";
+
+export const OrgOIDCSection = (): JSX.Element => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+
+ const { data, isLoading } = useGetOIDCConfig(currentOrg?.slug ?? "");
+ const { mutateAsync } = useUpdateOIDCConfig();
+ const { mutateAsync: updateOrg } = useUpdateOrg();
+
+ const logout = useLogoutUser();
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "addOIDC",
+ "upgradePlan"
+ ] as const);
+
+ const handleOIDCToggle = async (value: boolean) => {
+ try {
+ if (!currentOrg?.id) return;
+
+ if (!subscription?.oidcSSO) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ await mutateAsync({
+ orgSlug: currentOrg?.slug,
+ isActive: value
+ });
+
+ createNotification({
+ text: `Successfully ${value ? "enabled" : "disabled"} OIDC SSO`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
+ const handleEnforceOrgAuthToggle = async (value: boolean) => {
+ try {
+ if (!currentOrg?.id) return;
+ if (!subscription?.oidcSSO) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ await updateOrg({
+ orgId: currentOrg?.id,
+ authEnforced: value
+ });
+
+ createNotification({
+ text: `Successfully ${value ? "enforced" : "un-enforced"} org-level auth`,
+ type: "success"
+ });
+
+ if (value) {
+ await logout.mutateAsync();
+ window.open(`/api/v1/sso/oidc/login?orgSlug=${currentOrg.slug}`);
+ window.close();
+ }
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
+ const addOidcButtonClick = async () => {
+ if (subscription?.oidcSSO && currentOrg) {
+ handlePopUpOpen("addOIDC");
+ } else {
+ handlePopUpOpen("upgradePlan");
+ }
+ };
+
+ return (
+ <div className="mb-4 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
+ <div className="py-4">
+ <div className="mb-2 flex items-center justify-between">
+ <h2 className="text-md text-mineshaft-100">OIDC</h2>
+ {!isLoading && (
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Button
+ onClick={addOidcButtonClick}
+ colorSchema="secondary"
+ isDisabled={!isAllowed}
+ >
+ Manage
+ </Button>
+ )}
+ </OrgPermissionCan>
+ )}
+ </div>
+ <p className="text-sm text-mineshaft-300">Manage OIDC authentication configuration</p>
+ </div>
+ {data && (
+ <div className="py-4">
+ <div className="mb-2 flex items-center justify-between">
+ <h2 className="text-md text-mineshaft-100">Enable OIDC</h2>
+ {!isLoading && (
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Switch
+ id="enable-oidc-sso"
+ onCheckedChange={(value) => handleOIDCToggle(value)}
+ isChecked={data ? data.isActive : false}
+ isDisabled={!isAllowed}
+ />
+ )}
+ </OrgPermissionCan>
+ )}
+ </div>
+ <p className="text-sm text-mineshaft-300">
+ Allow members to authenticate into Infisical with OIDC
+ </p>
+ </div>
+ )}
+ <div className="py-4">
+ <div className="mb-2 flex justify-between">
+ <h3 className="text-md text-mineshaft-100">Enforce OIDC SSO</h3>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Switch
+ id="enforce-org-auth"
+ isChecked={currentOrg?.authEnforced ?? false}
+ onCheckedChange={(value) => handleEnforceOrgAuthToggle(value)}
+ isDisabled={!isAllowed}
+ />
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="text-sm text-mineshaft-300">
+ Enforce members to authenticate via OIDC to access this organization
+ </p>
+ </div>
+ <OIDCModal
+ popUp={popUp}
+ handlePopUpClose={handlePopUpClose}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text="You can use OIDC SSO if you switch to Infisical's Pro plan."
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgSCIMSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgSCIMSection.tsx
new file mode 100644
index 0000000000..e20a5fe22e
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgSCIMSection.tsx
@@ -0,0 +1,117 @@
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, Switch, UpgradePlanModal } from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { useUpdateOrg } from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { ExternalGroupOrgRoleMappings } from "./ExternalGroupOrgRoleMappings";
+import { ScimTokenModal } from "./ScimTokenModal";
+
+export const OrgScimSection = () => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([
+ "scimToken",
+ "deleteScimToken",
+ "upgradePlan"
+ ] as const);
+
+ const { mutateAsync } = useUpdateOrg();
+
+ const addScimTokenBtnClick = () => {
+ if (subscription?.scim) {
+ handlePopUpOpen("scimToken");
+ } else {
+ handlePopUpOpen("upgradePlan");
+ }
+ };
+
+ const handleEnableSCIMToggle = async (value: boolean) => {
+ try {
+ if (!currentOrg?.id) return;
+ if (!subscription?.scim) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ await mutateAsync({
+ orgId: currentOrg?.id,
+ scimEnabled: value
+ });
+
+ createNotification({
+ text: `Successfully ${value ? "enabled" : "disabled"} SCIM provisioning`,
+ type: "success"
+ });
+ } catch (err) {
+ createNotification({
+ text: (err as { response: { data: { message: string } } }).response.data.message,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
+ <p className="text-xl font-semibold text-gray-200">Provision users via SCIM</p>
+ <div className="py-4">
+ <div className="mb-2 flex items-center justify-between">
+ <h2 className="text-md text-mineshaft-100">SCIM</h2>
+ <OrgPermissionCan I={OrgPermissionActions.Read} a={OrgPermissionSubjects.Scim}>
+ {(isAllowed) => (
+ <Button
+ onClick={addScimTokenBtnClick}
+ colorSchema="secondary"
+ isDisabled={!isAllowed}
+ >
+ Configure
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="text-sm text-mineshaft-300">Manage SCIM configuration</p>
+ </div>
+ <ExternalGroupOrgRoleMappings />
+ <div className="py-4">
+ <div className="mb-2 flex items-center justify-between">
+ <h2 className="text-md text-mineshaft-100">Enable SCIM</h2>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Scim}>
+ {(isAllowed) => (
+ <Switch
+ id="enable-scim"
+ onCheckedChange={(value) => {
+ if (subscription?.scim) {
+ handleEnableSCIMToggle(value);
+ } else {
+ handlePopUpOpen("upgradePlan");
+ }
+ }}
+ isChecked={currentOrg?.scimEnabled ?? false}
+ isDisabled={!isAllowed}
+ />
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="text-sm text-mineshaft-300">
+ Allow member provisioning/deprovisioning with SCIM
+ </p>
+ </div>
+ <ScimTokenModal
+ popUp={popUp}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text="You can use SCIM Provisioning if you switch to Infisical's Enterprise plan."
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgSSOSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgSSOSection.tsx
new file mode 100644
index 0000000000..3e5d778422
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/OrgSSOSection.tsx
@@ -0,0 +1,130 @@
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, Switch, UpgradePlanModal } from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { useCreateSSOConfig, useGetSSOConfig, useUpdateSSOConfig } from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { SSOModal } from "./SSOModal";
+
+export const OrgSSOSection = (): JSX.Element => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+
+ const { data, isLoading } = useGetSSOConfig(currentOrg?.id ?? "");
+ const { mutateAsync } = useUpdateSSOConfig();
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "upgradePlan",
+ "addSSO"
+ ] as const);
+
+ const { mutateAsync: createMutateAsync } = useCreateSSOConfig();
+
+ const handleSamlSSOToggle = async (value: boolean) => {
+ try {
+ if (!currentOrg?.id) return;
+
+ if (!subscription?.samlSSO) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ await mutateAsync({
+ organizationId: currentOrg?.id,
+ isActive: value
+ });
+
+ createNotification({
+ text: `Successfully ${value ? "enabled" : "disabled"} SAML SSO`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: `Failed to ${value ? "enable" : "disable"} SAML SSO`,
+ type: "error"
+ });
+ }
+ };
+
+ const addSSOBtnClick = async () => {
+ try {
+ if (subscription?.samlSSO && currentOrg) {
+ if (!data) {
+ // case: SAML SSO is not configured
+ // -> initialize empty SAML SSO configuration
+ await createMutateAsync({
+ organizationId: currentOrg.id,
+ authProvider: "okta-saml",
+ isActive: false,
+ entryPoint: "",
+ issuer: "",
+ cert: ""
+ });
+ }
+
+ handlePopUpOpen("addSSO");
+ } else {
+ handlePopUpOpen("upgradePlan");
+ }
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
+ return (
+ <>
+ <hr className="border-mineshaft-600" />
+ <div className="py-4">
+ <div className="mb-2 flex items-center justify-between">
+ <h2 className="text-md text-mineshaft-100">SAML</h2>
+ {!isLoading && (
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Button onClick={addSSOBtnClick} colorSchema="secondary" isDisabled={!isAllowed}>
+ Manage
+ </Button>
+ )}
+ </OrgPermissionCan>
+ )}
+ </div>
+ <p className="text-sm text-mineshaft-300">Manage SAML authentication configuration</p>
+ </div>
+ <div className="py-4">
+ <div className="mb-2 flex items-center justify-between">
+ <h2 className="text-md text-mineshaft-100">Enable SAML</h2>
+ {!isLoading && (
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Switch
+ id="enable-saml-sso"
+ onCheckedChange={(value) => handleSamlSSOToggle(value)}
+ isChecked={data ? data.isActive : false}
+ isDisabled={!isAllowed}
+ />
+ )}
+ </OrgPermissionCan>
+ )}
+ </div>
+ <p className="text-sm text-mineshaft-300">
+ Allow members to authenticate into Infisical with SAML
+ </p>
+ </div>
+ <SSOModal
+ popUp={popUp}
+ handlePopUpClose={handlePopUpClose}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text="You can use SAML SSO if you switch to Infisical's Pro plan."
+ />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/SSOModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/SSOModal.tsx
new file mode 100644
index 0000000000..a39f1241f1
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/SSOModal.tsx
@@ -0,0 +1,343 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ DeleteActionModal,
+ FormControl,
+ Input,
+ Modal,
+ ModalContent,
+ Select,
+ SelectItem,
+ TextArea
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useToggle } from "@app/hooks";
+import { useCreateSSOConfig, useGetSSOConfig, useUpdateSSOConfig } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+enum AuthProvider {
+ OKTA_SAML = "okta-saml",
+ AZURE_SAML = "azure-saml",
+ JUMPCLOUD_SAML = "jumpcloud-saml",
+ KEYCLOAK_SAML = "keycloak-saml",
+ GOOGLE_SAML = "google-saml"
+}
+
+const ssoAuthProviders = [
+ { label: "Okta SAML", value: AuthProvider.OKTA_SAML },
+ { label: "Azure / Entra SAML", value: AuthProvider.AZURE_SAML },
+ { label: "JumpCloud SAML", value: AuthProvider.JUMPCLOUD_SAML },
+ { label: "Keycloak SAML", value: AuthProvider.KEYCLOAK_SAML },
+ { label: "Google SAML", value: AuthProvider.GOOGLE_SAML }
+];
+
+const schema = z
+ .object({
+ authProvider: z.string().min(1, "SSO Type is required"),
+ entryPoint: z.string().default(""),
+ issuer: z.string().default(""),
+ cert: z.string().default("")
+ })
+ .required();
+
+export type AddSSOFormData = z.infer<typeof schema>;
+
+type Props = {
+ popUp: UsePopUpState<["addSSO"]>;
+ handlePopUpClose: (popUpName: keyof UsePopUpState<["addSSO"]>) => void;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["addSSO"]>, state?: boolean) => void;
+ hideDelete?: boolean;
+};
+
+export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelete }: Props) => {
+ const { currentOrg } = useOrganization();
+
+ const { mutateAsync: createMutateAsync, isLoading: createIsLoading } = useCreateSSOConfig();
+ const { mutateAsync: updateMutateAsync, isLoading: updateIsLoading } = useUpdateSSOConfig();
+ const [isDeletePopupOpen, setIsDeletePopupOpen] = useToggle();
+ const { data } = useGetSSOConfig(currentOrg?.id ?? "");
+
+ const { control, handleSubmit, reset, watch, setValue, getValues } = useForm<AddSSOFormData>({
+ defaultValues: {
+ authProvider: AuthProvider.OKTA_SAML
+ },
+ resolver: zodResolver(schema)
+ });
+
+ useEffect(() => {
+ if (data) {
+ reset({
+ authProvider: data?.authProvider ?? "",
+ entryPoint: data?.entryPoint ?? "",
+ issuer: data?.issuer ?? "",
+ cert: data?.cert ?? ""
+ });
+ }
+ }, [data]);
+
+ const handleSamlSoftDelete = async () => {
+ if (!currentOrg) {
+ return;
+ }
+ try {
+ await updateMutateAsync({
+ organizationId: currentOrg.id,
+ isActive: false,
+ entryPoint: "",
+ issuer: "",
+ cert: ""
+ });
+
+ createNotification({
+ text: "Successfully deleted SAML SSO configuration.",
+ type: "success"
+ });
+ } catch {
+ createNotification({
+ text: "Failed deleting SAML SSO configuration.",
+ type: "error"
+ });
+ }
+ };
+
+ const onSSOModalSubmit = async ({ authProvider, entryPoint, issuer, cert }: AddSSOFormData) => {
+ try {
+ if (!currentOrg) return;
+
+ if (!data) {
+ await createMutateAsync({
+ organizationId: currentOrg.id,
+ authProvider,
+ isActive: false,
+ entryPoint,
+ issuer,
+ cert
+ });
+ } else {
+ await updateMutateAsync({
+ organizationId: currentOrg.id,
+ authProvider,
+ isActive: false,
+ entryPoint,
+ issuer,
+ cert
+ });
+ }
+
+ handlePopUpClose("addSSO");
+
+ createNotification({
+ text: `Successfully ${!data ? "added" : "updated"} SAML SSO configuration`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: `Failed to ${!data ? "add" : "update"} SAML SSO configuration`,
+ type: "error"
+ });
+ }
+ };
+
+ const renderLabels = (authProvider: string) => {
+ switch (authProvider) {
+ case AuthProvider.OKTA_SAML:
+ return {
+ acsUrl: "Single sign-on URL",
+ entityId: "Audience URI (SP Entity ID)",
+ entryPoint: "Identity Provider Single Sign-On URL",
+ entryPointPlaceholder: "https://your-domain.okta.com/app/app-name/xxx/sso/saml",
+ issuer: "Identity Provider Issuer",
+ issuerPlaceholder: "http://www.okta.com/xxx"
+ };
+ case AuthProvider.AZURE_SAML:
+ return {
+ acsUrl: "Reply URL (Assertion Consumer Service URL)",
+ entityId: "Identifier (Entity ID)",
+ entryPoint: "Login URL",
+ entryPointPlaceholder: "https://login.microsoftonline.com/xxx/saml2",
+ issuer: "Azure / Entra Application ID",
+ issuerPlaceholder: "abc-def-ghi-jkl-mno"
+ };
+ case AuthProvider.JUMPCLOUD_SAML:
+ return {
+ acsUrl: "ACS URL",
+ entityId: "SP Entity ID",
+ entryPoint: "IDP URL",
+ entryPointPlaceholder: "https://sso.jumpcloud.com/saml2/xxx",
+ issuer: "IdP Entity ID",
+ issuerPlaceholder: "xxx"
+ };
+ case AuthProvider.KEYCLOAK_SAML:
+ return {
+ acsUrl: "Valid redirect URI",
+ entityId: "SP Entity ID",
+ entryPoint: "IDP URL",
+ entryPointPlaceholder: "https://keycloak.mysite.com/realms/myrealm/protocol/saml",
+ issuer: "Client ID",
+ issuerPlaceholder: window.origin
+ };
+ case AuthProvider.GOOGLE_SAML:
+ return {
+ acsUrl: "ACS URL",
+ entityId: "SP Entity ID",
+ entryPoint: "SSO URL",
+ entryPointPlaceholder: "https://accounts.google.com/o/saml2/idp?idpid=xxx",
+ issuer: "Issuer",
+ issuerPlaceholder: window.origin
+ };
+ default:
+ return {
+ acsUrl: "ACS URL",
+ entityId: "Entity ID",
+ entryPoint: "Entrypoint",
+ entryPointPlaceholder: "Enter entrypoint...",
+ issuer: "Issuer",
+ issuerPlaceholder: "Enter placeholder..."
+ };
+ }
+ };
+
+ const authProvider = watch("authProvider");
+ useEffect(() => {
+ if (authProvider === AuthProvider.GOOGLE_SAML && getValues("issuer") === "") {
+ setValue("issuer", window.origin);
+ }
+ }, [authProvider]);
+
+ return (
+ <>
+ <Modal
+ isOpen={popUp?.addSSO?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addSSO", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent title="Manage SAML configuration">
+ <form onSubmit={handleSubmit(onSSOModalSubmit)}>
+ <Controller
+ control={control}
+ name="authProvider"
+ defaultValue="okta-saml"
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl label="Type" errorText={error?.message} isError={Boolean(error)}>
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ className="w-full"
+ >
+ {ssoAuthProviders.map(({ label, value }) => (
+ <SelectItem value={String(value || "")} key={label}>
+ {label}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ {authProvider && data && (
+ <>
+ <div className="mb-4">
+ <h3 className="text-sm text-mineshaft-400">
+ {renderLabels(authProvider).acsUrl}
+ </h3>
+ <p className="text-md break-all text-gray-400">{`${window.origin}/api/v1/sso/saml2/${data.id}`}</p>
+ </div>
+ <div className="mb-4">
+ <h3 className="text-sm text-mineshaft-400">
+ {renderLabels(authProvider).entityId}
+ </h3>
+ <p className="text-md text-gray-400">{window.origin}</p>
+ </div>
+ <Controller
+ control={control}
+ name="entryPoint"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label={renderLabels(authProvider).entryPoint}
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input
+ {...field}
+ placeholder={renderLabels(authProvider).entryPointPlaceholder}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="issuer"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label={renderLabels(authProvider).issuer}
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input
+ {...field}
+ placeholder={renderLabels(authProvider).issuerPlaceholder}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="cert"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Certificate"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <TextArea {...field} placeholder="-----BEGIN CERTIFICATE----- ..." />
+ </FormControl>
+ )}
+ />
+ </>
+ )}
+
+ <div className="mt-8 flex justify-between">
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={createIsLoading || updateIsLoading}
+ >
+ {!data ? "Add" : "Update"}
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpClose("addSSO")}
+ >
+ Cancel
+ </Button>
+ </div>
+ {!hideDelete && (
+ <Button colorSchema="danger" onClick={() => setIsDeletePopupOpen.on()}>
+ Delete
+ </Button>
+ )}
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ <DeleteActionModal
+ isOpen={isDeletePopupOpen}
+ title="Are you sure want to delete SAML SSO?"
+ onChange={() => setIsDeletePopupOpen.toggle()}
+ deleteKey="confirm"
+ onDeleteApproved={handleSamlSoftDelete}
+ />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/ScimTokenModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/ScimTokenModal.tsx
new file mode 100644
index 0000000000..82a038e58b
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/ScimTokenModal.tsx
@@ -0,0 +1,318 @@
+import { useEffect, useState } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { useTranslation } from "react-i18next";
+import { faCheck, faCopy, faKey, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { format } from "date-fns";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ DeleteActionModal,
+ EmptyState,
+ FormControl,
+ IconButton,
+ Input,
+ Modal,
+ ModalContent,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useToggle } from "@app/hooks";
+import { useCreateScimToken, useDeleteScimToken, useGetScimTokens } from "@app/hooks/api";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const schema = z.object({
+ description: z.string().optional(),
+ ttlDays: z.string()
+});
+
+export type FormData = z.infer<typeof schema>;
+
+type Props = {
+ popUp: UsePopUpState<["scimToken", "deleteScimToken"]>;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["deleteScimToken"]>,
+ data?: {
+ scimTokenId: string;
+ }
+ ) => void;
+ handlePopUpToggle: (
+ popUpName: keyof UsePopUpState<["scimToken", "deleteScimToken"]>,
+ state?: boolean
+ ) => void;
+};
+
+export const ScimTokenModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Props) => {
+ const { currentOrg } = useOrganization();
+ const { t } = useTranslation();
+
+ const [token, setToken] = useState("");
+
+ const [isScimUrlCopied, setIsScimUrlCopied] = useToggle(false);
+ const [isScimTokenCopied, setIsScimTokenCopied] = useToggle(false);
+
+ const { data, isLoading } = useGetScimTokens(currentOrg?.id ?? "");
+ const { mutateAsync: createScimTokenMutateAsync } = useCreateScimToken();
+ const { mutateAsync: deleteScimTokenMutateAsync } = useDeleteScimToken();
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ description: "",
+ ttlDays: "365"
+ }
+ });
+
+ useEffect(() => {
+ let timer: NodeJS.Timeout;
+ if (isScimUrlCopied) {
+ timer = setTimeout(() => setIsScimUrlCopied.off(), 2000);
+ }
+
+ if (isScimTokenCopied) {
+ timer = setTimeout(() => setIsScimTokenCopied.off(), 2000);
+ }
+
+ return () => clearTimeout(timer);
+ }, [isScimTokenCopied, isScimUrlCopied]);
+
+ const onFormSubmit = async ({ description, ttlDays }: FormData) => {
+ try {
+ if (!currentOrg?.id) return;
+
+ const { scimToken } = await createScimTokenMutateAsync({
+ organizationId: currentOrg.id,
+ description,
+ ttlDays: Number(ttlDays)
+ });
+
+ setToken(scimToken);
+
+ createNotification({
+ text: "Successfully created SCIM token",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to create SCIM token",
+ type: "error"
+ });
+ }
+ };
+
+ const onDeleteScimTokenSubmit = async (scimTokenId: string) => {
+ try {
+ if (!currentOrg?.id) return;
+
+ await deleteScimTokenMutateAsync({
+ organizationId: currentOrg.id,
+ scimTokenId
+ });
+
+ handlePopUpToggle("deleteScimToken", false);
+
+ createNotification({
+ text: "Successfully deleted SCIM token",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to delete SCIM token",
+ type: "error"
+ });
+ }
+ };
+
+ const hasToken = Boolean(token);
+ const scimUrl = `${window.origin}/api/v1/scim`;
+
+ return (
+ <Modal
+ isOpen={popUp?.scimToken?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("scimToken", isOpen);
+ reset();
+ setToken("");
+ }}
+ >
+ <ModalContent title="Manage SCIM credentials">
+ <h2 className="mb-4">SCIM URL</h2>
+ <div className="mb-8 flex items-center justify-between rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{scimUrl}</p>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(scimUrl);
+ setIsScimUrlCopied.on();
+ }}
+ >
+ <FontAwesomeIcon icon={isScimUrlCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ {t("common.click-to-copy")}
+ </span>
+ </IconButton>
+ </div>
+ <h2 className="mb-4">New SCIM Token</h2>
+ {hasToken ? (
+ <div>
+ <div className="mb-4 flex items-center justify-between">
+ <p>We will only show this token once</p>
+ <Button
+ colorSchema="secondary"
+ type="submit"
+ onClick={() => {
+ reset();
+ setToken("");
+ }}
+ >
+ Got it
+ </Button>
+ </div>
+ <div className="mb-8 flex items-center justify-between rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{token}</p>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(token);
+ setIsScimTokenCopied.on();
+ }}
+ >
+ <FontAwesomeIcon icon={isScimTokenCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ {t("common.click-to-copy")}
+ </span>
+ </IconButton>
+ </div>
+ </div>
+ ) : (
+ <form onSubmit={handleSubmit(onFormSubmit)} className="mb-8">
+ <Controller
+ control={control}
+ defaultValue=""
+ name="description"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Description (optional)"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="Description" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue="365"
+ name="ttlDays"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="TTL (days)" isError={Boolean(error)} errorText={error?.message}>
+ <div className="flex">
+ <Input {...field} placeholder="0" type="number" min="0" step="1" />
+ <Button
+ className="ml-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Create
+ </Button>
+ </div>
+ </FormControl>
+ )}
+ />
+ </form>
+ )}
+ <h2 className="mb-4">SCIM Tokens</h2>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Description</Th>
+ <Th>Expires At</Th>
+ <Th>Created At</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={4} innerKey="org-scim-tokens" />}
+ {!isLoading &&
+ data &&
+ data.length > 0 &&
+ data.map(({ id, description, ttlDays, createdAt }) => {
+ let expiresAt;
+ if (ttlDays > 0) {
+ expiresAt = new Date(new Date(createdAt).getTime() + ttlDays * 86400 * 1000);
+ }
+
+ return (
+ <Tr className="h-10 items-center" key={`mi-client-secret-${id}`}>
+ <Td>{description === "" ? "-" : description}</Td>
+ <Td>{expiresAt ? format(expiresAt, "yyyy-MM-dd HH:mm:ss") : "-"}</Td>
+ <Td>{format(new Date(createdAt), "yyyy-MM-dd HH:mm:ss")}</Td>
+ <Td>
+ <IconButton
+ onClick={() => {
+ handlePopUpOpen("deleteScimToken", {
+ scimTokenId: id
+ });
+ }}
+ size="lg"
+ colorSchema="primary"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </Td>
+ </Tr>
+ );
+ })}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={4}>
+ <EmptyState title="No SCIM tokens have been created yet" icon={faKey} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ <DeleteActionModal
+ isOpen={popUp.deleteScimToken.isOpen}
+ title="Are you sure want to delete the SCIM token?"
+ onChange={(isOpen) => handlePopUpToggle("scimToken", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() => {
+ const deleteScimTokenData = popUp?.deleteScimToken?.data as {
+ scimTokenId: string;
+ };
+
+ return onDeleteScimTokenSubmit(deleteScimTokenData.scimTokenId);
+ }}
+ />
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/index.tsx
new file mode 100644
index 0000000000..537be98310
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgAuthTab/index.tsx
@@ -0,0 +1 @@
+export { OrgAuthTab } from "./OrgAuthTab";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgDeleteSection/OrgDeleteSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgDeleteSection/OrgDeleteSection.tsx
new file mode 100644
index 0000000000..e28d0dcfba
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgDeleteSection/OrgDeleteSection.tsx
@@ -0,0 +1,73 @@
+import { useNavigate } from "@tanstack/react-router";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, DeleteActionModal } from "@app/components/v2";
+import { useOrganization, useOrgPermission } from "@app/context";
+import { useDeleteOrgById } from "@app/hooks/api";
+import { usePopUp } from "@app/hooks/usePopUp";
+import { navigateUserToOrg } from "@app/routes/_restrict_login_signup/login/-components/Login.utils";
+
+export const OrgDeleteSection = () => {
+ const navigate = useNavigate();
+ const { currentOrg } = useOrganization();
+
+ const { membership } = useOrgPermission();
+
+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
+ "deleteOrg"
+ ] as const);
+
+ const { mutateAsync, isLoading } = useDeleteOrgById();
+
+ const handleDeleteOrgSubmit = async () => {
+ try {
+ if (!currentOrg?.id) return;
+
+ await mutateAsync({
+ organizationId: currentOrg?.id
+ });
+
+ createNotification({
+ text: "Successfully deleted organization",
+ type: "success"
+ });
+
+ await navigateUserToOrg(navigate);
+
+ handlePopUpClose("deleteOrg");
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to delete organization",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <>
+ <hr className="border-mineshaft-600" />
+ <div className="py-4">
+ <p className="text-md mb-4 text-mineshaft-100">Danger Zone</p>
+ <Button
+ isLoading={isLoading}
+ colorSchema="danger"
+ variant="outline_bg"
+ type="submit"
+ onClick={() => handlePopUpOpen("deleteOrg")}
+ isDisabled={Boolean(membership && membership.role !== "admin")}
+ >
+ {`Delete ${currentOrg?.name}`}
+ </Button>
+ </div>
+ <DeleteActionModal
+ isOpen={popUp.deleteOrg.isOpen}
+ title="Are you sure want to delete this organization?"
+ subTitle={`Permanently remove ${currentOrg?.name} and all of its data. This action is not reversible, so please be careful.`}
+ onChange={(isOpen) => handlePopUpToggle("deleteOrg", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={handleDeleteOrgSubmit}
+ />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgDeleteSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgDeleteSection/index.tsx
new file mode 100644
index 0000000000..3ab22f2860
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgDeleteSection/index.tsx
@@ -0,0 +1 @@
+export { OrgDeleteSection } from "./OrgDeleteSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/AddExternalKmsForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/AddExternalKmsForm.tsx
new file mode 100644
index 0000000000..ceaa5c5b56
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/AddExternalKmsForm.tsx
@@ -0,0 +1,116 @@
+import { useState } from "react";
+import { faAws, faGoogle } from "@fortawesome/free-brands-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { AnimatePresence, motion } from "framer-motion";
+
+import { Modal, ModalContent } from "@app/components/v2";
+import { ExternalKmsProvider } from "@app/hooks/api/kms/types";
+
+import { AwsKmsForm } from "./AwsKmsForm";
+import { GcpKmsForm } from "./GcpKmsForm";
+
+type Props = {
+ isOpen?: boolean;
+ onToggle: (isOpen: boolean) => void;
+};
+
+enum WizardSteps {
+ SelectProvider = "select-provider",
+ ProviderInputs = "provider-inputs"
+}
+
+const EXTERNAL_KMS_LIST = [
+ {
+ icon: faAws,
+ provider: ExternalKmsProvider.Aws,
+ title: "AWS KMS"
+ },
+ {
+ icon: faGoogle,
+ provider: ExternalKmsProvider.Gcp,
+ title: "GCP KMS"
+ }
+];
+
+export const AddExternalKmsForm = ({ isOpen, onToggle }: Props) => {
+ const [wizardStep, setWizardStep] = useState(WizardSteps.SelectProvider);
+ const [selectedProvider, setSelectedProvider] = useState<string | null>(null);
+
+ const handleFormReset = (state: boolean = false) => {
+ onToggle(state);
+ setWizardStep(WizardSteps.SelectProvider);
+ setSelectedProvider(null);
+ };
+
+ return (
+ <Modal isOpen={isOpen} onOpenChange={(state) => handleFormReset(state)}>
+ <ModalContent
+ title="Add a Key Management System"
+ subTitle="Configure an external key management system (KMS)"
+ className="my-4"
+ bodyClassName="overflow-visible"
+ >
+ <AnimatePresence mode="wait">
+ {wizardStep === WizardSteps.SelectProvider && (
+ <motion.div
+ key="select-type-step"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <div className="mb-4 text-mineshaft-300">Select a KMS Provider</div>
+ <div className="flex items-center space-x-4">
+ {EXTERNAL_KMS_LIST.map(({ icon, provider, title }) => (
+ <div
+ key={`kms-${provider}`}
+ className="flex h-28 w-32 cursor-pointer flex-col items-center space-y-4 rounded border border-mineshaft-500 bg-bunker-600 p-6 transition-all hover:border-primary/70 hover:bg-primary/10 hover:text-white"
+ role="button"
+ tabIndex={0}
+ onClick={() => {
+ setSelectedProvider(provider);
+ setWizardStep(WizardSteps.ProviderInputs);
+ }}
+ onKeyDown={(evt) => {
+ if (evt.key === "Enter") {
+ setSelectedProvider(provider);
+ setWizardStep(WizardSteps.ProviderInputs);
+ }
+ }}
+ >
+ <FontAwesomeIcon icon={icon} size="lg" />
+ <div className="whitespace-pre-wrap text-center text-sm">{title}</div>
+ </div>
+ ))}
+ </div>
+ </motion.div>
+ )}
+ {wizardStep === WizardSteps.ProviderInputs &&
+ selectedProvider === ExternalKmsProvider.Aws && (
+ <motion.div
+ key="kms-aws"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <AwsKmsForm onCancel={() => onToggle(false)} onCompleted={() => onToggle(false)} />
+ </motion.div>
+ )}
+ {wizardStep === WizardSteps.ProviderInputs &&
+ selectedProvider === ExternalKmsProvider.Gcp && (
+ <motion.div
+ key="kms-gcp"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <GcpKmsForm onCancel={() => onToggle(false)} onCompleted={() => onToggle(false)} />
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/AwsKmsForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/AwsKmsForm.tsx
new file mode 100644
index 0000000000..ef47f3195b
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/AwsKmsForm.tsx
@@ -0,0 +1,273 @@
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Badge, Button, FormControl, Input, Select, SelectItem } from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useAddExternalKms, useUpdateExternalKms } from "@app/hooks/api";
+import {
+ AddExternalKmsSchema,
+ AddExternalKmsType,
+ ExternalKmsProvider,
+ Kms,
+ KmsAwsCredentialType
+} from "@app/hooks/api/kms/types";
+
+const AWS_REGIONS = [
+ { name: "US East (Ohio)", slug: "us-east-2" },
+ { name: "US East (N. Virginia)", slug: "us-east-1" },
+ { name: "US West (N. California)", slug: "us-west-1" },
+ { name: "US West (Oregon)", slug: "us-west-2" },
+ { name: "Africa (Cape Town)", slug: "af-south-1" },
+ { name: "Asia Pacific (Hong Kong)", slug: "ap-east-1" },
+ { name: "Asia Pacific (Hyderabad)", slug: "ap-south-2" },
+ { name: "Asia Pacific (Jakarta)", slug: "ap-southeast-3" },
+ { name: "Asia Pacific (Melbourne)", slug: "ap-southeast-4" },
+ { name: "Asia Pacific (Mumbai)", slug: "ap-south-1" },
+ { name: "Asia Pacific (Osaka)", slug: "ap-northeast-3" },
+ { name: "Asia Pacific (Seoul)", slug: "ap-northeast-2" },
+ { name: "Asia Pacific (Singapore)", slug: "ap-southeast-1" },
+ { name: "Asia Pacific (Sydney)", slug: "ap-southeast-2" },
+ { name: "Asia Pacific (Tokyo)", slug: "ap-northeast-1" },
+ { name: "Canada (Central)", slug: "ca-central-1" },
+ { name: "Europe (Frankfurt)", slug: "eu-central-1" },
+ { name: "Europe (Ireland)", slug: "eu-west-1" },
+ { name: "Europe (London)", slug: "eu-west-2" },
+ { name: "Europe (Milan)", slug: "eu-south-1" },
+ { name: "Europe (Paris)", slug: "eu-west-3" },
+ { name: "Europe (Spain)", slug: "eu-south-2" },
+ { name: "Europe (Stockholm)", slug: "eu-north-1" },
+ { name: "Europe (Zurich)", slug: "eu-central-2" },
+ { name: "Middle East (Bahrain)", slug: "me-south-1" },
+ { name: "Middle East (UAE)", slug: "me-central-1" },
+ { name: "South America (Sao Paulo)", slug: "sa-east-1" },
+ { name: "AWS GovCloud (US-East)", slug: "us-gov-east-1" },
+ { name: "AWS GovCloud (US-West)", slug: "us-gov-west-1" }
+];
+
+type Props = {
+ onCompleted: () => void;
+ onCancel: () => void;
+ kms?: Kms;
+};
+
+export const AwsKmsForm = ({ onCompleted, onCancel, kms }: Props) => {
+ const {
+ control,
+ handleSubmit,
+ watch,
+ setValue,
+ formState: { isSubmitting }
+ } = useForm<AddExternalKmsType>({
+ resolver: zodResolver(AddExternalKmsSchema),
+ defaultValues: {
+ name: kms?.name,
+ description: kms?.description ?? "",
+ provider: {
+ type: ExternalKmsProvider.Aws,
+ inputs: {
+ credential: {
+ type: kms?.external?.providerInput?.credential?.type,
+ data: {
+ accessKey: kms?.external?.providerInput?.credential?.data?.accessKey,
+ secretKey: kms?.external?.providerInput?.credential?.data?.secretKey,
+ assumeRoleArn: kms?.external?.providerInput?.credential?.data?.assumeRoleArn,
+ externalId: kms?.external?.providerInput?.credential?.data?.externalId
+ }
+ },
+ awsRegion: kms?.external?.providerInput?.awsRegion,
+ kmsKeyId: kms?.external?.providerInput?.kmsKeyId
+ }
+ }
+ }
+ });
+
+ const { currentOrg } = useOrganization();
+ const { mutateAsync: addAwsExternalKms } = useAddExternalKms(currentOrg.id);
+ const { mutateAsync: updateAwsExternalKms } = useUpdateExternalKms(currentOrg.id);
+
+ const selectedAwsAuthType = watch("provider.inputs.credential.type");
+
+ const handleAwsKmsFormSubmit = async (data: AddExternalKmsType) => {
+ const { name, description, provider } = data;
+ try {
+ if (kms) {
+ await updateAwsExternalKms({
+ kmsId: kms.id,
+ name,
+ description,
+ provider
+ });
+
+ createNotification({
+ text: "Successfully updated AWS External KMS",
+ type: "success"
+ });
+ } else {
+ await addAwsExternalKms({
+ name,
+ description,
+ provider
+ });
+
+ createNotification({
+ text: "Successfully added AWS External KMS",
+ type: "success"
+ });
+ }
+
+ onCompleted();
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(handleAwsKmsFormSubmit)} autoComplete="off">
+ <Controller
+ control={control}
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Alias" errorText={error?.message} isError={Boolean(error)}>
+ <Input placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="description"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Description" errorText={error?.message} isError={Boolean(error)}>
+ <Input placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="provider.inputs.credential.type"
+ defaultValue={KmsAwsCredentialType.AssumeRole}
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl
+ label="Authentication Mode"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => {
+ setValue("provider.inputs.credential.data.accessKey", "");
+ setValue("provider.inputs.credential.data.secretKey", "");
+ setValue("provider.inputs.credential.data.assumeRoleArn", "");
+ setValue("provider.inputs.credential.data.externalId", "");
+
+ onChange(e);
+ }}
+ className="w-full"
+ >
+ <SelectItem value={KmsAwsCredentialType.AssumeRole}>AWS Assume Role</SelectItem>
+ <SelectItem value={KmsAwsCredentialType.AccessKey}>Access Key</SelectItem>
+ </Select>
+ </FormControl>
+ )}
+ />
+
+ {selectedAwsAuthType === KmsAwsCredentialType.AccessKey ? (
+ <>
+ <Controller
+ control={control}
+ name="provider.inputs.credential.data.accessKey"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Key ID"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="provider.inputs.credential.data.secretKey"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Secret Access Key"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input type="password" autoComplete="new-password" placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+ </>
+ ) : (
+ <>
+ <Controller
+ control={control}
+ name="provider.inputs.credential.data.assumeRoleArn"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="IAM Role ARN For Role Assumption"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="provider.inputs.credential.data.externalId"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Assume Role External ID"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+ </>
+ )}
+ <Controller
+ control={control}
+ name="provider.inputs.awsRegion"
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl label="AWS Region" errorText={error?.message} isError={Boolean(error)}>
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ className="w-full border border-mineshaft-500"
+ >
+ {AWS_REGIONS.map((awsRegion) => (
+ <SelectItem value={awsRegion.slug} key={`kms-aws-region-${awsRegion.slug}`}>
+ {awsRegion.name} <Badge variant="success">{awsRegion.slug}</Badge>
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="provider.inputs.kmsKeyId"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="AWS KMS Key ID" errorText={error?.message} isError={Boolean(error)}>
+ <Input placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+ <div className="mt-6 flex items-center space-x-4">
+ <Button type="submit" isLoading={isSubmitting}>
+ Save
+ </Button>
+ <Button variant="outline_bg" onClick={onCancel}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/GcpKmsForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/GcpKmsForm.tsx
new file mode 100644
index 0000000000..b4476bcbc5
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/GcpKmsForm.tsx
@@ -0,0 +1,360 @@
+import { useEffect, useState } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Badge, Button, FilterableSelect, FormControl, Input } from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import {
+ useAddExternalKms,
+ useExternalKmsFetchGcpKeys,
+ useUpdateExternalKms
+} from "@app/hooks/api";
+import {
+ AddExternalKmsGcpFormSchema,
+ AddExternalKmsGcpFormSchemaType,
+ ExternalKmsGcpCredentialSchema,
+ ExternalKmsGcpCredentialSchemaType,
+ ExternalKmsProvider,
+ Kms
+} from "@app/hooks/api/kms/types";
+
+type Props = {
+ onCompleted: () => void;
+ onCancel: () => void;
+ kms?: Kms;
+};
+
+const GCP_REGIONS = [
+ { label: "Johannesburg", value: "africa-south1" },
+ { label: "Taiwan", value: "asia-east1" },
+ { label: "Hong Kong", value: "asia-east2" },
+ { label: "Tokyo", value: "asia-northeast1" },
+ { label: "Osaka", value: "asia-northeast2" },
+ { label: "Seoul", value: "asia-northeast3" },
+ { label: "Mumbai", value: "asia-south1" },
+ { label: "Delhi", value: "asia-south2" },
+ { label: "Singapore", value: "asia-southeast1" },
+ { label: "Jakarta", value: "asia-southeast2" },
+ { label: "Sydney", value: "australia-southeast1" },
+ { label: "Melbourne", value: "australia-southeast2" },
+ { label: "Warsaw", value: "europe-central2" },
+ { label: "Finland", value: "europe-north1" },
+ { label: "Belgium", value: "europe-west1" },
+ { label: "London", value: "europe-west2" },
+ { label: "Frankfurt", value: "europe-west3" },
+ { label: "Netherlands", value: "europe-west4" },
+ { label: "Zurich", value: "europe-west6" },
+ { label: "Milan", value: "europe-west8" },
+ { label: "Paris", value: "europe-west9" },
+ { label: "Berlin", value: "europe-west10" },
+ { label: "Turin", value: "europe-west12" },
+ { label: "Madrid", value: "europe-southwest1" },
+ { label: "Doha", value: "me-central1" },
+ { label: "Dammam", value: "me-central2" },
+ { label: "Tel Aviv", value: "me-west1" },
+ { label: "Montréal", value: "northamerica-northeast1" },
+ { label: "Toronto", value: "northamerica-northeast2" },
+ { label: "São Paulo", value: "southamerica-east1" },
+ { label: "Santiago", value: "southamerica-west1" },
+ { label: "Iowa", value: "us-central1" },
+ { label: "South Carolina", value: "us-east1" },
+ { label: "North Virginia", value: "us-east4" },
+ { label: "Columbus", value: "us-east5" },
+ { label: "Dallas", value: "us-south1" },
+ { label: "Oregon", value: "us-west1" },
+ { label: "Los Angeles", value: "us-west2" },
+ { label: "Salt Lake City", value: "us-west3" },
+ { label: "Las Vegas", value: "us-west4" }
+];
+
+const formatOptionLabel = ({ value, label }: { value: string; label: string }) => (
+ <div className="flex w-full flex-row items-center justify-between">
+ <span>{label}</span>
+ <Badge variant="success">{value}</Badge>
+ </div>
+);
+
+export const GcpKmsForm = ({ onCompleted, onCancel, kms }: Props) => {
+ const [isCredentialValid, setIsCredentialValid] = useState<boolean>(false);
+ const [keys, setKeys] = useState<{ value: string; label: string }[]>([]);
+
+ const {
+ control,
+ handleSubmit,
+ setError,
+ clearErrors,
+ getValues,
+ resetField,
+ setValue,
+ formState: { isSubmitting }
+ } = useForm<AddExternalKmsGcpFormSchemaType>({
+ resolver: zodResolver(AddExternalKmsGcpFormSchema),
+ defaultValues: {
+ formType: kms ? "updateGcpKms" : "newGcpKms",
+ name: kms?.name ?? "",
+ description: kms?.description ?? "",
+ gcpRegion: kms
+ ? {
+ label:
+ GCP_REGIONS.find((r) => r.value === kms.external.providerInput.gcpRegion)?.label ??
+ "",
+ value: kms.external.providerInput.gcpRegion
+ }
+ : undefined,
+ keyObject: undefined
+ }
+ });
+
+ const { currentOrg } = useOrganization();
+ const { mutateAsync: addGcpExternalKms } = useAddExternalKms(currentOrg.id);
+ const { mutateAsync: updateGcpExternalKms } = useUpdateExternalKms(currentOrg.id);
+ const { mutateAsync: fetchGcpKeys, isLoading: isFetchGcpKeysLoading } =
+ useExternalKmsFetchGcpKeys(currentOrg?.id);
+
+ // transforms the credential file into a JSON object
+ async function getCredentialFileJson(): Promise<ExternalKmsGcpCredentialSchemaType | null> {
+ const files = getValues("credentialFile");
+ if (!files || !files.length) {
+ return null;
+ }
+ const file = files[0];
+ if (file.type !== "application/json") {
+ setError("credentialFile", {
+ message: "Only .json files are accepted."
+ });
+ return null;
+ }
+ const jsonContents = await file.text();
+ const parsedJson = ExternalKmsGcpCredentialSchema.safeParse(JSON.parse(jsonContents));
+ if (!parsedJson.success) {
+ setError("credentialFile", {
+ message: "Invalid Service Account credential JSON."
+ });
+ return null;
+ }
+ clearErrors("credentialFile");
+ return parsedJson.data;
+ }
+
+ // handles the form submission
+ const handleGcpKmsFormSubmit = async (data: AddExternalKmsGcpFormSchemaType) => {
+ const { name, description, gcpRegion: gcpRegionObject, keyObject } = data;
+ const gcpRegion = gcpRegionObject.value;
+ if (!keys.find((k) => k.value === keyObject?.value)) {
+ setError("keyObject", {
+ message: "Please select a valid key."
+ });
+ resetField("keyObject");
+ return;
+ }
+
+ try {
+ if (kms) {
+ await updateGcpExternalKms({
+ kmsId: kms.id,
+ name,
+ description,
+ provider: {
+ type: ExternalKmsProvider.Gcp,
+ inputs: {
+ gcpRegion,
+ keyName: keyObject?.value
+ }
+ }
+ });
+
+ createNotification({
+ text: "Successfully updated GCP External KMS",
+ type: "success"
+ });
+ } else {
+ const credentialJson = await getCredentialFileJson();
+ if (!credentialJson) {
+ return;
+ }
+ await addGcpExternalKms({
+ name,
+ description,
+ provider: {
+ type: ExternalKmsProvider.Gcp,
+ inputs: {
+ gcpRegion,
+ keyName: keyObject?.value,
+ credential: credentialJson
+ }
+ }
+ });
+
+ createNotification({
+ text: "Successfully added GCP External KMS",
+ type: "success"
+ });
+ }
+
+ onCompleted();
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
+ const fetchGCPKeys = async () => {
+ // @ts-expect-error - issue with the way react-select renders the placeholder. We need to set the value to null explicitly otherwise it will not re-render
+ setValue("keyObject", null);
+ setKeys([]);
+
+ const credentialJson = kms ? undefined : await getCredentialFileJson();
+ if (!kms && !credentialJson) {
+ return;
+ }
+ const gcpRegion = getValues("gcpRegion").value;
+ if (!gcpRegion.length) {
+ setError("gcpRegion", {
+ message: "Please select a GCP region to fetch GCP Keys."
+ });
+ return;
+ }
+ const res = await fetchGcpKeys({
+ gcpRegion,
+ ...(kms ? { kmsId: kms.id } : { credential: credentialJson! })
+ });
+ setIsCredentialValid(!!res.keys);
+ const returnedKeys = res.keys.map((key) => {
+ const parts = key.split("/");
+ const keyLabel = `${parts[5]}/${parts[7]}`;
+ return {
+ value: key,
+ label: keyLabel
+ };
+ });
+
+ setKeys(returnedKeys);
+ if (kms) {
+ const existingKey = returnedKeys.find((k) => k.value === kms.external.providerInput.keyName);
+ if (existingKey) {
+ setValue("keyObject", existingKey);
+ }
+ }
+ };
+
+ const getPlaceholderText = () => {
+ if (isFetchGcpKeysLoading) {
+ return "Loading keys in this region...";
+ }
+ if (!isCredentialValid) {
+ return "Upload a valid credential file";
+ }
+ if (keys.length) {
+ return "Select a key";
+ }
+
+ return "No valid keys found in this region";
+ };
+
+ useEffect(() => {
+ if (kms && !isCredentialValid) {
+ fetchGCPKeys();
+ }
+ }, [kms]);
+
+ return (
+ <form onSubmit={handleSubmit(handleGcpKmsFormSubmit)} autoComplete="off">
+ <Controller
+ control={control}
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Alias" errorText={error?.message} isError={Boolean(error)}>
+ <Input placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="description"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Description" errorText={error?.message} isError={Boolean(error)}>
+ <Input placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="gcpRegion"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="GCP Region" errorText={error?.message} isError={Boolean(error)}>
+ <FilterableSelect
+ className="w-full"
+ placeholder="Select a GCP region"
+ name="gcpRegion"
+ options={GCP_REGIONS}
+ value={field.value}
+ onChange={(e) => {
+ resetField("keyObject");
+ field.onChange(e);
+ fetchGCPKeys();
+ }}
+ formatOptionLabel={formatOptionLabel}
+ />
+ </FormControl>
+ )}
+ />
+ {!kms && (
+ <Controller
+ control={control}
+ name="credentialFile"
+ render={({ field: { value, onChange, ref, ...rest }, fieldState: { error } }) => (
+ <FormControl
+ label="Service Account Credential JSON"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Input
+ {...rest}
+ ref={ref}
+ type="file"
+ accept=".json"
+ placeholder=""
+ value={value?.filename}
+ onChange={(e) => {
+ onChange(e.target.files);
+ fetchGCPKeys();
+ }}
+ />
+ </FormControl>
+ )}
+ />
+ )}
+ <Controller
+ control={control}
+ name="keyObject"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="GCP Key Name" errorText={error?.message} isError={Boolean(error)}>
+ <FilterableSelect
+ className="w-full"
+ placeholder={getPlaceholderText()}
+ isDisabled={!isCredentialValid || !keys.length}
+ name="key"
+ options={keys}
+ value={field.value}
+ onChange={field.onChange}
+ />
+ </FormControl>
+ )}
+ />
+ {kms && (
+ <span className="text-xs text-mineshaft-300">
+ To change your GCP credentials, create a new external KMS and assign it to project you
+ want to use it with.
+ </span>
+ )}
+ <div className="mt-6 flex items-center space-x-4">
+ <Button type="submit" isLoading={isSubmitting}>
+ Save
+ </Button>
+ <Button variant="outline_bg" onClick={onCancel}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/OrgEncryptionTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/OrgEncryptionTab.tsx
new file mode 100644
index 0000000000..d2d676bdf2
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/OrgEncryptionTab.tsx
@@ -0,0 +1,221 @@
+import { faAws, faGoogle } from "@fortawesome/free-brands-svg-icons";
+import { faEllipsis, faLock, faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { twMerge } from "tailwind-merge";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ DeleteActionModal,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ EmptyState,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ THead,
+ Tr,
+ UpgradePlanModal
+} from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { withPermission } from "@app/hoc";
+import { usePopUp } from "@app/hooks";
+import { useGetExternalKmsList, useRemoveExternalKms } from "@app/hooks/api";
+import { ExternalKmsProvider } from "@app/hooks/api/kms/types";
+
+import { AddExternalKmsForm } from "./AddExternalKmsForm";
+import { UpdateExternalKmsForm } from "./UpdateExternalKmsForm";
+
+export const OrgEncryptionTab = withPermission(
+ () => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+ const orgId = currentOrg?.id || "";
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([
+ "upgradePlan",
+ "addExternalKms",
+ "editExternalKms",
+ "removeExternalKms"
+ ] as const);
+ const { data: externalKmsList, isLoading: isExternalKmsListLoading } =
+ useGetExternalKmsList(orgId);
+
+ const { mutateAsync: removeExternalKms } = useRemoveExternalKms(currentOrg.id);
+
+ const handleRemoveExternalKms = async () => {
+ const { kmsId } = popUp?.removeExternalKms?.data as {
+ kmsId: string;
+ };
+
+ try {
+ await removeExternalKms(kmsId);
+
+ createNotification({
+ text: "Successfully deleted external KMS",
+ type: "success"
+ });
+
+ handlePopUpToggle("removeExternalKms", false);
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex justify-between">
+ <p className="text-xl font-semibold text-mineshaft-100">Key Management System (KMS)</p>
+ <OrgPermissionCan I={OrgPermissionActions.Create} an={OrgPermissionSubjects.Kms}>
+ {(isAllowed) => (
+ <Button
+ onClick={() => {
+ if (subscription && !subscription?.externalKms) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+ handlePopUpOpen("addExternalKms");
+ }}
+ isDisabled={!isAllowed}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ >
+ Add
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="mb-4 text-gray-400">
+ Encrypt your organization&apos;s data with external KMS.
+ </p>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Td>Provider</Td>
+ <Td>Alias</Td>
+ </Tr>
+ </THead>
+ <TBody>
+ {isExternalKmsListLoading && <TableSkeleton columns={2} innerKey="kms-loading" />}
+ {!isExternalKmsListLoading && externalKmsList && externalKmsList?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No external KMS found" icon={faLock} />
+ </Td>
+ </Tr>
+ )}
+ {!isExternalKmsListLoading &&
+ externalKmsList?.map((kms) => (
+ <Tr key={kms.id}>
+ <Td className="flex max-w-xs items-center overflow-hidden text-ellipsis hover:overflow-auto hover:break-all">
+ {kms.externalKms.provider === ExternalKmsProvider.Aws && (
+ <FontAwesomeIcon icon={faAws} />
+ )}
+ {kms.externalKms.provider === ExternalKmsProvider.Gcp && (
+ <FontAwesomeIcon icon={faGoogle} />
+ )}
+ <div className="ml-2">{kms.externalKms.provider.toUpperCase()}</div>
+ </Td>
+ <Td>{kms.name}</Td>
+ <Td>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <div className="flex justify-end hover:text-primary-400 data-[state=open]:text-primary-400">
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ an={OrgPermissionSubjects.Kms}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ disabled={!isAllowed}
+ className={twMerge(
+ !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (subscription && !subscription?.externalKms) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ handlePopUpOpen("editExternalKms", {
+ kmsId: kms.id
+ });
+ }}
+ >
+ Edit
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ an={OrgPermissionSubjects.Kms}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ disabled={!isAllowed}
+ className={twMerge(
+ !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("removeExternalKms", {
+ name: kms.name,
+ kmsId: kms.id,
+ provider: kms.externalKms.provider
+ });
+ }}
+ >
+ Delete
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </Td>
+ </Tr>
+ ))}
+ </TBody>
+ </Table>
+ </TableContainer>
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text="You can configure external KMS if you switch to Infisical's Enterprise plan."
+ />
+ <AddExternalKmsForm
+ isOpen={popUp.addExternalKms.isOpen}
+ onToggle={(state) => handlePopUpToggle("addExternalKms", state)}
+ />
+ <UpdateExternalKmsForm
+ isOpen={popUp.editExternalKms.isOpen}
+ kmsId={(popUp.editExternalKms.data as { kmsId: string })?.kmsId}
+ onOpenChange={(state) => handlePopUpToggle("editExternalKms", state)}
+ />
+ <DeleteActionModal
+ isOpen={popUp.removeExternalKms.isOpen}
+ title={`Are you sure want to remove ${
+ (popUp?.removeExternalKms?.data as { slug: string })?.slug || ""
+ } from ${(popUp?.removeExternalKms?.data as { provider: string })?.provider || ""}?`}
+ onChange={(isOpen) => handlePopUpToggle("removeExternalKms", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={handleRemoveExternalKms}
+ />
+ </div>
+ );
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Kms }
+);
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/UpdateExternalKmsForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/UpdateExternalKmsForm.tsx
new file mode 100644
index 0000000000..bc2e85558f
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/UpdateExternalKmsForm.tsx
@@ -0,0 +1,37 @@
+import { ContentLoader, Modal, ModalContent } from "@app/components/v2";
+import { useGetExternalKmsById } from "@app/hooks/api";
+import { ExternalKmsProvider } from "@app/hooks/api/kms/types";
+
+import { AwsKmsForm } from "./AwsKmsForm";
+import { GcpKmsForm } from "./GcpKmsForm";
+
+type Props = {
+ isOpen: boolean;
+ kmsId: string;
+ onOpenChange: (state: boolean) => void;
+};
+
+export const UpdateExternalKmsForm = ({ isOpen, kmsId, onOpenChange }: Props) => {
+ const { data: externalKms, isLoading } = useGetExternalKmsById(kmsId);
+ return (
+ <Modal isOpen={isOpen} onOpenChange={onOpenChange}>
+ <ModalContent title="Edit configuration" bodyClassName="overflow-visible">
+ {isLoading && <ContentLoader />}
+ {externalKms?.external?.provider === ExternalKmsProvider.Aws && (
+ <AwsKmsForm
+ kms={externalKms}
+ onCancel={() => onOpenChange(false)}
+ onCompleted={() => onOpenChange(false)}
+ />
+ )}
+ {externalKms?.external?.provider === ExternalKmsProvider.Gcp && (
+ <GcpKmsForm
+ kms={externalKms}
+ onCancel={() => onOpenChange(false)}
+ onCompleted={() => onOpenChange(false)}
+ />
+ )}
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/index.tsx
new file mode 100644
index 0000000000..c32c02d763
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgEncryptionTab/index.tsx
@@ -0,0 +1 @@
+export { OrgEncryptionTab } from "./OrgEncryptionTab";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgGeneralTab/OrgGeneralTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgGeneralTab/OrgGeneralTab.tsx
new file mode 100644
index 0000000000..917d08be96
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgGeneralTab/OrgGeneralTab.tsx
@@ -0,0 +1,16 @@
+import { useOrgPermission } from "@app/context";
+
+import { OrgDeleteSection } from "../OrgDeleteSection";
+import { OrgIncidentContactsSection } from "../OrgIncidentContactsSection";
+import { OrgNameChangeSection } from "../OrgNameChangeSection";
+
+export const OrgGeneralTab = () => {
+ const { membership } = useOrgPermission();
+ return (
+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
+ <OrgNameChangeSection />
+ <OrgIncidentContactsSection />
+ {membership && membership.role === "admin" && <OrgDeleteSection />}
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgGeneralTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgGeneralTab/index.tsx
new file mode 100644
index 0000000000..46db8314d8
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgGeneralTab/index.tsx
@@ -0,0 +1 @@
+export { OrgGeneralTab } from "./OrgGeneralTab";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/AddOrgIncidentContactModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/AddOrgIncidentContactModal.tsx
new file mode 100644
index 0000000000..1748682cd3
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/AddOrgIncidentContactModal.tsx
@@ -0,0 +1,104 @@
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useAddIncidentContact } from "@app/hooks/api";
+import { useFetchServerStatus } from "@app/hooks/api/serverDetails";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
+const addContactFormSchema = z.object({
+ email: z.string().email().trim()
+});
+
+type TAddContactForm = z.infer<typeof addContactFormSchema>;
+
+type Props = {
+ popUp: UsePopUpState<["addContact"]>;
+ handlePopUpClose: (popUpName: keyof UsePopUpState<["addContact"]>) => void;
+ handlePopUpToggle: (popUpName: keyof UsePopUpState<["addContact"]>, state?: boolean) => void;
+};
+
+export const AddOrgIncidentContactModal = ({
+ popUp,
+ handlePopUpClose,
+ handlePopUpToggle
+}: Props) => {
+ const { currentOrg } = useOrganization();
+ const { data: serverDetails } = useFetchServerStatus();
+ const { control, handleSubmit, reset } = useForm<TAddContactForm>({
+ resolver: zodResolver(addContactFormSchema)
+ });
+
+ const { mutateAsync, isLoading } = useAddIncidentContact();
+
+ const onFormSubmit = async ({ email }: TAddContactForm) => {
+ try {
+ if (!currentOrg?.id) return;
+
+ await mutateAsync({
+ orgId: currentOrg.id,
+ email
+ });
+
+ createNotification({
+ text: "Successfully added incident contact",
+ type: "success"
+ });
+
+ if (serverDetails?.emailConfigured) {
+ handlePopUpClose("addContact");
+ }
+
+ reset();
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to add incident contact",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <Modal
+ isOpen={popUp?.addContact?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addContact", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent
+ title="Add an Incident Contact"
+ subTitle="This contact will be notified in the unlikely event of a severe incident."
+ >
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="email"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Email" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ <div className="mt-8 flex items-center space-x-4">
+ <Button size="sm" type="submit" isLoading={isLoading} isDisabled={isLoading}>
+ Add Incident Contact
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpClose("addContact")}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/OrgIncidentContactsSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/OrgIncidentContactsSection.tsx
new file mode 100644
index 0000000000..61639f5247
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/OrgIncidentContactsSection.tsx
@@ -0,0 +1,53 @@
+import { useTranslation } from "react-i18next";
+import { faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan, PermissionDeniedBanner } from "@app/components/permissions";
+import { Button } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrgPermission } from "@app/context";
+import { usePopUp } from "@app/hooks";
+
+import { AddOrgIncidentContactModal } from "./AddOrgIncidentContactModal";
+import { OrgIncidentContactsTable } from "./OrgIncidentContactsTable";
+
+export const OrgIncidentContactsSection = () => {
+ const { t } = useTranslation();
+ const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
+ "addContact"
+ ] as const);
+ const { permission } = useOrgPermission();
+
+ return (
+ <>
+ <hr className="border-mineshaft-600" />
+ <div className="flex items-center justify-between pt-4">
+ <p className="text-md text-mineshaft-100">{t("section.incident.incident-contacts")}</p>
+ <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.IncidentAccount}>
+ {(isAllowed) => (
+ <Button
+ colorSchema="secondary"
+ type="submit"
+ isDisabled={!isAllowed}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ onClick={() => handlePopUpOpen("addContact")}
+ >
+ Add contact
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <div className="py-4">
+ {permission.can(OrgPermissionActions.Read, OrgPermissionSubjects.IncidentAccount) ? (
+ <OrgIncidentContactsTable />
+ ) : (
+ <PermissionDeniedBanner />
+ )}
+ </div>
+ <AddOrgIncidentContactModal
+ popUp={popUp}
+ handlePopUpClose={handlePopUpClose}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/OrgIncidentContactsTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/OrgIncidentContactsTable.tsx
new file mode 100644
index 0000000000..29d1e721bd
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/OrgIncidentContactsTable.tsx
@@ -0,0 +1,119 @@
+import { useState } from "react";
+import { faContactBook, faMagnifyingGlass, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ DeleteActionModal,
+ EmptyState,
+ IconButton,
+ Input,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { usePopUp } from "@app/hooks";
+import { useDeleteIncidentContact, useGetOrgIncidentContact } from "@app/hooks/api";
+
+export const OrgIncidentContactsTable = () => {
+ const { currentOrg } = useOrganization();
+ const { data: contacts, isLoading } = useGetOrgIncidentContact(currentOrg?.id ?? "");
+ const [searchContact, setSearchContact] = useState("");
+ const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
+ "removeContact",
+ "setUpEmail"
+ ] as const);
+ const { mutateAsync } = useDeleteIncidentContact();
+
+ const onRemoveIncidentContact = async () => {
+ try {
+ const incidentContactId = (popUp?.removeContact?.data as { id: string })?.id;
+
+ if (!currentOrg?.id) return;
+ await mutateAsync({
+ orgId: currentOrg.id,
+ incidentContactId
+ });
+
+ createNotification({
+ text: "Successfully removed incident contact",
+ type: "success"
+ });
+
+ handlePopUpClose("removeContact");
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to remove incident contact",
+ type: "error"
+ });
+ }
+ };
+
+ const filteredContacts = contacts
+ ? contacts.filter(({ email }) => email.toLocaleLowerCase().includes(searchContact))
+ : [];
+
+ return (
+ <div>
+ <Input
+ value={searchContact}
+ onChange={(e) => setSearchContact(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search incident contact by email..."
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Email</Th>
+ <Th aria-label="actions" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={2} innerKey="incident-contact" />}
+ {filteredContacts?.map(({ email, id }) => (
+ <Tr key={email}>
+ <Td className="w-full">{email}</Td>
+ <Td className="mr-4">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ an={OrgPermissionSubjects.IncidentAccount}
+ >
+ {(isAllowed) => (
+ <IconButton
+ ariaLabel="delete"
+ colorSchema="danger"
+ onClick={() => handlePopUpOpen("removeContact", { email, id })}
+ isDisabled={!isAllowed}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ )}
+ </OrgPermissionCan>
+ </Td>
+ </Tr>
+ ))}
+ </TBody>
+ </Table>
+ {filteredContacts?.length === 0 && !isLoading && (
+ <EmptyState title="No incident contacts found" icon={faContactBook} />
+ )}
+ </TableContainer>
+ <DeleteActionModal
+ isOpen={popUp.removeContact.isOpen}
+ deleteKey="remove"
+ title="Do you want to remove this email from incident contact?"
+ onChange={(isOpen) => handlePopUpToggle("removeContact", isOpen)}
+ onDeleteApproved={onRemoveIncidentContact}
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/index.tsx
new file mode 100644
index 0000000000..ceaf7269e6
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgIncidentContactsSection/index.tsx
@@ -0,0 +1,2 @@
+export { AddOrgIncidentContactModal } from "./AddOrgIncidentContactModal";
+export { OrgIncidentContactsSection } from "./OrgIncidentContactsSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgNameChangeSection/OrgNameChangeSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgNameChangeSection/OrgNameChangeSection.tsx
new file mode 100644
index 0000000000..0fca370007
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgNameChangeSection/OrgNameChangeSection.tsx
@@ -0,0 +1,168 @@
+import { useEffect, useState } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, FormControl, Input, Select, SelectItem, Spinner } from "@app/components/v2";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useOrgPermission
+} from "@app/context";
+import { isCustomOrgRole } from "@app/helpers/roles";
+import { useGetOrgRoles, useUpdateOrg } from "@app/hooks/api";
+
+const formSchema = z.object({
+ name: z.string().max(64, "Too long, maximum length is 64 characters"),
+ slug: z
+ .string()
+ .regex(/^[a-zA-Z0-9-]+$/, "Name must only contain alphanumeric characters or hyphens"),
+ defaultMembershipRole: z.string()
+});
+
+type FormData = z.infer<typeof formSchema>;
+
+export const OrgNameChangeSection = (): JSX.Element => {
+ const { currentOrg } = useOrganization();
+ const { permission } = useOrgPermission();
+
+ const { handleSubmit, control, reset } = useForm<FormData>({
+ resolver: zodResolver(formSchema)
+ });
+ const { mutateAsync, isLoading } = useUpdateOrg();
+
+ const canReadOrgRoles = permission.can(OrgPermissionActions.Read, OrgPermissionSubjects.Role);
+
+ const { data: roles, isLoading: isRolesLoading } = useGetOrgRoles(currentOrg.id, canReadOrgRoles);
+ const [isFormInitialized, setIsFormInitialized] = useState(false);
+
+ useEffect(() => {
+ if (currentOrg) {
+ reset({
+ name: currentOrg.name,
+ slug: currentOrg.slug,
+ ...(canReadOrgRoles &&
+ roles?.length && {
+ // will always be present, can't remove role if default
+ defaultMembershipRole: isCustomOrgRole(currentOrg.defaultMembershipRole)
+ ? roles?.find((role) => currentOrg.defaultMembershipRole === role.id)?.slug || ""
+ : currentOrg.defaultMembershipRole
+ })
+ });
+ setIsFormInitialized(true);
+ }
+ }, [currentOrg, roles]);
+
+ const onFormSubmit = async ({ name, slug, defaultMembershipRole }: FormData) => {
+ try {
+ if (!currentOrg?.id || !roles?.length) return;
+
+ await mutateAsync({
+ orgId: currentOrg?.id,
+ name,
+ slug,
+ defaultMembershipRoleSlug: defaultMembershipRole
+ });
+
+ createNotification({
+ text: "Successfully updated organization details",
+ type: "success"
+ });
+ } catch (error) {
+ console.error(error);
+ createNotification({
+ text: "Failed to update organization details",
+ type: "error"
+ });
+ }
+ };
+
+ if (!isFormInitialized) {
+ return (
+ <div className="flex h-[25.25rem] w-full items-center justify-center">
+ <Spinner size="lg" />
+ </div>
+ );
+ }
+
+ return (
+ <form onSubmit={handleSubmit(onFormSubmit)} className="py-4">
+ <div className="">
+ <h2 className="text-md mb-2 text-mineshaft-100">Organization Name</h2>
+ <Controller
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl isError={Boolean(error)} errorText={error?.message} className="max-w-md">
+ <Input placeholder="Acme Corp" {...field} />
+ </FormControl>
+ )}
+ control={control}
+ name="name"
+ />
+ </div>
+ <div className="py-4">
+ <h2 className="text-md mb-2 text-mineshaft-100">Organization Slug</h2>
+ <Controller
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl isError={Boolean(error)} errorText={error?.message} className="max-w-md">
+ <Input placeholder="acme" {...field} />
+ </FormControl>
+ )}
+ control={control}
+ name="slug"
+ />
+ </div>
+ {canReadOrgRoles && (
+ <div className="pb-4">
+ <h2 className="text-md mb-2 text-mineshaft-100">Default Organization Member Role</h2>
+ <p className="text-mineshaft-400" />
+ <Controller
+ defaultValue=""
+ control={control}
+ name="defaultMembershipRole"
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ helperText="Users joining your organization will be assigned this role unless otherwise specified."
+ isError={Boolean(error)}
+ errorText={error?.message}
+ className="max-w-md"
+ >
+ <Select
+ isDisabled={isRolesLoading}
+ className="w-full capitalize"
+ value={value}
+ onValueChange={!roles?.length ? undefined : onChange}
+ >
+ {roles?.map((role) => {
+ return (
+ <SelectItem key={role.id} value={role.slug}>
+ {role.name}
+ </SelectItem>
+ );
+ })}
+ </Select>
+ </FormControl>
+ )}
+ />
+ </div>
+ )}
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Settings}>
+ {(isAllowed) => (
+ <Button
+ isLoading={isLoading}
+ isDisabled={!isAllowed}
+ colorSchema="primary"
+ variant="outline_bg"
+ type="submit"
+ >
+ Save
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgNameChangeSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgNameChangeSection/index.tsx
new file mode 100644
index 0000000000..4d86fcddb2
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgNameChangeSection/index.tsx
@@ -0,0 +1 @@
+export { OrgNameChangeSection } from "./OrgNameChangeSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgTabGroup/OrgTabGroup.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgTabGroup/OrgTabGroup.tsx
new file mode 100644
index 0000000000..b2dd405a3e
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgTabGroup/OrgTabGroup.tsx
@@ -0,0 +1,65 @@
+import { useState } from "react";
+import { useSearch } from "@tanstack/react-router";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+
+import { AuditLogStreamsTab } from "../AuditLogStreamTab";
+import { ImportTab } from "../ImportTab";
+import { OrgAuthTab } from "../OrgAuthTab";
+import { OrgEncryptionTab } from "../OrgEncryptionTab";
+import { OrgGeneralTab } from "../OrgGeneralTab";
+import { OrgWorkflowIntegrationTab } from "../OrgWorkflowIntegrationTab/OrgWorkflowIntegrationTab";
+import { ProjectTemplatesTab } from "../ProjectTemplatesTab";
+
+const tabs = [
+ { name: "General", key: "tab-org-general" },
+ { name: "Security", key: "tab-org-security" },
+ { name: "Encryption", key: "tab-org-encryption" },
+ { name: "Workflow Integrations", key: "workflow-integrations" },
+ { name: "Audit Log Streams", key: "tag-audit-log-streams" },
+ { name: "Import", key: "tab-import" },
+ { name: "Project Templates", key: "project-templates" }
+];
+export const OrgTabGroup = () => {
+ const search = useSearch({
+ from: "/_authenticate/_org_details/_org-layout/organization/$organizationId/settings"
+ });
+ const [selectedTab, setSelectedTab] = useState(search.selectedTab || tabs[0].key);
+
+ return (
+ <Tabs value={selectedTab} onValueChange={setSelectedTab}>
+ <TabList>
+ {tabs.map((tab) => (
+ <Tab value={tab.key} key={tab.key}>
+ {tab.name}
+ </Tab>
+ ))}
+ </TabList>
+ <TabPanel value={tabs[0].key}>
+ <OrgGeneralTab />
+ </TabPanel>
+ <TabPanel value={tabs[1].key}>
+ <OrgAuthTab />
+ </TabPanel>
+ <TabPanel value={tabs[2].key}>
+ <OrgEncryptionTab />
+ </TabPanel>
+ <TabPanel value={tabs[3].key}>
+ <OrgWorkflowIntegrationTab />
+ </TabPanel>
+ <TabPanel value={tabs[4].key}>
+ <AuditLogStreamsTab />
+ </TabPanel>
+ <OrgPermissionCan I={OrgPermissionActions.Create} an={OrgPermissionSubjects.Workspace}>
+ <TabPanel value={tabs[5].key}>
+ <ImportTab />
+ </TabPanel>
+ </OrgPermissionCan>
+ <TabPanel value={tabs[6].key}>
+ <ProjectTemplatesTab />
+ </TabPanel>
+ </Tabs>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgTabGroup/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgTabGroup/index.tsx
new file mode 100644
index 0000000000..6486136420
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgTabGroup/index.tsx
@@ -0,0 +1 @@
+export { OrgTabGroup } from "./OrgTabGroup";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/AddWorkflowIntegrationForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/AddWorkflowIntegrationForm.tsx
new file mode 100644
index 0000000000..1d12b50ddc
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/AddWorkflowIntegrationForm.tsx
@@ -0,0 +1,93 @@
+import { useState } from "react";
+import { faSlack } from "@fortawesome/free-brands-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { AnimatePresence, motion } from "framer-motion";
+
+import { Modal, ModalContent } from "@app/components/v2";
+import { WorkflowIntegrationPlatform } from "@app/hooks/api/workflowIntegrations/types";
+
+import { SlackIntegrationForm } from "./SlackIntegrationForm";
+
+type Props = {
+ isOpen?: boolean;
+ onToggle: (isOpen: boolean) => void;
+};
+
+enum WizardSteps {
+ SelectPlatform = "select-platform",
+ PlatformInputs = "platform-inputs"
+}
+
+const PLATFORM_LIST = [
+ {
+ icon: faSlack,
+ platform: WorkflowIntegrationPlatform.SLACK,
+ title: "Slack"
+ }
+];
+
+export const AddWorkflowIntegrationForm = ({ isOpen, onToggle }: Props) => {
+ const [wizardStep, setWizardStep] = useState(WizardSteps.SelectPlatform);
+ const [selectedPlatform, setSelectedPlatform] = useState<string | null>(null);
+
+ const handleFormReset = (state: boolean = false) => {
+ onToggle(state);
+ setWizardStep(WizardSteps.SelectPlatform);
+ setSelectedPlatform(null);
+ };
+
+ return (
+ <Modal isOpen={isOpen} onOpenChange={(state) => handleFormReset(state)}>
+ <ModalContent title={`Add a ${selectedPlatform ?? "workflow"} integration`} className="my-4">
+ <AnimatePresence mode="wait">
+ {wizardStep === WizardSteps.SelectPlatform && (
+ <motion.div
+ key="select-type-step"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <div className="mb-4 text-mineshaft-300">Select a platform</div>
+ <div className="flex items-center space-x-4">
+ {PLATFORM_LIST.map(({ icon, platform, title }) => (
+ <div
+ key={platform}
+ className="flex h-28 w-32 cursor-pointer flex-col items-center space-y-4 rounded border border-mineshaft-500 bg-bunker-600 p-6 transition-all hover:border-primary/70 hover:bg-primary/10 hover:text-white"
+ role="button"
+ tabIndex={0}
+ onClick={() => {
+ setSelectedPlatform(platform);
+ setWizardStep(WizardSteps.PlatformInputs);
+ }}
+ onKeyDown={(evt) => {
+ if (evt.key === "Enter") {
+ setSelectedPlatform(platform);
+ setWizardStep(WizardSteps.PlatformInputs);
+ }
+ }}
+ >
+ <FontAwesomeIcon icon={icon} size="lg" />
+ <div className="whitespace-pre-wrap text-center text-sm">{title}</div>
+ </div>
+ ))}
+ </div>
+ </motion.div>
+ )}
+ {wizardStep === WizardSteps.PlatformInputs &&
+ selectedPlatform === WorkflowIntegrationPlatform.SLACK && (
+ <motion.div
+ key="slack-platform"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <SlackIntegrationForm onClose={() => onToggle(false)} />
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/IntegrationFormDetails.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/IntegrationFormDetails.tsx
new file mode 100644
index 0000000000..a9af20247c
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/IntegrationFormDetails.tsx
@@ -0,0 +1,26 @@
+import { Modal, ModalContent } from "@app/components/v2";
+import { WorkflowIntegrationPlatform } from "@app/hooks/api/workflowIntegrations/types";
+
+import { SlackIntegrationForm } from "./SlackIntegrationForm";
+
+type Props = {
+ isOpen: boolean;
+ id: string;
+ workflowPlatform: WorkflowIntegrationPlatform;
+ onOpenChange: (state: boolean) => void;
+};
+
+export const IntegrationFormDetails = ({ isOpen, id, onOpenChange, workflowPlatform }: Props) => {
+ const modalTitle =
+ workflowPlatform === WorkflowIntegrationPlatform.SLACK ? "Slack integration" : "Integration";
+
+ return (
+ <Modal isOpen={isOpen} onOpenChange={onOpenChange}>
+ <ModalContent title={modalTitle}>
+ {workflowPlatform === WorkflowIntegrationPlatform.SLACK && (
+ <SlackIntegrationForm id={id} onClose={() => onOpenChange(false)} />
+ )}
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/OrgWorkflowIntegrationTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/OrgWorkflowIntegrationTab.tsx
new file mode 100644
index 0000000000..cb0b7ae080
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/OrgWorkflowIntegrationTab.tsx
@@ -0,0 +1,240 @@
+import { faSlack } from "@fortawesome/free-brands-svg-icons";
+import { faEllipsis, faGear, faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { useNavigate } from "@tanstack/react-router";
+import axios from "axios";
+import { twMerge } from "tailwind-merge";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ DeleteActionModal,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ EmptyState,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { withPermission } from "@app/hoc";
+import { usePopUp } from "@app/hooks";
+import {
+ fetchSlackReinstallUrl,
+ useDeleteSlackIntegration,
+ useGetWorkflowIntegrations
+} from "@app/hooks/api";
+import { WorkflowIntegrationPlatform } from "@app/hooks/api/workflowIntegrations/types";
+
+import { AddWorkflowIntegrationForm } from "./AddWorkflowIntegrationForm";
+import { IntegrationFormDetails } from "./IntegrationFormDetails";
+
+export const OrgWorkflowIntegrationTab = withPermission(
+ () => {
+ const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([
+ "addWorkflowIntegration",
+ "integrationDetails",
+ "removeIntegration"
+ ] as const);
+
+ const { currentOrg } = useOrganization();
+ const navigate = useNavigate();
+ const { data: workflowIntegrations, isLoading: isWorkflowIntegrationsLoading } =
+ useGetWorkflowIntegrations(currentOrg?.id);
+
+ const { mutateAsync: deleteSlackIntegration } = useDeleteSlackIntegration();
+
+ const handleRemoveIntegration = async () => {
+ if (!currentOrg) {
+ return;
+ }
+
+ const { platform, id } = popUp.removeIntegration.data;
+ if (platform === WorkflowIntegrationPlatform.SLACK) {
+ await deleteSlackIntegration({
+ id,
+ orgId: currentOrg?.id
+ });
+ }
+
+ handlePopUpClose("removeIntegration");
+ createNotification({
+ text: "Successfully deleted integration",
+ type: "success"
+ });
+ };
+
+ const triggerReinstall = async (platform: WorkflowIntegrationPlatform, id: string) => {
+ if (platform === WorkflowIntegrationPlatform.SLACK) {
+ try {
+ const slackReinstallUrl = await fetchSlackReinstallUrl({
+ id
+ });
+
+ if (slackReinstallUrl) {
+ window.location.href = slackReinstallUrl;
+ }
+ } catch (err) {
+ if (axios.isAxiosError(err)) {
+ createNotification({
+ text: (err.response?.data as { message: string })?.message,
+ type: "error"
+ });
+ }
+ }
+ }
+ };
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex justify-between">
+ <p className="text-xl font-semibold text-mineshaft-100">Workflow Integrations</p>
+ <OrgPermissionCan I={OrgPermissionActions.Create} an={OrgPermissionSubjects.Settings}>
+ {(isAllowed) => (
+ <Button
+ onClick={() => {
+ handlePopUpOpen("addWorkflowIntegration");
+ }}
+ isDisabled={!isAllowed}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ >
+ Add
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="mb-4 text-gray-400">
+ Connect Infisical to other platforms for notification and workflow integrations.
+ </p>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Td>Provider</Td>
+ <Td>Alias</Td>
+ </Tr>
+ </THead>
+ <TBody>
+ {isWorkflowIntegrationsLoading && (
+ <TableSkeleton columns={2} innerKey="integrations-loading" />
+ )}
+ {!isWorkflowIntegrationsLoading &&
+ workflowIntegrations &&
+ workflowIntegrations.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No workflow integrations found" icon={faGear} />
+ </Td>
+ </Tr>
+ )}
+ {workflowIntegrations?.map((workflowIntegration) => (
+ <Tr key={workflowIntegration.id}>
+ <Td className="flex max-w-xs items-center overflow-hidden text-ellipsis hover:overflow-auto hover:break-all">
+ <FontAwesomeIcon icon={faSlack} />
+ <div className="ml-2">{workflowIntegration.integration.toUpperCase()}</div>
+ </Td>
+ <Td>{workflowIntegration.slug}</Td>
+ <Td>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="rounded-lg">
+ <div className="flex justify-end hover:text-primary-400 data-[state=open]:text-primary-400">
+ <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+
+ handlePopUpOpen("integrationDetails", {
+ id: workflowIntegration.id,
+ platform: workflowIntegration.integration
+ });
+ }}
+ >
+ More details
+ </DropdownMenuItem>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Create}
+ an={OrgPermissionSubjects.Settings}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ disabled={!isAllowed}
+ className={twMerge(
+ !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+
+ triggerReinstall(
+ workflowIntegration.integration,
+ workflowIntegration.id
+ );
+ }}
+ >
+ Reinstall
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ an={OrgPermissionSubjects.Settings}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ disabled={!isAllowed}
+ className={twMerge(
+ !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+
+ handlePopUpOpen("removeIntegration", {
+ id: workflowIntegration.id,
+ slug: workflowIntegration.slug,
+ platform: workflowIntegration.integration
+ });
+ }}
+ >
+ Delete
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </Td>
+ </Tr>
+ ))}
+ </TBody>
+ </Table>
+ </TableContainer>
+ <AddWorkflowIntegrationForm
+ isOpen={popUp.addWorkflowIntegration.isOpen}
+ onToggle={(state) => handlePopUpToggle("addWorkflowIntegration", state)}
+ />
+ <IntegrationFormDetails
+ isOpen={popUp.integrationDetails?.isOpen}
+ workflowPlatform={popUp.integrationDetails?.data?.platform}
+ id={popUp.integrationDetails?.data?.id}
+ onOpenChange={(state) => handlePopUpToggle("integrationDetails", state)}
+ />
+ <DeleteActionModal
+ isOpen={popUp.removeIntegration.isOpen}
+ title={`Are you sure want to remove ${popUp?.removeIntegration?.data?.slug}?`}
+ onChange={(isOpen) => handlePopUpToggle("removeIntegration", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={handleRemoveIntegration}
+ />
+ </div>
+ );
+ },
+ { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Settings }
+);
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/SlackIntegrationForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/SlackIntegrationForm.tsx
new file mode 100644
index 0000000000..d26b9c8633
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/OrgWorkflowIntegrationTab/SlackIntegrationForm.tsx
@@ -0,0 +1,139 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import axios from "axios";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, Input } from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { useToggle } from "@app/hooks";
+import {
+ fetchSlackInstallUrl,
+ useGetSlackIntegrationById,
+ useUpdateSlackIntegration
+} from "@app/hooks/api";
+import { slugSchema } from "@app/lib/schemas";
+import { useNavigate } from "@tanstack/react-router";
+
+type Props = {
+ id?: string;
+ onClose: () => void;
+};
+
+const slackFormSchema = z.object({
+ slug: slugSchema({ min: 1, field: "Alias" }),
+ description: z.string().optional()
+});
+
+type TSlackFormData = z.infer<typeof slackFormSchema>;
+
+export const SlackIntegrationForm = ({ id, onClose }: Props) => {
+ const {
+ control,
+ handleSubmit,
+ setValue,
+ formState: { isSubmitting, isDirty }
+ } = useForm<TSlackFormData>({
+ resolver: zodResolver(slackFormSchema)
+ });
+
+ const navigate = useNavigate();
+ const [isConnectLoading, setIsConnectLoading] = useToggle(false);
+ const { currentOrg } = useOrganization();
+ const { data: slackIntegration } = useGetSlackIntegrationById(id);
+ const { mutateAsync: updateSlackIntegration } = useUpdateSlackIntegration();
+
+ useEffect(() => {
+ if (slackIntegration) {
+ setValue("slug", slackIntegration.slug);
+ setValue("description", slackIntegration.description ?? "");
+ }
+ }, [slackIntegration]);
+
+ const triggerSlackInstall = async (slug: string, description?: string) => {
+ setIsConnectLoading.on();
+ try {
+ const slackInstallUrl = await fetchSlackInstallUrl({
+ slug,
+ description
+ });
+ // TODO(rbr): check this
+ if (slackInstallUrl) {
+ navigate({ to: slackInstallUrl });
+ }
+ } catch (err) {
+ if (axios.isAxiosError(err)) {
+ createNotification({
+ text: (err.response?.data as { message: string })?.message,
+ type: "error"
+ });
+ }
+ } finally {
+ setIsConnectLoading.off();
+ }
+ };
+
+ const handleSlackFormSubmit = async ({ slug, description }: TSlackFormData) => {
+ if (id && slackIntegration) {
+ if (!currentOrg) {
+ return;
+ }
+
+ await updateSlackIntegration({
+ id,
+ orgId: currentOrg?.id,
+ slug,
+ description
+ });
+
+ onClose();
+ createNotification({
+ text: "Successfully updated Slack integration",
+ type: "success"
+ });
+ } else {
+ await triggerSlackInstall(slug, description);
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(handleSlackFormSubmit)} autoComplete="off">
+ <Controller
+ control={control}
+ name="slug"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Alias" isRequired errorText={error?.message} isError={Boolean(error)}>
+ <Input placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="description"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Description" errorText={error?.message} isError={Boolean(error)}>
+ <Input placeholder="" {...field} />
+ </FormControl>
+ )}
+ />
+ {slackIntegration && (
+ <FormControl label="Connected Slack workspace">
+ <Input value={slackIntegration?.teamName} isReadOnly className="bg-white/[0.07]" />
+ </FormControl>
+ )}
+ <div className="mt-6 flex items-center space-x-4">
+ <Button
+ type="submit"
+ isLoading={isSubmitting || isConnectLoading}
+ isDisabled={!isDirty || isConnectLoading || isSubmitting}
+ >
+ {slackIntegration ? "Save" : "Connect Slack"}
+ </Button>
+ <Button variant="outline_bg" onClick={onClose}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/ProjectTemplatesTab.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/ProjectTemplatesTab.tsx
new file mode 100644
index 0000000000..016c1439c5
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/ProjectTemplatesTab.tsx
@@ -0,0 +1,9 @@
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { withPermission } from "@app/hoc";
+
+import { ProjectTemplatesSection } from "./components";
+
+export const ProjectTemplatesTab = withPermission(() => <ProjectTemplatesSection />, {
+ action: OrgPermissionActions.Read,
+ subject: OrgPermissionSubjects.ProjectTemplates
+});
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/DeleteProjectTemplateModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/DeleteProjectTemplateModal.tsx
new file mode 100644
index 0000000000..09537ce575
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/DeleteProjectTemplateModal.tsx
@@ -0,0 +1,49 @@
+import { createNotification } from "@app/components/notifications";
+import { DeleteActionModal } from "@app/components/v2";
+import { TProjectTemplate, useDeleteProjectTemplate } from "@app/hooks/api/projectTemplates";
+
+type Props = {
+ template?: TProjectTemplate;
+ isOpen: boolean;
+ onOpenChange: (isOpen: boolean) => void;
+};
+
+export const DeleteProjectTemplateModal = ({ isOpen, onOpenChange, template }: Props) => {
+ const deleteTemplate = useDeleteProjectTemplate();
+
+ if (!template) return null;
+
+ const { id: templateId, name } = template;
+
+ const handleDeleteProjectTemplate = async () => {
+ try {
+ await deleteTemplate.mutateAsync({
+ templateId
+ });
+
+ createNotification({
+ text: "Successfully removed project template",
+ type: "success"
+ });
+
+ onOpenChange(false);
+ } catch (err) {
+ console.error(err);
+
+ createNotification({
+ text: "Failed remove project template",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <DeleteActionModal
+ isOpen={isOpen}
+ onChange={onOpenChange}
+ title={`Are you sure want to delete ${name}?`}
+ deleteKey="confirm"
+ onDeleteApproved={handleDeleteProjectTemplate}
+ />
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/EditProjectTemplateSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/EditProjectTemplateSection.tsx
new file mode 100644
index 0000000000..0923a9bb45
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/EditProjectTemplateSection.tsx
@@ -0,0 +1,55 @@
+import { faChevronLeft } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { Button, EmptyState, Spinner } from "@app/components/v2";
+import {
+ InfisicalProjectTemplate,
+ TProjectTemplate,
+ useGetProjectTemplateById
+} from "@app/hooks/api/projectTemplates";
+
+import { EditProjectTemplate } from "./components";
+
+type Props = {
+ template: TProjectTemplate;
+ onBack: () => void;
+};
+
+export const EditProjectTemplateSection = ({ template, onBack }: Props) => {
+ const isInfisicalTemplate = Object.values(InfisicalProjectTemplate).includes(
+ template.name as InfisicalProjectTemplate
+ );
+
+ const { data: projectTemplate, isLoading } = useGetProjectTemplateById(template.id, {
+ initialData: template,
+ enabled: !isInfisicalTemplate
+ });
+
+ return (
+ <div>
+ <Button
+ variant="link"
+ type="submit"
+ leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
+ onClick={onBack}
+ className="mb-4"
+ >
+ Back to Templates
+ </Button>
+ {/* eslint-disable-next-line no-nested-ternary */}
+ {isLoading ? (
+ <div className="flex h-[60vh] w-full items-center justify-center p-24">
+ <Spinner />
+ </div>
+ ) : projectTemplate ? (
+ <EditProjectTemplate
+ isInfisicalTemplate={isInfisicalTemplate}
+ projectTemplate={projectTemplate}
+ onBack={onBack}
+ />
+ ) : (
+ <EmptyState title="Error: Unable to find project template." className="py-12" />
+ )}
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/EditProjectTemplate.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/EditProjectTemplate.tsx
new file mode 100644
index 0000000000..98a6759401
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/EditProjectTemplate.tsx
@@ -0,0 +1,119 @@
+import { faPencil, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, DeleteActionModal } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { usePopUp } from "@app/hooks";
+import { TProjectTemplate, useDeleteProjectTemplate } from "@app/hooks/api/projectTemplates";
+
+import { ProjectTemplateDetailsModal } from "../../ProjectTemplateDetailsModal";
+import { ProjectTemplateEnvironmentsForm } from "./ProjectTemplateEnvironmentsForm";
+import { ProjectTemplateRolesSection } from "./ProjectTemplateRolesSection";
+
+type Props = {
+ projectTemplate: TProjectTemplate;
+ onBack: () => void;
+ isInfisicalTemplate: boolean;
+};
+
+export const EditProjectTemplate = ({ isInfisicalTemplate, projectTemplate, onBack }: Props) => {
+ const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
+ "removeTemplate",
+ "editDetails"
+ ] as const);
+
+ const { id: templateId, name, description } = projectTemplate;
+
+ const deleteProjectTemplate = useDeleteProjectTemplate();
+
+ const handleRemoveTemplate = async () => {
+ try {
+ await deleteProjectTemplate.mutateAsync({
+ templateId
+ });
+ createNotification({
+ text: "Successfully removed project template",
+ type: "success"
+ });
+ onBack();
+ } catch (error) {
+ console.error(error);
+ createNotification({
+ text: "Failed to remove project template",
+ type: "error"
+ });
+ }
+ handlePopUpClose("removeTemplate");
+ };
+
+ return (
+ <>
+ <div className="mb-4 flex items-start justify-between border-b border-bunker-400 pb-4">
+ <div className="flex-col">
+ <h3 className="text-xl font-semibold">{name}</h3>
+ <h2 className="text-sm text-mineshaft-400">{description || "Project Template"}</h2>
+ </div>
+ {!isInfisicalTemplate && (
+ <div className="flex gap-2">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <Button
+ isDisabled={!isAllowed}
+ leftIcon={<FontAwesomeIcon icon={faPencil} />}
+ size="xs"
+ colorSchema="secondary"
+ onClick={() => handlePopUpOpen("editDetails")}
+ >
+ Edit Details
+ </Button>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <Button
+ isDisabled={!isAllowed}
+ onClick={() => {
+ handlePopUpOpen("removeTemplate");
+ }}
+ leftIcon={<FontAwesomeIcon icon={faTrash} />}
+ size="xs"
+ colorSchema="danger"
+ >
+ Delete Template
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ )}
+ </div>
+ <ProjectTemplateEnvironmentsForm
+ isInfisicalTemplate={isInfisicalTemplate}
+ projectTemplate={projectTemplate}
+ />
+ <ProjectTemplateRolesSection
+ isInfisicalTemplate={isInfisicalTemplate}
+ projectTemplate={projectTemplate}
+ />
+ <ProjectTemplateDetailsModal
+ isOpen={popUp.editDetails.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("editDetails", isOpen)}
+ projectTemplate={projectTemplate}
+ />
+ <DeleteActionModal
+ isOpen={popUp.removeTemplate.isOpen}
+ title={`Are you sure want to delete ${projectTemplate.name}?`}
+ deleteKey="confirm"
+ onChange={(isOpen) => handlePopUpToggle("removeTemplate", isOpen)}
+ onDeleteApproved={handleRemoveTemplate}
+ />
+ </>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEditRoleForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEditRoleForm.tsx
new file mode 100644
index 0000000000..7cb6d5d09e
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEditRoleForm.tsx
@@ -0,0 +1,211 @@
+import { Controller, FormProvider, useForm } from "react-hook-form";
+import { faChevronLeft, faPlus, faSave } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { twMerge } from "tailwind-merge";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { Button, FormControl, Input, Modal, ModalContent, ModalTrigger } from "@app/components/v2";
+import { ProjectPermissionSub } from "@app/context";
+import { isCustomProjectRole } from "@app/helpers/roles";
+import { usePopUp } from "@app/hooks";
+import { TProjectTemplate, useUpdateProjectTemplate } from "@app/hooks/api/projectTemplates";
+import { slugSchema } from "@app/lib/schemas";
+import { GeneralPermissionPolicies } from "@app/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionPolicies";
+import { NewPermissionRule } from "@app/views/Project/RolePage/components/RolePermissionsSection/components/NewPermissionRule";
+import { PermissionEmptyState } from "@app/views/Project/RolePage/components/RolePermissionsSection/PermissionEmptyState";
+import {
+ formRolePermission2API,
+ PROJECT_PERMISSION_OBJECT,
+ projectRoleFormSchema,
+ rolePermission2Form
+} from "@app/views/Project/RolePage/components/RolePermissionsSection/ProjectRoleModifySection.utils";
+import { renderConditionalComponents } from "@app/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection";
+
+type Props = {
+ projectTemplate: TProjectTemplate;
+ role?: TProjectTemplate["roles"][number];
+ onGoBack: () => void;
+ isDisabled?: boolean;
+};
+
+const formSchema = z.object({
+ slug: slugSchema(),
+ name: z.string().trim().min(1),
+ permissions: projectRoleFormSchema.shape.permissions
+});
+
+type TFormSchema = z.infer<typeof formSchema>;
+
+export const ProjectTemplateEditRoleForm = ({
+ onGoBack,
+ projectTemplate,
+ role,
+ isDisabled
+}: Props) => {
+ const { popUp, handlePopUpToggle } = usePopUp(["createPolicy"] as const);
+
+ const formMethods = useForm<TFormSchema>({
+ values: role ? { ...role, permissions: rolePermission2Form(role.permissions) } : undefined,
+ resolver: zodResolver(formSchema)
+ });
+
+ const {
+ handleSubmit,
+ control,
+ formState: { isDirty, isSubmitting }
+ } = formMethods;
+
+ const updateProjectTemplate = useUpdateProjectTemplate();
+
+ const onSubmit = async (form: TFormSchema) => {
+ try {
+ await updateProjectTemplate.mutateAsync({
+ templateId: projectTemplate.id,
+ roles: [
+ ...projectTemplate.roles.filter(
+ (r) => r.slug !== role?.slug && isCustomProjectRole(r.slug) // filter out default roles as well
+ ),
+ {
+ ...form,
+ permissions: formRolePermission2API(form.permissions)
+ }
+ ]
+ });
+ onGoBack();
+ createNotification({
+ text: "Template roles successfully updated",
+ type: "success"
+ });
+ } catch (e: any) {
+ console.error(e);
+ createNotification({
+ text: "Failed to update template roles",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form
+ onSubmit={handleSubmit(onSubmit)}
+ className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"
+ >
+ <FormProvider {...formMethods}>
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-2">
+ <Button
+ leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
+ className="text-base font-semibold text-mineshaft-200"
+ variant="link"
+ onClick={onGoBack}
+ >
+ {isDisabled ? "Back" : "Cancel"}
+ </Button>
+ {!isDisabled && (
+ <div className="flex items-center space-x-4">
+ {isDirty && (
+ <Button
+ className="mr-4 text-mineshaft-300"
+ variant="link"
+ isDisabled={isSubmitting}
+ isLoading={isSubmitting}
+ onClick={onGoBack}
+ >
+ Discard
+ </Button>
+ )}
+ <div className="flex items-center">
+ <Button
+ variant="outline_bg"
+ type="submit"
+ className={twMerge("h-10 rounded-r-none", isDirty && "bg-primary text-black")}
+ isDisabled={isSubmitting || !isDirty || isDisabled}
+ isLoading={isSubmitting}
+ leftIcon={<FontAwesomeIcon icon={faSave} />}
+ >
+ Save
+ </Button>
+ <Modal
+ isOpen={popUp.createPolicy.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("createPolicy", isOpen)}
+ >
+ <ModalTrigger asChild>
+ <Button
+ className="h-10 rounded-l-none"
+ variant="outline_bg"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ isDisabled={isDisabled}
+ >
+ New Policy
+ </Button>
+ </ModalTrigger>
+ <ModalContent
+ title="New Policy"
+ subTitle="Policies grant additional permissions."
+ >
+ <NewPermissionRule onClose={() => handlePopUpToggle("createPolicy")} />
+ </ModalContent>
+ </Modal>
+ </div>
+ </div>
+ )}
+ </div>
+ <div className="mt-2 border-b border-gray-800 p-4 pt-2 first:rounded-t-md last:rounded-b-md">
+ {isDisabled ? (
+ <div className="flex flex-col">
+ <span className="text-lg font-semibold">{role?.name}</span>
+ <span className="text-mineshaft-400">{role?.slug}</span>
+ </div>
+ ) : (
+ <div className="flex w-full gap-2">
+ <Controller
+ control={control}
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ label="Name"
+ className="mb-0 flex-1"
+ >
+ <Input {...field} autoFocus placeholder="Role name..." />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="slug"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ label="Slug"
+ className="mb-0 flex-1"
+ >
+ <Input {...field} placeholder="Role slug..." />
+ </FormControl>
+ )}
+ />
+ </div>
+ )}
+ </div>
+ <div className="p-4">
+ <div className="mb-2 text-lg">Policies</div>
+ <PermissionEmptyState />
+ {(Object.keys(PROJECT_PERMISSION_OBJECT) as ProjectPermissionSub[]).map((subject) => (
+ <GeneralPermissionPolicies
+ subject={subject}
+ actions={PROJECT_PERMISSION_OBJECT[subject].actions}
+ title={PROJECT_PERMISSION_OBJECT[subject].title}
+ key={`project-permission-${subject}`}
+ isDisabled={isDisabled}
+ >
+ {renderConditionalComponents(subject, isDisabled)}
+ </GeneralPermissionPolicies>
+ ))}
+ </div>
+ </FormProvider>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx
new file mode 100644
index 0000000000..b72d12c73e
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx
@@ -0,0 +1,281 @@
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faArrowDown, faArrowUp, faPlus, faSave, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ FormControl,
+ IconButton,
+ Input,
+ Table,
+ TableContainer,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { TProjectTemplate, useUpdateProjectTemplate } from "@app/hooks/api/projectTemplates";
+import { slugSchema } from "@app/lib/schemas";
+
+type Props = {
+ projectTemplate: TProjectTemplate;
+ isInfisicalTemplate: boolean;
+};
+
+const formSchema = z.object({
+ environments: z
+ .object({
+ name: z.string().trim().min(1),
+ slug: slugSchema({ min: 1, max: 32 })
+ })
+ .array()
+});
+
+type TFormSchema = z.infer<typeof formSchema>;
+
+export const ProjectTemplateEnvironmentsForm = ({
+ projectTemplate,
+ isInfisicalTemplate
+}: Props) => {
+ const {
+ control,
+ handleSubmit,
+ formState: { isDirty, errors },
+ reset
+ } = useForm<TFormSchema>({
+ defaultValues: {
+ environments: projectTemplate.environments
+ },
+ resolver: zodResolver(formSchema)
+ });
+
+ const {
+ fields: environments,
+ move,
+ remove,
+ append
+ } = useFieldArray({ control, name: "environments" });
+
+ const updateProjectTemplate = useUpdateProjectTemplate();
+
+ const onFormSubmit = async (form: TFormSchema) => {
+ try {
+ const { environments: updatedEnvs } = await updateProjectTemplate.mutateAsync({
+ environments: form.environments.map((env, index) => ({
+ ...env,
+ position: index + 1
+ })),
+ templateId: projectTemplate.id
+ });
+
+ reset({ environments: updatedEnvs });
+
+ createNotification({
+ text: "Project template updated successfully",
+ type: "success"
+ });
+ } catch (e: any) {
+ console.error(e);
+ createNotification({
+ text: e.message ?? "Failed to update project template",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form
+ onSubmit={handleSubmit(onFormSubmit)}
+ className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"
+ >
+ <div className="mb-4 flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <div>
+ <h2 className="text-lg font-semibold">Project Environments</h2>
+ {!isInfisicalTemplate && (
+ <p className="text-sm text-mineshaft-400">
+ Add, rename, remove and reorder environments for this project template
+ </p>
+ )}
+ </div>
+ {!isInfisicalTemplate && (
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <Button
+ type="submit"
+ colorSchema="primary"
+ className="ml-auto w-40"
+ variant={isDirty ? "solid" : "outline_bg"}
+ leftIcon={<FontAwesomeIcon icon={faSave} />}
+ isDisabled={!isAllowed || !isDirty}
+ >
+ {isDirty ? "Save" : "No"} Changes
+ </Button>
+ )}
+ </OrgPermissionCan>
+ )}
+ </div>
+ {errors.environments && (
+ <span className="my-4 text-sm text-red">{errors.environments.message}</span>
+ )}
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Friendly Name</Th>
+ <Th>Slug</Th>
+ {!isInfisicalTemplate && (
+ <Th>
+ <div className="flex w-full justify-end normal-case">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <Button
+ onClick={() => append({ name: "", slug: "" })}
+ colorSchema="secondary"
+ className="ml-auto"
+ variant="solid"
+ size="xs"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ isDisabled={!isAllowed}
+ >
+ Add Environment
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ </Th>
+ )}
+ </Tr>
+ </THead>
+ <TBody>
+ {environments.map(({ id, name, slug }, pos) => (
+ <Tr key={id}>
+ <Td>
+ {isInfisicalTemplate ? (
+ name
+ ) : (
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <Controller
+ control={control}
+ name={`environments.${pos}.name`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0 flex-grow"
+ >
+ <Input isDisabled={!isAllowed} {...field} placeholder="Name..." />
+ </FormControl>
+ )}
+ />
+ )}
+ </OrgPermissionCan>
+ )}
+ </Td>
+ <Td>
+ {isInfisicalTemplate ? (
+ slug
+ ) : (
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <Controller
+ control={control}
+ name={`environments.${pos}.slug`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0 flex-grow"
+ >
+ <Input isDisabled={!isAllowed} {...field} placeholder="Slug..." />
+ </FormControl>
+ )}
+ />
+ )}
+ </OrgPermissionCan>
+ )}
+ </Td>
+ {!isInfisicalTemplate && (
+ <Td className="flex items-center justify-end">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <IconButton
+ className={`mr-3 py-2 ${
+ pos === environments.length - 1 ? "pointer-events-none opacity-50" : ""
+ }`}
+ onClick={() => move(pos, pos + 1)}
+ colorSchema="primary"
+ variant="plain"
+ ariaLabel="Increase position"
+ isDisabled={pos === environments.length - 1 || !isAllowed}
+ >
+ <FontAwesomeIcon icon={faArrowDown} />
+ </IconButton>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <IconButton
+ className={`mr-3 py-2 ${
+ pos === 0 ? "pointer-events-none opacity-50" : ""
+ }`}
+ onClick={() => move(pos, pos - 1)}
+ colorSchema="primary"
+ variant="plain"
+ ariaLabel="Decrease position"
+ isDisabled={pos === 0 || !isAllowed}
+ >
+ <FontAwesomeIcon icon={faArrowUp} />
+ </IconButton>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <IconButton
+ onClick={() => remove(pos)}
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="Remove environment"
+ isDisabled={!isAllowed || environments.length === 1}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ )}
+ </OrgPermissionCan>
+ </Td>
+ )}
+ </Tr>
+ ))}
+ </TBody>
+ </Table>
+ </TableContainer>
+ </form>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx
new file mode 100644
index 0000000000..f67891ecc7
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx
@@ -0,0 +1,223 @@
+import { faPlus, faTrash, faUnlock } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { AnimatePresence, motion } from "framer-motion";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ DeleteActionModal,
+ EmptyState,
+ IconButton,
+ Table,
+ TableContainer,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrgPermission } from "@app/context";
+import { isCustomProjectRole } from "@app/helpers/roles";
+import { usePopUp } from "@app/hooks";
+import { TProjectTemplate, useUpdateProjectTemplate } from "@app/hooks/api/projectTemplates";
+import { TProjectRole } from "@app/hooks/api/roles/types";
+
+import { ProjectTemplateEditRoleForm } from "./ProjectTemplateEditRoleForm";
+
+type Props = {
+ projectTemplate: TProjectTemplate;
+ isInfisicalTemplate: boolean;
+};
+
+export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTemplate }: Props) => {
+ const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([
+ "removeRole",
+ "editRole"
+ ] as const);
+
+ const { permission } = useOrgPermission();
+
+ const { roles } = projectTemplate;
+
+ const updateProjectTemplate = useUpdateProjectTemplate();
+
+ const handleRemoveRole = async (slug: string) => {
+ try {
+ await updateProjectTemplate.mutateAsync({
+ templateId: projectTemplate.id,
+ roles: projectTemplate.roles.filter(
+ (role) => role.slug !== slug && isCustomProjectRole(role.slug) // filter out default roles as well
+ )
+ });
+
+ createNotification({
+ text: "Successfully removed role from template",
+ type: "success"
+ });
+ handlePopUpClose("removeRole");
+ } catch (e) {
+ console.error(e);
+ createNotification({
+ text: "Error removing role from template",
+ type: "error"
+ });
+ }
+ };
+
+ const editRole = popUp?.editRole?.data as TProjectRole;
+ const roleToDelete = popUp?.removeRole?.data as TProjectRole;
+
+ return (
+ <div className="relative">
+ <AnimatePresence>
+ {popUp?.editRole.isOpen ? (
+ <motion.div
+ key="edit-role"
+ transition={{ duration: 0.3 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: 30 }}
+ className="absolute min-h-[10rem] w-full"
+ >
+ <ProjectTemplateEditRoleForm
+ onGoBack={() => handlePopUpClose("editRole")}
+ projectTemplate={projectTemplate}
+ role={editRole}
+ isDisabled={
+ permission.cannot(
+ OrgPermissionActions.Edit,
+ OrgPermissionSubjects.ProjectTemplates
+ ) ||
+ (editRole && !isCustomProjectRole(editRole.slug))
+ }
+ />
+ <div className="h-4 w-full" />
+ </motion.div>
+ ) : (
+ <motion.div
+ key="role-list"
+ transition={{ duration: 0.3 }}
+ initial={{ opacity: 0, translateX: 0 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ className="absolute w-full"
+ >
+ <div className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
+ <div>
+ <h2 className="text-lg font-semibold">Project Roles</h2>
+ <p className="text-sm text-mineshaft-400">
+ {isInfisicalTemplate
+ ? "Click a role to view the associated permissions"
+ : "Add, edit and remove roles for this project template"}
+ </p>
+ </div>
+ {!isInfisicalTemplate && (
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <Button
+ onClick={() => {
+ handlePopUpOpen("editRole");
+ }}
+ colorSchema="primary"
+ className="ml-auto"
+ variant="outline_bg"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ isDisabled={!isAllowed}
+ >
+ Add Role
+ </Button>
+ )}
+ </OrgPermissionCan>
+ )}
+ </div>
+ <div className="py-4">
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Name</Th>
+ <Th>Slug</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {roles.length ? (
+ roles.map((role) => {
+ return (
+ <Tr
+ key={role.slug}
+ className="group w-full cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"
+ role="button"
+ tabIndex={0}
+ onKeyDown={(evt) => {
+ if (evt.key === "Enter") {
+ handlePopUpOpen("editRole", role);
+ }
+ }}
+ onClick={() => handlePopUpOpen("editRole", role)}
+ >
+ <Td>{role.name}</Td>
+ <Td>{role.slug}</Td>
+ <Td>
+ {isCustomProjectRole(role.slug) && (
+ <div className="flex space-x-2 opacity-0 transition-opacity duration-300 group-hover:opacity-100">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ renderTooltip
+ allowedLabel="Remove Role"
+ >
+ {(isAllowed) => (
+ <IconButton
+ colorSchema="danger"
+ ariaLabel="delete-icon"
+ variant="plain"
+ className="group relative"
+ isDisabled={!isAllowed}
+ onClick={(e) => {
+ e.stopPropagation();
+ e.preventDefault();
+ handlePopUpOpen("removeRole", role);
+ }}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ )}
+ </OrgPermissionCan>
+ </div>
+ )}
+ </Td>
+ </Tr>
+ );
+ })
+ ) : (
+ <Tr>
+ <Td colSpan={2}>
+ <EmptyState title="No roles assigned to template" icon={faUnlock} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ </div>
+ <DeleteActionModal
+ isOpen={popUp.removeRole.isOpen}
+ deleteKey="remove"
+ title={`Are you sure you want to remove the role ${roleToDelete?.slug}?`}
+ onChange={(isOpen) => handlePopUpToggle("removeRole", isOpen)}
+ onDeleteApproved={() => handleRemoveRole(roleToDelete?.slug)}
+ />
+ </div>
+ <div className="h-4 w-full" />
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/index.tsx
new file mode 100644
index 0000000000..5c3e6e57f7
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/index.tsx
@@ -0,0 +1 @@
+export * from "./EditProjectTemplate";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/index.tsx
new file mode 100644
index 0000000000..cd6925f94c
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/EditProjectTemplateSection/index.tsx
@@ -0,0 +1 @@
+export * from "./EditProjectTemplateSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/ProjectTemplateDetailsModal.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/ProjectTemplateDetailsModal.tsx
new file mode 100644
index 0000000000..e601e0319f
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/ProjectTemplateDetailsModal.tsx
@@ -0,0 +1,143 @@
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FormControl,
+ Input,
+ Modal,
+ ModalClose,
+ ModalContent,
+ TextArea
+} from "@app/components/v2";
+import {
+ TProjectTemplate,
+ useCreateProjectTemplate,
+ useUpdateProjectTemplate
+} from "@app/hooks/api/projectTemplates";
+import { slugSchema } from "@app/lib/schemas";
+
+const formSchema = z.object({
+ name: slugSchema({ min: 1, max: 32, field: "Name" }),
+ description: z.string().max(500).optional()
+});
+
+export type FormData = z.infer<typeof formSchema>;
+
+type Props = {
+ isOpen: boolean;
+ onOpenChange: (isOpen: boolean) => void;
+ onComplete?: (template: TProjectTemplate) => void;
+ projectTemplate?: TProjectTemplate;
+};
+
+type FormProps = {
+ projectTemplate?: TProjectTemplate;
+ onComplete: (template: TProjectTemplate) => void;
+};
+
+const ProjectTemplateForm = ({ onComplete, projectTemplate }: FormProps) => {
+ const createProjectTemplate = useCreateProjectTemplate();
+ const updateProjectTemplate = useUpdateProjectTemplate();
+
+ const {
+ handleSubmit,
+ register,
+ formState: { isSubmitting, errors }
+ } = useForm<FormData>({
+ resolver: zodResolver(formSchema),
+ defaultValues: {
+ name: projectTemplate?.name,
+ description: projectTemplate?.description
+ }
+ });
+
+ const onFormSubmit = async (data: FormData) => {
+ const mutation = projectTemplate
+ ? updateProjectTemplate.mutateAsync({ templateId: projectTemplate.id, ...data })
+ : createProjectTemplate.mutateAsync(data);
+ try {
+ const template = await mutation;
+ createNotification({
+ text: `Successfully ${
+ projectTemplate ? "updated template details" : "created project template"
+ }`,
+ type: "success"
+ });
+
+ onComplete(template);
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: `Failed to ${
+ projectTemplate ? "update template details" : "create project template"
+ }`,
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <FormControl
+ helperText="Name must be slug-friendly"
+ errorText={errors.name?.message}
+ isError={Boolean(errors.name?.message)}
+ label="Name"
+ >
+ <Input autoFocus placeholder="my-project-template" {...register("name")} />
+ </FormControl>
+ <FormControl
+ label="Description (optional)"
+ errorText={errors.description?.message}
+ isError={Boolean(errors.description?.message)}
+ >
+ <TextArea
+ className="max-h-[20rem] min-h-[10rem] min-w-full max-w-full"
+ {...register("description")}
+ />
+ </FormControl>
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {projectTemplate ? "Update" : "Add"} Template
+ </Button>
+ <ModalClose asChild>
+ <Button colorSchema="secondary" variant="plain">
+ Cancel
+ </Button>
+ </ModalClose>
+ </div>
+ </form>
+ );
+};
+
+export const ProjectTemplateDetailsModal = ({
+ isOpen,
+ onOpenChange,
+ projectTemplate,
+ onComplete
+}: Props) => {
+ return (
+ <Modal isOpen={isOpen} onOpenChange={onOpenChange}>
+ <ModalContent
+ title={projectTemplate ? "Edit Project Template Details" : "Create Project Template"}
+ >
+ <ProjectTemplateForm
+ projectTemplate={projectTemplate}
+ onComplete={(template) => {
+ if (onComplete) onComplete(template);
+ onOpenChange(false);
+ }}
+ />
+ </ModalContent>
+ </Modal>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/ProjectTemplatesSection.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/ProjectTemplatesSection.tsx
new file mode 100644
index 0000000000..151ee9f5df
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/ProjectTemplatesSection.tsx
@@ -0,0 +1,116 @@
+import { useState } from "react";
+import { faArrowUpRightFromSquare, faBookOpen, faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { AnimatePresence, motion } from "framer-motion";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, UpgradePlanModal } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
+import { TProjectTemplate } from "@app/hooks/api/projectTemplates";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { EditProjectTemplateSection } from "./EditProjectTemplateSection";
+import { ProjectTemplateDetailsModal } from "./ProjectTemplateDetailsModal";
+import { ProjectTemplatesTable } from "./ProjectTemplatesTable";
+
+export const ProjectTemplatesSection = () => {
+ const { subscription } = useSubscription();
+ const [editTemplate, setEditTemplate] = useState<TProjectTemplate | null>(null);
+
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([
+ "upgradePlan",
+ "addTemplate"
+ ] as const);
+
+ return (
+ <div className="relative">
+ <AnimatePresence>
+ {editTemplate ? (
+ <motion.div
+ key="edit-project-template"
+ transition={{ duration: 0.3 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: 30 }}
+ className="absolute min-h-[10rem] w-full"
+ >
+ <EditProjectTemplateSection
+ template={editTemplate}
+ onBack={() => setEditTemplate(null)}
+ />
+ </motion.div>
+ ) : (
+ <motion.div
+ key="project-templates-list"
+ transition={{ duration: 0.3 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: 30 }}
+ className="absolute min-h-[10rem] w-full"
+ >
+ <div>
+ <p className="mb-6 text-bunker-300">
+ Create and configure templates with predefined roles and environments to streamline
+ project setup
+ </p>
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="mb-4 flex items-start">
+ <p className="text-xl font-semibold text-mineshaft-100">Project Templates</p>
+ <a
+ target="_blank"
+ rel="noopener noreferrer"
+ href="https://infisical.com/docs/documentation/platform/project-templates"
+ >
+ <div className="ml-2 mt-[0.32rem] inline-block rounded-md bg-yellow/20 px-1.5 text-sm text-yellow opacity-80 hover:opacity-100">
+ <FontAwesomeIcon icon={faBookOpen} className="mr-1.5" />
+ <span>Docs</span>
+ <FontAwesomeIcon
+ icon={faArrowUpRightFromSquare}
+ className="mb-[0.07rem] ml-1.5 text-[10px]"
+ />
+ </div>
+ </a>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Create}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <Button
+ colorSchema="secondary"
+ type="submit"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ onClick={() => {
+ if (!subscription?.projectTemplates) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ handlePopUpOpen("addTemplate");
+ }}
+ isDisabled={!isAllowed}
+ className="ml-auto"
+ >
+ Add Template
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <ProjectTemplatesTable onEdit={setEditTemplate} />
+ <ProjectTemplateDetailsModal
+ onComplete={(template) => setEditTemplate(template)}
+ isOpen={popUp.addTemplate.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("addTemplate", isOpen)}
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text="You can create project templates if you switch to Infisical's Enterprise plan."
+ />
+ </div>
+ </div>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/ProjectTemplatesTable.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/ProjectTemplatesTable.tsx
new file mode 100644
index 0000000000..b3e2d9ba33
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/ProjectTemplatesTable.tsx
@@ -0,0 +1,191 @@
+import { useMemo, useState } from "react";
+import {
+ faCircleInfo,
+ faClone,
+ faMagnifyingGlass,
+ faTrash
+} from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ EmptyState,
+ IconButton,
+ Input,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tooltip,
+ Tr
+} from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
+import { usePopUp } from "@app/hooks";
+import { TProjectTemplate, useListProjectTemplates } from "@app/hooks/api/projectTemplates";
+
+import { DeleteProjectTemplateModal } from "./DeleteProjectTemplateModal";
+
+type Props = {
+ onEdit: (projectTemplate: TProjectTemplate) => void;
+};
+
+export const ProjectTemplatesTable = ({ onEdit }: Props) => {
+ const { subscription } = useSubscription();
+
+ const { isLoading, data: projectTemplates = [] } = useListProjectTemplates({
+ enabled: subscription?.projectTemplates
+ });
+ const [search, setSearch] = useState("");
+
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["deleteTemplate"] as const);
+
+ const filteredTemplates = useMemo(
+ () =>
+ projectTemplates?.filter((template) =>
+ template.name.toLowerCase().includes(search.toLowerCase().trim())
+ ) ?? [],
+ [search, projectTemplates]
+ );
+
+ return (
+ <div>
+ <Input
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search templates..."
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Name</Th>
+ <Th>Roles</Th>
+ <Th>Environments</Th>
+ <Th />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && (
+ <TableSkeleton
+ innerKey="project-templates-table"
+ columns={4}
+ key="project-templates"
+ />
+ )}
+ {filteredTemplates.map((template) => {
+ const { id, name, roles, environments, description } = template;
+ return (
+ <Tr
+ onClick={() => onEdit(template)}
+ className="cursor-pointer hover:bg-mineshaft-700"
+ key={id}
+ >
+ <Td>
+ {name}
+ {description && (
+ <Tooltip content={description}>
+ <FontAwesomeIcon
+ size="sm"
+ className="ml-2 text-mineshaft-400"
+ icon={faCircleInfo}
+ />
+ </Tooltip>
+ )}
+ </Td>
+ <Td className="pl-8">
+ {roles.length}
+ {roles.length > 0 && (
+ <Tooltip
+ content={
+ <ul className="ml-2 list-disc">
+ {roles.map((role) => (
+ <li key={role.name}>{role.name}</li>
+ ))}
+ </ul>
+ }
+ >
+ <FontAwesomeIcon
+ size="sm"
+ className="ml-2 text-mineshaft-400"
+ icon={faCircleInfo}
+ />
+ </Tooltip>
+ )}
+ </Td>
+ <Td className="pl-14">
+ {environments.length}
+ {environments.length > 0 && (
+ <Tooltip
+ content={
+ <ul className="ml-2 list-disc">
+ {environments
+ .sort((a, b) => (a.position > b.position ? 1 : -1))
+ .map((env) => (
+ <li key={env.slug}>{env.name}</li>
+ ))}
+ </ul>
+ }
+ >
+ <FontAwesomeIcon
+ size="sm"
+ className="ml-2 text-mineshaft-400"
+ icon={faCircleInfo}
+ />
+ </Tooltip>
+ )}
+ </Td>
+ <Td className="w-5">
+ {name !== "default" && (
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <IconButton
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("deleteTemplate", template);
+ }}
+ variant="plain"
+ colorSchema="danger"
+ ariaLabel="Delete template"
+ isDisabled={!isAllowed}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ )}
+ </OrgPermissionCan>
+ )}
+ </Td>
+ </Tr>
+ );
+ })}
+ {!isLoading && filteredTemplates?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState
+ title={
+ search.trim()
+ ? "No project templates match search"
+ : "No project templates found"
+ }
+ icon={faClone}
+ />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ <DeleteProjectTemplateModal
+ isOpen={popUp.deleteTemplate.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("deleteTemplate", isOpen)}
+ template={popUp.deleteTemplate.data}
+ />
+ </div>
+ );
+};
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/index.tsx
new file mode 100644
index 0000000000..46db36f022
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/components/index.tsx
@@ -0,0 +1 @@
+export { ProjectTemplatesSection } from "./ProjectTemplatesSection";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/index.tsx
new file mode 100644
index 0000000000..6fdd12aeed
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/ProjectTemplatesTab/index.tsx
@@ -0,0 +1 @@
+export { ProjectTemplatesTab } from "./ProjectTemplatesTab";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/index.tsx
new file mode 100644
index 0000000000..6486136420
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/-components/index.tsx
@@ -0,0 +1 @@
+export { OrgTabGroup } from "./OrgTabGroup";
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/index.tsx
new file mode 100644
index 0000000000..249e438e90
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/$organizationId/settings/index.tsx
@@ -0,0 +1,45 @@
+import { Helmet } from 'react-helmet'
+import { useTranslation } from 'react-i18next'
+import { createFileRoute } from '@tanstack/react-router'
+
+import { OrgTabGroup } from './-components'
+
+const SettingsOrg = () => {
+ const { t } = useTranslation()
+
+ return (
+ <>
+ <Helmet>
+ <title>
+ {t('common.head-title', { title: t('settings.org.title') })}
+ </title>
+ <link rel="icon" href="/infisical.ico" />
+ </Helmet>
+ <div className="flex w-full justify-center bg-bunker-800 py-6 text-white">
+ <div className="w-full max-w-4xl px-6">
+ <div className="mb-4">
+ <p className="text-3xl font-semibold text-gray-200">
+ {t('settings.org.title')}
+ </p>
+ </div>
+ <div className="flex w-full justify-center bg-bunker-800 py-6 text-white">
+ <div className="w-full max-w-4xl px-6">
+ <div className="mb-4">
+ <p className="text-3xl font-semibold text-gray-200">
+ {t('settings.org.title')}
+ </p>
+ </div>
+ <OrgTabGroup />
+ </div>
+ </div>
+ </div>
+ </div>
+ </>
+ )
+}
+
+export const Route = createFileRoute(
+ '/_authenticate/_org_details/_org-layout/organization/$organizationId/settings/',
+)({
+ component: SettingsOrg,
+})
diff --git a/frontend-v2/src/routes/_authenticate/_org_details/organization/none/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/organization/none/index.tsx
new file mode 100644
index 0000000000..08f8783355
--- /dev/null
+++ b/frontend-v2/src/routes/_authenticate/_org_details/organization/none/index.tsx
@@ -0,0 +1,36 @@
+import { useEffect } from "react";
+import { Helmet } from "react-helmet";
+import { useTranslation } from "react-i18next";
+
+import { CreateOrgModal } from "@app/components/organization/CreateOrgModal";
+import { usePopUp } from "@app/hooks";
+import { createFileRoute } from "@tanstack/react-router";
+
+const NoneOrganization = () => {
+ const { t } = useTranslation();
+
+ const { popUp, handlePopUpToggle } = usePopUp(["createOrg"] as const);
+
+ useEffect(() => {
+ handlePopUpToggle("createOrg", true);
+ }, []);
+
+ return (
+ <>
+ <Helmet>
+ <title>{t("common.head-title", { title: t("settings.org.title") })}</title>
+ <link rel="icon" href="/infisical.ico" />
+ </Helmet>
+ <div className="flex h-full w-full justify-center bg-bunker-800 text-white">
+ <CreateOrgModal
+ isOpen={popUp.createOrg.isOpen}
+ onClose={() => handlePopUpToggle("createOrg", false)}
+ />
+ </div>
+ </>
+ );
+};
+
+export const Route = createFileRoute("/_authenticate/_org_details/_org-layout/organization/none/")({
+ component: NoneOrganization
+});