diff --git a/frontend/src/components/v3/generic/Accordion/Accordion.tsx b/frontend/src/components/v3/generic/Accordion/Accordion.tsx new file mode 100644 index 000000000..dcf4d5559 --- /dev/null +++ b/frontend/src/components/v3/generic/Accordion/Accordion.tsx @@ -0,0 +1,79 @@ +/* eslint-disable react/prop-types */ + +import * as React from "react"; +import * as AccordionPrimitive from "@radix-ui/react-accordion"; +import { ChevronDownIcon } from "lucide-react"; + +import { cn } from "../../utils"; + +function UnstableAccordion({ ...props }: React.ComponentProps) { + return ( + + ); +} + +function UnstableAccordionItem({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function UnstableAccordionTrigger({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + + svg]:rotate-180", + "cursor-pointer hover:bg-foreground/5", + "data-[state=open]:bg-foreground/5", + className + )} + {...props} + > + + {children} + + + ); +} + +function UnstableAccordionContent({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + +
{children}
+
+ ); +} + +export { + UnstableAccordion, + UnstableAccordionContent, + UnstableAccordionItem, + UnstableAccordionTrigger +}; diff --git a/frontend/src/components/v3/generic/Accordion/index.ts b/frontend/src/components/v3/generic/Accordion/index.ts new file mode 100644 index 000000000..16e0243c2 --- /dev/null +++ b/frontend/src/components/v3/generic/Accordion/index.ts @@ -0,0 +1 @@ +export * from "./Accordion"; diff --git a/frontend/src/components/v3/generic/Badge/Badge.tsx b/frontend/src/components/v3/generic/Badge/Badge.tsx index 9dae877ab..a31f279f2 100644 --- a/frontend/src/components/v3/generic/Badge/Badge.tsx +++ b/frontend/src/components/v3/generic/Badge/Badge.tsx @@ -25,8 +25,8 @@ const badgeVariants = cva( }, variant: { ghost: "text-foreground border-none", - default: "bg-foreground text-background [a&,button&]:hover:bg-primary/35", - outline: "text-foreground border-foreground border", + default: "bg-label text-background border-label [a&,button&]:hover:bg-primary/35", + outline: "text-label border-label border", neutral: "bg-neutral/15 border-neutral/10 text-neutral [a&,button&]:hover:bg-neutral/35", success: "bg-success/15 border-success/10 text-success [a&,button&]:hover:bg-success/35", info: "bg-info/15 border-info/10 border text-info [a&,button&]:hover:bg-info/35", diff --git a/frontend/src/components/v3/generic/Card/Card.tsx b/frontend/src/components/v3/generic/Card/Card.tsx index 5af0d8da6..f38930526 100644 --- a/frontend/src/components/v3/generic/Card/Card.tsx +++ b/frontend/src/components/v3/generic/Card/Card.tsx @@ -8,7 +8,10 @@ function UnstableCard({ className, ...props }: React.ComponentProps<"div">) { return (
); @@ -19,7 +22,8 @@ function UnstableCardHeader({ className, ...props }: React.ComponentProps<"div">
) return (
svg]:inline-block [&>svg]:size-[18px]", - className - )} + className={cn("text-lg leading-none font-semibold", className)} {...props} /> ); @@ -42,14 +43,7 @@ function UnstableCardTitle({ className, ...props }: React.ComponentProps<"div">) function CardDescription({ className, ...props }: React.ComponentProps<"div">) { return ( -
svg]:inline-block [&>svg]:size-[12px]", - className - )} - {...props} - /> +
); } diff --git a/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx b/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx index 64e8aa0fd..5a93c3fb6 100644 --- a/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx +++ b/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx @@ -36,7 +36,8 @@ function UnstableDropdownMenuContent({ sideOffset={sideOffset} className={cn( "max-h-(--radix-dropdown-menu-content-available-height) origin-(--radix-dropdown-menu-content-transform-origin)", - "z-50 overflow-x-hidden overflow-y-auto rounded-[6px] border border-border/50 bg-popover p-1 text-xs text-foreground shadow-md", + "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95", + "z-50 overflow-x-hidden overflow-y-auto rounded-[6px] border border-border bg-popover p-1 text-xs text-foreground shadow-md", className )} {...props} diff --git a/frontend/src/components/v3/generic/Empty/Empty.tsx b/frontend/src/components/v3/generic/Empty/Empty.tsx index f91ae9fb0..3b86bcc88 100644 --- a/frontend/src/components/v3/generic/Empty/Empty.tsx +++ b/frontend/src/components/v3/generic/Empty/Empty.tsx @@ -70,7 +70,7 @@ function UnstableEmptyDescription({ className, ...props }: React.ComponentProps<
a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", + "text-xs/relaxed text-muted [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-project", className )} {...props} diff --git a/frontend/src/components/v3/generic/IconButton/IconButton.tsx b/frontend/src/components/v3/generic/IconButton/IconButton.tsx index b10006aa4..d6fdfb4ce 100644 --- a/frontend/src/components/v3/generic/IconButton/IconButton.tsx +++ b/frontend/src/components/v3/generic/IconButton/IconButton.tsx @@ -35,8 +35,8 @@ const iconButtonVariants = cva( "border-danger/75 bg-danger/40 text-foreground hover:bg-danger/50 hover:border-danger" }, size: { - xs: "h-6 w-6 [&>svg]:size-4 rounded-[5px] [&>svg]:stroke-[1.75]", - sm: "h-8 w-8 [&>svg]:size-5 [&>svg]:stroke-[1.5]", + xs: "h-7 w-7 [&>svg]:size-3.5 [&>svg]:stroke-[1.75]", + sm: "h-8 w-8 [&>svg]:size-4 [&>svg]:stroke-[1.5]", md: "h-9 w-9 [&>svg]:size-6 [&>svg]:stroke-[1.5]", lg: "h-10 w-10 [&>svg]:size-7 [&>svg]:stroke-[1.5]" }, diff --git a/frontend/src/components/v3/generic/Table/Table.tsx b/frontend/src/components/v3/generic/Table/Table.tsx index 45ae3210e..ffd25b766 100644 --- a/frontend/src/components/v3/generic/Table/Table.tsx +++ b/frontend/src/components/v3/generic/Table/Table.tsx @@ -8,7 +8,7 @@ function UnstableTable({ className, ...props }: React.ComponentProps<"table">) { return (
tr]:last:border-b-0", - className - )} + className={cn("border-t border-border font-medium [&>tr]:last:border-b-0", className)} {...props} /> ); @@ -53,7 +50,7 @@ function UnstableTableRow({ className, ...props }: React.ComponentProps<"tr">) { )
[role=checkbox]]:translate-y-[2px]", + "h-[30px] border-x-0 border-t-0 border-b border-border px-3 text-left align-middle text-xs whitespace-nowrap text-accent [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className )} {...props} @@ -91,7 +88,7 @@ function UnstableTableCaption({ className, ...props }: React.ComponentProps<"cap return (
); diff --git a/frontend/src/components/v3/generic/index.ts b/frontend/src/components/v3/generic/index.ts index de3288e4c..43ddf08b0 100644 --- a/frontend/src/components/v3/generic/index.ts +++ b/frontend/src/components/v3/generic/index.ts @@ -1,3 +1,4 @@ +export * from "./Accordion"; export * from "./Alert"; export * from "./Badge"; export * from "./Button"; diff --git a/frontend/src/hooks/api/shared/types.ts b/frontend/src/hooks/api/shared/types.ts index c57daf3fd..8a07ff4e6 100644 --- a/frontend/src/hooks/api/shared/types.ts +++ b/frontend/src/hooks/api/shared/types.ts @@ -18,7 +18,7 @@ export type TIdentity = { updatedAt: string; hasDeleteProtection: boolean; authMethods: IdentityAuthMethod[]; - activeLockoutAuthMethods: string[]; + activeLockoutAuthMethods: IdentityAuthMethod[]; metadata?: Array; }; diff --git a/frontend/src/index.css b/frontend/src/index.css index afd6c1b57..c1e564d92 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -49,14 +49,14 @@ --color-sub-org: #96ff59; --color-project: #e0ed34; --color-neutral: #adaeb0; - --color-border: #323439; + --color-border: #2b2c30; --color-label: #adaeb0; --color-muted: #707174; - --color-popover: #111419; + --color-popover: #141617; --color-ring: #2d2f33; - --color-container: #16181a; + --color-card: #16181a; --color-accent: #7d7f80; - --color-muted-foreground: ; + --color-container: #1a1c1e; /*legacy color schema */ --color-org-v1: #30b3ff; diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx index 47428f2b8..f1533dacb 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx @@ -17,7 +17,6 @@ import { } from "@app/context"; import { useDeleteOrgIdentity, useGetOrgIdentityMembershipById } from "@app/hooks/api"; import { usePopUp } from "@app/hooks/usePopUp"; -import { ViewIdentityAuthModal } from "@app/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAuthModal"; import { OrgAccessControlTabSections } from "@app/types/org"; import { IdentityAuthMethodModal } from "../AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal"; @@ -125,14 +124,16 @@ const Page = () => { identityId={identityId} handlePopUpOpen={handlePopUpOpen} /> + +
{!isAuthHidden && ( )} +
- )} @@ -171,14 +172,6 @@ const Page = () => { ) } /> - handlePopUpToggle("viewAuthMethod", isOpen)} - authMethod={popUp.viewAuthMethod.data?.authMethod} - lockedOut={popUp.viewAuthMethod.data?.lockedOut || false} - identityId={identityId} - onResetAllLockouts={popUp.viewAuthMethod.data?.refetchIdentity} - /> ); }; diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx index dd6234268..aeed2af50 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx @@ -1,16 +1,14 @@ -import { faCog, faLock, faPlus } from "@fortawesome/free-solid-svg-icons"; +import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { OrgPermissionCan } from "@app/components/permissions"; -import { Button, Tooltip } from "@app/components/v2"; +import { Button } from "@app/components/v2"; import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/context"; -import { - IdentityAuthMethod, - identityAuthToNameMap, - useGetOrgIdentityMembershipById -} from "@app/hooks/api"; +import { IdentityAuthMethod, useGetOrgIdentityMembershipById } from "@app/hooks/api"; import { UsePopUpState } from "@app/hooks/usePopUp"; +import { ViewIdentityAuth } from "../ViewIdentityAuth"; + type Props = { identityId: string; handlePopUpOpen: ( @@ -23,37 +21,42 @@ export const IdentityAuthenticationSection = ({ identityId, handlePopUpOpen }: P const { data, refetch } = useGetOrgIdentityMembershipById(identityId); return data ? ( -
-
+
+

Authentication

+ {!Object.values(IdentityAuthMethod).every((method) => + data.identity.authMethods.includes(method) + ) && ( + + {(isAllowed) => ( + + )} + + )}
{data.identity.authMethods.length > 0 ? ( -
- {data.identity.authMethods.map((authMethod) => ( - - ))} -
+ ) : (

@@ -61,30 +64,6 @@ export const IdentityAuthenticationSection = ({ identityId, handlePopUpOpen }: P

)} - {!Object.values(IdentityAuthMethod).every((method) => - data.identity.authMethods.includes(method) - ) && ( - - {(isAllowed) => ( - - )} - - )}
) : (
diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/IdentityAuthFieldDisplay.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/IdentityAuthFieldDisplay.tsx new file mode 100644 index 000000000..5075d9643 --- /dev/null +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/IdentityAuthFieldDisplay.tsx @@ -0,0 +1,24 @@ +import { ReactNode } from "react"; + +import { Detail, DetailLabel, DetailValue } from "@app/components/v3"; + +type Props = { + label: string; + children: ReactNode; + className?: string; +}; + +export const IdentityAuthFieldDisplay = ({ label, children, className }: Props) => { + return ( + + {label} + + {children ? ( +

{children}

+ ) : ( +

Not set

+ )} +
+
+ ); +}; diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityAuthLockoutFields.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/IdentityAuthLockoutFields.tsx similarity index 100% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityAuthLockoutFields.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/IdentityAuthLockoutFields.tsx diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityTokenAuthTokensTable.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/IdentityTokenAuthTokensTable.tsx similarity index 100% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityTokenAuthTokensTable.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/IdentityTokenAuthTokensTable.tsx diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityUniversalAuthClientSecretsTable.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/IdentityUniversalAuthClientSecretsTable.tsx similarity index 100% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityUniversalAuthClientSecretsTable.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/IdentityUniversalAuthClientSecretsTable.tsx diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAliCloudAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAliCloudAuthContent.tsx similarity index 73% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAliCloudAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAliCloudAuthContent.tsx index 5249d7f65..30837ea27 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAliCloudAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAliCloudAuthContent.tsx @@ -2,7 +2,6 @@ import { faBan } from "@fortawesome/free-solid-svg-icons"; import { EmptyState, Spinner } from "@app/components/v2"; import { useGetIdentityAliCloudAuth } from "@app/hooks/api"; -import { IdentityAliCloudAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAliCloudAuthForm"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { ViewAuthMethodProps } from "./types"; @@ -10,10 +9,8 @@ import { ViewIdentityContentWrapper } from "./ViewIdentityContentWrapper"; export const ViewIdentityAliCloudAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, - onDelete, - popUp + onEdit, + onDelete }: ViewAuthMethodProps) => { const { data, isPending } = useGetIdentityAliCloudAuth(identityId); @@ -34,23 +31,8 @@ export const ViewIdentityAliCloudAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {data.accessTokenTTL} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAuth.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAuth.tsx new file mode 100644 index 000000000..93fdc7b8b --- /dev/null +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAuth.tsx @@ -0,0 +1,276 @@ +import { useParams } from "@tanstack/react-router"; +import { EllipsisIcon, LockIcon } from "lucide-react"; + +import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal"; +import { createNotification } from "@app/components/notifications"; +import { DeleteActionModal, Modal, ModalContent, Tooltip } from "@app/components/v2"; +import { + Badge, + UnstableAccordion, + UnstableAccordionContent, + UnstableAccordionItem, + UnstableAccordionTrigger, + UnstableDropdownMenu, + UnstableDropdownMenuContent, + UnstableDropdownMenuItem, + UnstableDropdownMenuTrigger, + UnstableIconButton +} from "@app/components/v3"; +import { useOrganization } from "@app/context"; +import { usePopUp } from "@app/hooks"; +import { + IdentityAuthMethod, + identityAuthToNameMap, + useDeleteIdentityAliCloudAuth, + useDeleteIdentityAwsAuth, + useDeleteIdentityAzureAuth, + useDeleteIdentityGcpAuth, + useDeleteIdentityJwtAuth, + useDeleteIdentityKubernetesAuth, + useDeleteIdentityLdapAuth, + useDeleteIdentityOciAuth, + useDeleteIdentityOidcAuth, + useDeleteIdentityTlsCertAuth, + useDeleteIdentityTokenAuth, + useDeleteIdentityUniversalAuth +} from "@app/hooks/api"; +import { IdentityAliCloudAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAliCloudAuthForm"; +import { IdentityAwsAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm"; +import { IdentityAzureAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm"; +import { IdentityGcpAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm"; +import { IdentityJwtAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm"; +import { IdentityKubernetesAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm"; +import { IdentityLdapAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm"; +import { IdentityOciAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOciAuthForm"; +import { IdentityOidcAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm"; +import { IdentityTlsCertAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTlsCertAuthForm"; +import { IdentityTokenAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthForm"; +import { IdentityUniversalAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm"; + +import { ViewIdentityAliCloudAuthContent } from "./ViewIdentityAliCloudAuthContent"; +import { ViewIdentityAwsAuthContent } from "./ViewIdentityAwsAuthContent"; +import { ViewIdentityAzureAuthContent } from "./ViewIdentityAzureAuthContent"; +import { ViewIdentityGcpAuthContent } from "./ViewIdentityGcpAuthContent"; +import { ViewIdentityJwtAuthContent } from "./ViewIdentityJwtAuthContent"; +import { ViewIdentityKubernetesAuthContent } from "./ViewIdentityKubernetesAuthContent"; +import { ViewIdentityLdapAuthContent } from "./ViewIdentityLdapAuthContent"; +import { ViewIdentityOciAuthContent } from "./ViewIdentityOciAuthContent"; +import { ViewIdentityOidcAuthContent } from "./ViewIdentityOidcAuthContent"; +import { ViewIdentityTlsCertAuthContent } from "./ViewIdentityTlsCertAuthContent"; +import { ViewIdentityTokenAuthContent } from "./ViewIdentityTokenAuthContent"; +import { ViewIdentityUniversalAuthContent } from "./ViewIdentityUniversalAuthContent"; + +type Props = { + identityId: string; + authMethods: IdentityAuthMethod[]; + onResetAllLockouts: () => void; + activeLockoutAuthMethods: IdentityAuthMethod[]; +}; + +const AuthMethodComponentMap = { + [IdentityAuthMethod.UNIVERSAL_AUTH]: ViewIdentityUniversalAuthContent, + [IdentityAuthMethod.TOKEN_AUTH]: ViewIdentityTokenAuthContent, + [IdentityAuthMethod.TLS_CERT_AUTH]: ViewIdentityTlsCertAuthContent, + [IdentityAuthMethod.KUBERNETES_AUTH]: ViewIdentityKubernetesAuthContent, + [IdentityAuthMethod.LDAP_AUTH]: ViewIdentityLdapAuthContent, + [IdentityAuthMethod.OCI_AUTH]: ViewIdentityOciAuthContent, + [IdentityAuthMethod.OIDC_AUTH]: ViewIdentityOidcAuthContent, + [IdentityAuthMethod.GCP_AUTH]: ViewIdentityGcpAuthContent, + [IdentityAuthMethod.AWS_AUTH]: ViewIdentityAwsAuthContent, + [IdentityAuthMethod.ALICLOUD_AUTH]: ViewIdentityAliCloudAuthContent, + [IdentityAuthMethod.AZURE_AUTH]: ViewIdentityAzureAuthContent, + [IdentityAuthMethod.JWT_AUTH]: ViewIdentityJwtAuthContent +}; + +const EditAuthMethodMap = { + [IdentityAuthMethod.KUBERNETES_AUTH]: IdentityKubernetesAuthForm, + [IdentityAuthMethod.GCP_AUTH]: IdentityGcpAuthForm, + [IdentityAuthMethod.TLS_CERT_AUTH]: IdentityTlsCertAuthForm, + [IdentityAuthMethod.AWS_AUTH]: IdentityAwsAuthForm, + [IdentityAuthMethod.AZURE_AUTH]: IdentityAzureAuthForm, + [IdentityAuthMethod.ALICLOUD_AUTH]: IdentityAliCloudAuthForm, + [IdentityAuthMethod.UNIVERSAL_AUTH]: IdentityUniversalAuthForm, + [IdentityAuthMethod.TOKEN_AUTH]: IdentityTokenAuthForm, + [IdentityAuthMethod.OCI_AUTH]: IdentityOciAuthForm, + [IdentityAuthMethod.OIDC_AUTH]: IdentityOidcAuthForm, + [IdentityAuthMethod.JWT_AUTH]: IdentityJwtAuthForm, + [IdentityAuthMethod.LDAP_AUTH]: IdentityLdapAuthForm +}; + +export const Content = ({ + identityId, + authMethods, + onResetAllLockouts, + activeLockoutAuthMethods +}: Pick< + Props, + "authMethods" | "identityId" | "onResetAllLockouts" | "activeLockoutAuthMethods" +>) => { + const { currentOrg } = useOrganization(); + const orgId = currentOrg?.id || ""; + const { projectId } = useParams({ + strict: false + }); + const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([ + "revokeAuthMethod", + "identityAuthMethod", + "upgradePlan" + ] as const); + + const { mutateAsync: revokeUniversalAuth } = useDeleteIdentityUniversalAuth(); + const { mutateAsync: revokeTokenAuth } = useDeleteIdentityTokenAuth(); + const { mutateAsync: revokeKubernetesAuth } = useDeleteIdentityKubernetesAuth(); + const { mutateAsync: revokeGcpAuth } = useDeleteIdentityGcpAuth(); + const { mutateAsync: revokeTlsCertAuth } = useDeleteIdentityTlsCertAuth(); + const { mutateAsync: revokeAwsAuth } = useDeleteIdentityAwsAuth(); + const { mutateAsync: revokeAzureAuth } = useDeleteIdentityAzureAuth(); + const { mutateAsync: revokeAliCloudAuth } = useDeleteIdentityAliCloudAuth(); + const { mutateAsync: revokeOciAuth } = useDeleteIdentityOciAuth(); + const { mutateAsync: revokeOidcAuth } = useDeleteIdentityOidcAuth(); + const { mutateAsync: revokeJwtAuth } = useDeleteIdentityJwtAuth(); + const { mutateAsync: revokeLdapAuth } = useDeleteIdentityLdapAuth(); + + const RemoveAuthMethodMap = { + [IdentityAuthMethod.KUBERNETES_AUTH]: revokeKubernetesAuth, + [IdentityAuthMethod.GCP_AUTH]: revokeGcpAuth, + [IdentityAuthMethod.TLS_CERT_AUTH]: revokeTlsCertAuth, + [IdentityAuthMethod.AWS_AUTH]: revokeAwsAuth, + [IdentityAuthMethod.AZURE_AUTH]: revokeAzureAuth, + [IdentityAuthMethod.ALICLOUD_AUTH]: revokeAliCloudAuth, + [IdentityAuthMethod.UNIVERSAL_AUTH]: revokeUniversalAuth, + [IdentityAuthMethod.TOKEN_AUTH]: revokeTokenAuth, + [IdentityAuthMethod.OCI_AUTH]: revokeOciAuth, + [IdentityAuthMethod.OIDC_AUTH]: revokeOidcAuth, + [IdentityAuthMethod.JWT_AUTH]: revokeJwtAuth, + [IdentityAuthMethod.LDAP_AUTH]: revokeLdapAuth + }; + + const handleDeleteAuthMethod = async (authMethod: IdentityAuthMethod) => { + await RemoveAuthMethodMap[authMethod]({ + identityId, + ...(projectId + ? { projectId } + : { + organizationId: orgId + }) + }); + + createNotification({ + text: "Successfully removed auth method", + type: "success" + }); + handlePopUpToggle("revokeAuthMethod", false); + }; + + const EditForm = popUp.identityAuthMethod?.data + ? EditAuthMethodMap[popUp.identityAuthMethod.data as IdentityAuthMethod] + : null; + + return ( + <> + + {authMethods.map((authMethod) => { + const Component = AuthMethodComponentMap[authMethod]; + + return ( + + + {identityAuthToNameMap[authMethod]} + {activeLockoutAuthMethods?.includes(authMethod) && ( + + + + + + )} + + + + + + + + { + e.stopPropagation(); + handlePopUpOpen("identityAuthMethod", authMethod); + }} + > + Edit Auth Method + + { + e.stopPropagation(); + handlePopUpOpen("revokeAuthMethod", authMethod); + }} + variant="danger" + > + Remove Auth Method + + + + + + handlePopUpOpen("identityAuthMethod", authMethod)} + onDelete={() => handlePopUpOpen("revokeAuthMethod", authMethod)} + onResetAllLockouts={onResetAllLockouts} + lockedOut={activeLockoutAuthMethods?.includes(authMethod)} + /> + + + ); + })} + + handlePopUpToggle("revokeAuthMethod", isOpen)} + deleteKey="confirm" + buttonText="Remove" + onDeleteApproved={() => + handleDeleteAuthMethod(popUp?.revokeAuthMethod?.data as IdentityAuthMethod) + } + /> + handlePopUpToggle("identityAuthMethod", isOpen)} + > + + {EditForm && ( + + )} + + + handlePopUpToggle("upgradePlan", isOpen)} + text={`Your current plan does not include access to ${popUp.upgradePlan.data?.featureName}. To unlock this feature, please upgrade to Infisical ${popUp.upgradePlan.data?.isEnterpriseFeature ? "Enterprise" : "Pro"} plan.`} + /> + + ); +}; + +export const ViewIdentityAuth = ({ + authMethods, + identityId, + onResetAllLockouts, + activeLockoutAuthMethods +}: Props) => { + return ( + onResetAllLockouts()} + /> + ); +}; diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAwsAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAwsAuthContent.tsx similarity index 77% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAwsAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAwsAuthContent.tsx index dde9f1d2a..c16a8c3a1 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAwsAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAwsAuthContent.tsx @@ -2,7 +2,6 @@ import { faBan } from "@fortawesome/free-solid-svg-icons"; import { EmptyState, Spinner } from "@app/components/v2"; import { useGetIdentityAwsAuth } from "@app/hooks/api"; -import { IdentityAwsAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { ViewAuthMethodProps } from "./types"; @@ -10,10 +9,8 @@ import { ViewIdentityContentWrapper } from "./ViewIdentityContentWrapper"; export const ViewIdentityAwsAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, - onDelete, - popUp + onEdit, + onDelete }: ViewAuthMethodProps) => { const { data, isPending } = useGetIdentityAwsAuth(identityId); @@ -31,23 +28,8 @@ export const ViewIdentityAwsAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {data.accessTokenTTL} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAzureAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAzureAuthContent.tsx similarity index 76% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAzureAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAzureAuthContent.tsx index 82e4c69e0..5f25f1a50 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAzureAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityAzureAuthContent.tsx @@ -2,7 +2,6 @@ import { faBan } from "@fortawesome/free-solid-svg-icons"; import { EmptyState, Spinner } from "@app/components/v2"; import { useGetIdentityAzureAuth } from "@app/hooks/api"; -import { IdentityAzureAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { ViewAuthMethodProps } from "./types"; @@ -10,10 +9,8 @@ import { ViewIdentityContentWrapper } from "./ViewIdentityContentWrapper"; export const ViewIdentityAzureAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, - onDelete, - popUp + onEdit, + onDelete }: ViewAuthMethodProps) => { const { data, isPending } = useGetIdentityAzureAuth(identityId); @@ -31,23 +28,8 @@ export const ViewIdentityAzureAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {data.accessTokenTTL} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityContentWrapper.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityContentWrapper.tsx similarity index 100% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityContentWrapper.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityContentWrapper.tsx diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityGcpAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityGcpAuthContent.tsx similarity index 80% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityGcpAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityGcpAuthContent.tsx index 296b4d764..5f24ec54c 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityGcpAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityGcpAuthContent.tsx @@ -2,7 +2,6 @@ import { faBan } from "@fortawesome/free-solid-svg-icons"; import { EmptyState, Spinner } from "@app/components/v2"; import { useGetIdentityGcpAuth } from "@app/hooks/api"; -import { IdentityGcpAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { ViewAuthMethodProps } from "./types"; @@ -10,10 +9,8 @@ import { ViewIdentityContentWrapper } from "./ViewIdentityContentWrapper"; export const ViewIdentityGcpAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, - onDelete, - popUp + onEdit, + onDelete }: ViewAuthMethodProps) => { const { data, isPending } = useGetIdentityGcpAuth(identityId); @@ -31,23 +28,8 @@ export const ViewIdentityGcpAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {data.accessTokenTTL} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityJwtAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityJwtAuthContent.tsx similarity index 86% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityJwtAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityJwtAuthContent.tsx index 7fb81d2e1..a372491eb 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityJwtAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityJwtAuthContent.tsx @@ -5,18 +5,15 @@ import { EmptyState, Spinner, Tooltip } from "@app/components/v2"; import { Badge } from "@app/components/v3"; import { useGetIdentityJwtAuth } from "@app/hooks/api"; import { IdentityJwtConfigurationType } from "@app/hooks/api/identities/enums"; -import { IdentityJwtAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm"; -import { ViewIdentityContentWrapper } from "@app/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityContentWrapper"; +import { ViewIdentityContentWrapper } from "@app/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityContentWrapper"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { ViewAuthMethodProps } from "./types"; export const ViewIdentityJwtAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, - onDelete, - popUp + onEdit, + onDelete }: ViewAuthMethodProps) => { const { data, isPending } = useGetIdentityJwtAuth(identityId); @@ -34,23 +31,8 @@ export const ViewIdentityJwtAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {data.accessTokenTTL} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityKubernetesAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityKubernetesAuthContent.tsx similarity index 86% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityKubernetesAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityKubernetesAuthContent.tsx index 02b0e0c88..e6992ca2e 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityKubernetesAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityKubernetesAuthContent.tsx @@ -6,7 +6,6 @@ import { EyeIcon } from "lucide-react"; import { EmptyState, Spinner, Tooltip } from "@app/components/v2"; import { Badge } from "@app/components/v3"; import { gatewaysQueryKeys, useGetIdentityKubernetesAuth } from "@app/hooks/api"; -import { IdentityKubernetesAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { ViewAuthMethodProps } from "./types"; @@ -14,10 +13,8 @@ import { ViewIdentityContentWrapper } from "./ViewIdentityContentWrapper"; export const ViewIdentityKubernetesAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, - onDelete, - popUp + onEdit, + onDelete }: ViewAuthMethodProps) => { const { data: gateways } = useQuery(gatewaysQueryKeys.list()); @@ -44,23 +41,8 @@ export const ViewIdentityKubernetesAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {data.accessTokenTTL} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityLdapAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityLdapAuthContent.tsx similarity index 83% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityLdapAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityLdapAuthContent.tsx index b6db96c41..c835fd97c 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityLdapAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityLdapAuthContent.tsx @@ -4,8 +4,7 @@ import { EyeIcon } from "lucide-react"; import { EmptyState, Spinner, Tooltip } from "@app/components/v2"; import { Badge } from "@app/components/v3"; import { useClearIdentityLdapAuthLockouts, useGetIdentityLdapAuth } from "@app/hooks/api"; -import { IdentityLdapAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm"; -import { ViewIdentityContentWrapper } from "@app/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityContentWrapper"; +import { ViewIdentityContentWrapper } from "@app/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityContentWrapper"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { LockoutFields } from "./IdentityAuthLockoutFields"; @@ -13,10 +12,8 @@ import { ViewAuthMethodProps } from "./types"; export const ViewIdentityLdapAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, onDelete, - popUp, + onEdit, lockedOut, onResetAllLockouts }: ViewAuthMethodProps) => { @@ -37,23 +34,8 @@ export const ViewIdentityLdapAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {data.accessTokenTTL} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityOciAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityOciAuthContent.tsx similarity index 75% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityOciAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityOciAuthContent.tsx index c577c01e0..7b7e58258 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityOciAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityOciAuthContent.tsx @@ -2,7 +2,6 @@ import { faBan } from "@fortawesome/free-solid-svg-icons"; import { EmptyState, Spinner } from "@app/components/v2"; import { useGetIdentityOciAuth } from "@app/hooks/api"; -import { IdentityOciAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOciAuthForm"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { ViewAuthMethodProps } from "./types"; @@ -10,10 +9,8 @@ import { ViewIdentityContentWrapper } from "./ViewIdentityContentWrapper"; export const ViewIdentityOciAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, - onDelete, - popUp + onEdit, + onDelete }: ViewAuthMethodProps) => { const { data, isPending } = useGetIdentityOciAuth(identityId); @@ -31,23 +28,8 @@ export const ViewIdentityOciAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {data.accessTokenTTL} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityOidcAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityOidcAuthContent.tsx similarity index 84% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityOidcAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityOidcAuthContent.tsx index dc7e5b985..27b487a3f 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityOidcAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityOidcAuthContent.tsx @@ -4,18 +4,15 @@ import { EyeIcon } from "lucide-react"; import { EmptyState, Spinner, Tooltip } from "@app/components/v2"; import { Badge } from "@app/components/v3"; import { useGetIdentityOidcAuth } from "@app/hooks/api"; -import { IdentityOidcAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm"; -import { ViewIdentityContentWrapper } from "@app/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityContentWrapper"; +import { ViewIdentityContentWrapper } from "@app/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityContentWrapper"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { ViewAuthMethodProps } from "./types"; export const ViewIdentityOidcAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, - onDelete, - popUp + onEdit, + onDelete }: ViewAuthMethodProps) => { const { data, isPending } = useGetIdentityOidcAuth(identityId); @@ -33,23 +30,8 @@ export const ViewIdentityOidcAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {data.accessTokenTTL} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityTlsCertAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityTlsCertAuthContent.tsx similarity index 78% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityTlsCertAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityTlsCertAuthContent.tsx index 03c4989a6..6ffefbeb6 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityTlsCertAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityTlsCertAuthContent.tsx @@ -4,7 +4,6 @@ import { EyeIcon } from "lucide-react"; import { EmptyState, Spinner, Tooltip } from "@app/components/v2"; import { Badge } from "@app/components/v3"; import { useGetIdentityTlsCertAuth } from "@app/hooks/api"; -import { IdentityTlsCertAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTlsCertAuthForm"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { ViewAuthMethodProps } from "./types"; @@ -12,10 +11,8 @@ import { ViewIdentityContentWrapper } from "./ViewIdentityContentWrapper"; export const ViewIdentityTlsCertAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, - onDelete, - popUp + onEdit, + onDelete }: ViewAuthMethodProps) => { const { data, isPending } = useGetIdentityTlsCertAuth(identityId); @@ -36,23 +33,8 @@ export const ViewIdentityTlsCertAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {data.accessTokenTTL} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityTokenAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityTokenAuthContent.tsx similarity index 75% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityTokenAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityTokenAuthContent.tsx index d42f9d2ca..b86a4d9ad 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityTokenAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityTokenAuthContent.tsx @@ -2,7 +2,6 @@ import { faBan } from "@fortawesome/free-solid-svg-icons"; import { EmptyState, Spinner } from "@app/components/v2"; import { useGetIdentityTokenAuth, useGetIdentityTokensTokenAuth } from "@app/hooks/api"; -import { IdentityTokenAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthForm"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { IdentityTokenAuthTokensTable } from "./IdentityTokenAuthTokensTable"; @@ -11,10 +10,8 @@ import { ViewIdentityContentWrapper } from "./ViewIdentityContentWrapper"; export const ViewIdentityTokenAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, onDelete, - popUp + onEdit }: ViewAuthMethodProps) => { const { data, isPending } = useGetIdentityTokenAuth(identityId); const { data: tokens = [], isPending: clientSecretsPending } = @@ -34,23 +31,8 @@ export const ViewIdentityTokenAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {data.accessTokenTTL} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityUniversalAuthContent.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityUniversalAuthContent.tsx similarity index 86% rename from frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityUniversalAuthContent.tsx rename to frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityUniversalAuthContent.tsx index e9840a28c..86a2e4fb9 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityUniversalAuthContent.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/ViewIdentityUniversalAuthContent.tsx @@ -8,7 +8,6 @@ import { useGetIdentityUniversalAuth, useGetIdentityUniversalAuthClientSecrets } from "@app/hooks/api"; -import { IdentityUniversalAuthForm } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm"; import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay"; import { LockoutFields } from "./IdentityAuthLockoutFields"; @@ -18,10 +17,8 @@ import { ViewIdentityContentWrapper } from "./ViewIdentityContentWrapper"; export const ViewIdentityUniversalAuthContent = ({ identityId, - handlePopUpToggle, - handlePopUpOpen, onDelete, - popUp, + onEdit, lockedOut, onResetAllLockouts }: ViewAuthMethodProps) => { @@ -51,23 +48,8 @@ export const ViewIdentityUniversalAuthContent = ({ ); } - if (popUp.identityAuthMethod.isOpen) { - return ( - - ); - } - return ( - handlePopUpOpen("identityAuthMethod")} - onDelete={onDelete} - identityId={identityId} - > + {Number(data.accessTokenPeriod) > 0 ? ( {data.accessTokenPeriod} diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/index.ts b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/index.ts new file mode 100644 index 000000000..951c84087 --- /dev/null +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/index.ts @@ -0,0 +1 @@ +export * from "./ViewIdentityAuth"; diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/types/index.ts b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/types/index.ts new file mode 100644 index 000000000..e4b015410 --- /dev/null +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth/types/index.ts @@ -0,0 +1,7 @@ +export type ViewAuthMethodProps = { + identityId: string; + onDelete: () => void; + onEdit: () => void; + lockedOut: boolean; + onResetAllLockouts: () => void; +}; diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityAuthFieldDisplay.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityAuthFieldDisplay.tsx deleted file mode 100644 index eb81bbcef..000000000 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityAuthFieldDisplay.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { ReactNode } from "react"; - -type Props = { - label: string; - children: ReactNode; - className?: string; -}; - -export const IdentityAuthFieldDisplay = ({ label, children, className }: Props) => { - return ( -
- {label} - {children ? ( -

{children}

- ) : ( -

Not set

- )} -
- ); -}; diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAuthModal.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAuthModal.tsx deleted file mode 100644 index 5c12ddd4c..000000000 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityAuthModal.tsx +++ /dev/null @@ -1,214 +0,0 @@ -import { useParams } from "@tanstack/react-router"; - -import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal"; -import { createNotification } from "@app/components/notifications"; -import { DeleteActionModal, Modal, ModalContent } from "@app/components/v2"; -import { useOrganization } from "@app/context"; -import { usePopUp } from "@app/hooks"; -import { - IdentityAuthMethod, - identityAuthToNameMap, - useDeleteIdentityAliCloudAuth, - useDeleteIdentityAwsAuth, - useDeleteIdentityAzureAuth, - useDeleteIdentityGcpAuth, - useDeleteIdentityJwtAuth, - useDeleteIdentityKubernetesAuth, - useDeleteIdentityLdapAuth, - useDeleteIdentityOciAuth, - useDeleteIdentityOidcAuth, - useDeleteIdentityTlsCertAuth, - useDeleteIdentityTokenAuth, - useDeleteIdentityUniversalAuth -} from "@app/hooks/api"; - -import { ViewAuthMethodProps } from "./types"; -import { ViewIdentityAliCloudAuthContent } from "./ViewIdentityAliCloudAuthContent"; -import { ViewIdentityAwsAuthContent } from "./ViewIdentityAwsAuthContent"; -import { ViewIdentityAzureAuthContent } from "./ViewIdentityAzureAuthContent"; -import { ViewIdentityGcpAuthContent } from "./ViewIdentityGcpAuthContent"; -import { ViewIdentityJwtAuthContent } from "./ViewIdentityJwtAuthContent"; -import { ViewIdentityKubernetesAuthContent } from "./ViewIdentityKubernetesAuthContent"; -import { ViewIdentityLdapAuthContent } from "./ViewIdentityLdapAuthContent"; -import { ViewIdentityOciAuthContent } from "./ViewIdentityOciAuthContent"; -import { ViewIdentityOidcAuthContent } from "./ViewIdentityOidcAuthContent"; -import { ViewIdentityTlsCertAuthContent } from "./ViewIdentityTlsCertAuthContent"; -import { ViewIdentityTokenAuthContent } from "./ViewIdentityTokenAuthContent"; -import { ViewIdentityUniversalAuthContent } from "./ViewIdentityUniversalAuthContent"; - -type Props = { - identityId: string; - authMethod?: IdentityAuthMethod; - lockedOut: boolean; - isOpen: boolean; - onOpenChange: (isOpen: boolean) => void; - onDeleteAuthMethod: () => void; - onResetAllLockouts: () => void; -}; - -type TRevokeOptions = { - identityId: string; -} & ({ projectId: string } | { organizationId: string }); - -export const Content = ({ - identityId, - authMethod, - lockedOut, - onDeleteAuthMethod, - onResetAllLockouts -}: Pick< - Props, - "authMethod" | "lockedOut" | "identityId" | "onDeleteAuthMethod" | "onResetAllLockouts" ->) => { - const { currentOrg } = useOrganization(); - const orgId = currentOrg?.id || ""; - const { projectId } = useParams({ - strict: false - }); - const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([ - "revokeAuthMethod", - "upgradePlan", - "identityAuthMethod" - ] as const); - - const { mutateAsync: revokeUniversalAuth } = useDeleteIdentityUniversalAuth(); - const { mutateAsync: revokeTokenAuth } = useDeleteIdentityTokenAuth(); - const { mutateAsync: revokeKubernetesAuth } = useDeleteIdentityKubernetesAuth(); - const { mutateAsync: revokeGcpAuth } = useDeleteIdentityGcpAuth(); - const { mutateAsync: revokeTlsCertAuth } = useDeleteIdentityTlsCertAuth(); - const { mutateAsync: revokeAwsAuth } = useDeleteIdentityAwsAuth(); - const { mutateAsync: revokeAzureAuth } = useDeleteIdentityAzureAuth(); - const { mutateAsync: revokeAliCloudAuth } = useDeleteIdentityAliCloudAuth(); - const { mutateAsync: revokeOciAuth } = useDeleteIdentityOciAuth(); - const { mutateAsync: revokeOidcAuth } = useDeleteIdentityOidcAuth(); - const { mutateAsync: revokeJwtAuth } = useDeleteIdentityJwtAuth(); - const { mutateAsync: revokeLdapAuth } = useDeleteIdentityLdapAuth(); - - let Component: (props: ViewAuthMethodProps) => JSX.Element; - let revokeMethod: (revokeOptions: TRevokeOptions) => Promise; - - const handleDelete = () => handlePopUpOpen("revokeAuthMethod"); - - switch (authMethod) { - case IdentityAuthMethod.UNIVERSAL_AUTH: - revokeMethod = revokeUniversalAuth; - Component = ViewIdentityUniversalAuthContent; - break; - case IdentityAuthMethod.TOKEN_AUTH: - revokeMethod = revokeTokenAuth; - Component = ViewIdentityTokenAuthContent; - break; - case IdentityAuthMethod.KUBERNETES_AUTH: - revokeMethod = revokeKubernetesAuth; - Component = ViewIdentityKubernetesAuthContent; - break; - case IdentityAuthMethod.GCP_AUTH: - revokeMethod = revokeGcpAuth; - Component = ViewIdentityGcpAuthContent; - break; - case IdentityAuthMethod.TLS_CERT_AUTH: - revokeMethod = revokeTlsCertAuth; - Component = ViewIdentityTlsCertAuthContent; - break; - case IdentityAuthMethod.AWS_AUTH: - revokeMethod = revokeAwsAuth; - Component = ViewIdentityAwsAuthContent; - break; - case IdentityAuthMethod.AZURE_AUTH: - revokeMethod = revokeAzureAuth; - Component = ViewIdentityAzureAuthContent; - break; - case IdentityAuthMethod.OCI_AUTH: - revokeMethod = revokeOciAuth; - Component = ViewIdentityOciAuthContent; - break; - case IdentityAuthMethod.ALICLOUD_AUTH: - revokeMethod = revokeAliCloudAuth; - Component = ViewIdentityAliCloudAuthContent; - break; - case IdentityAuthMethod.OIDC_AUTH: - revokeMethod = revokeOidcAuth; - Component = ViewIdentityOidcAuthContent; - break; - case IdentityAuthMethod.JWT_AUTH: - revokeMethod = revokeJwtAuth; - Component = ViewIdentityJwtAuthContent; - break; - case IdentityAuthMethod.LDAP_AUTH: - revokeMethod = revokeLdapAuth; - Component = ViewIdentityLdapAuthContent; - break; - default: - throw new Error(`Unhandled Auth Method: ${authMethod}`); - } - - const handleDeleteAuthMethod = async () => { - await revokeMethod({ - identityId, - ...(projectId - ? { projectId } - : { - organizationId: orgId - }) - }); - - createNotification({ - text: "Successfully removed auth method", - type: "success" - }); - handlePopUpToggle("revokeAuthMethod", false); - onDeleteAuthMethod(); - }; - - return ( - <> - - handlePopUpToggle("revokeAuthMethod", isOpen)} - deleteKey="confirm" - buttonText="Remove" - onDeleteApproved={handleDeleteAuthMethod} - /> - handlePopUpToggle("upgradePlan", isOpen)} - text={`Your current plan does not include access to ${popUp.upgradePlan.data?.featureName}. To unlock this feature, please upgrade to Infisical ${popUp.upgradePlan.data?.isEnterpriseFeature ? "Enterprise" : "Pro"} plan.`} - /> - - ); -}; - -export const ViewIdentityAuthModal = ({ - isOpen, - onOpenChange, - authMethod, - identityId, - lockedOut, - onResetAllLockouts -}: Omit) => { - if (!identityId || !authMethod) return null; - - return ( - - - onOpenChange(false)} - onResetAllLockouts={() => onResetAllLockouts()} - /> - - - ); -}; diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/index.ts b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/index.ts deleted file mode 100644 index 2da1344a8..000000000 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./ViewIdentityAuthModal"; diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/types/index.ts b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/types/index.ts deleted file mode 100644 index da31a233c..000000000 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/types/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { UsePopUpState } from "@app/hooks/usePopUp"; - -export type ViewAuthMethodProps = { - identityId: string; - onDelete: () => void; - handlePopUpOpen: (popUpName: keyof UsePopUpState<["upgradePlan", "identityAuthMethod"]>) => void; - handlePopUpToggle: ( - popUpName: keyof UsePopUpState<["identityAuthMethod"]>, - state?: boolean - ) => void; - popUp: UsePopUpState<["revokeAuthMethod", "upgradePlan", "identityAuthMethod"]>; - lockedOut: boolean; - onResetAllLockouts: () => void; -}; diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx index d8fbd73d7..909f60282 100644 --- a/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx +++ b/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx @@ -179,14 +179,13 @@ const Page = () => { search={{ selectedTab: ProjectAccessControlTabs.Identities }} - className="mb-3 flex w-fit items-center gap-x-1 text-sm text-mineshaft-400 transition duration-100 hover:text-mineshaft-400/80" + className="mb-4 flex w-fit items-center gap-x-1 text-sm text-mineshaft-400 transition duration-100 hover:text-mineshaft-400/80" > Project Machine Identities @@ -256,14 +255,14 @@ const Page = () => { -
+
-
+
{identity ? ( - + Project Additional Privileges Assign one-off policies to this machine identity @@ -96,7 +98,7 @@ export const IdentityProjectAdditionalPrivilegeSection = ({ identityMembershipDe > {(isAllowed) => ( { handlePopUpOpen("modifyPrivilege"); diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx index a0905abb4..9d88924b3 100644 --- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx +++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx @@ -96,7 +96,9 @@ export const IdentityRoleDetailsSection = ({ return ( <> - + Project Roles Manage roles assigned to this machine identity @@ -112,7 +114,7 @@ export const IdentityRoleDetailsSection = ({ {(isAllowed) => ( { handlePopUpOpen("modifyRole"); }} diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx index 6f1bfe464..6311267a3 100644 --- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx +++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx @@ -1,11 +1,11 @@ import { subject } from "@casl/ability"; -import { EllipsisIcon, LockIcon, PlusIcon } from "lucide-react"; +import { PlusIcon } from "lucide-react"; import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; -import { Tooltip } from "@app/components/v2"; +import { DeleteActionModal } from "@app/components/v2"; import { - Badge, UnstableButton, UnstableCard, UnstableCardAction, @@ -17,20 +17,29 @@ import { UnstableEmptyContent, UnstableEmptyDescription, UnstableEmptyHeader, - UnstableEmptyTitle, - UnstableIconButton, - UnstableTable, - UnstableTableBody, - UnstableTableCell, - UnstableTableHead, - UnstableTableHeader, - UnstableTableRow + UnstableEmptyTitle } from "@app/components/v3"; import { ProjectPermissionIdentityActions, ProjectPermissionSub } from "@app/context"; -import { IdentityAuthMethod, identityAuthToNameMap, TProjectIdentity } from "@app/hooks/api"; +import { + IdentityAuthMethod, + identityAuthToNameMap, + TProjectIdentity, + useDeleteIdentityAliCloudAuth, + useDeleteIdentityAwsAuth, + useDeleteIdentityAzureAuth, + useDeleteIdentityGcpAuth, + useDeleteIdentityJwtAuth, + useDeleteIdentityKubernetesAuth, + useDeleteIdentityLdapAuth, + useDeleteIdentityOciAuth, + useDeleteIdentityOidcAuth, + useDeleteIdentityTlsCertAuth, + useDeleteIdentityTokenAuth, + useDeleteIdentityUniversalAuth +} from "@app/hooks/api"; import { usePopUp } from "@app/hooks/usePopUp"; import { IdentityAuthMethodModal } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal"; -import { ViewIdentityAuthModal } from "@app/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal"; +import { ViewIdentityAuth } from "@app/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuth"; type Props = { identity: TProjectIdentity; @@ -39,17 +48,58 @@ type Props = { export const ProjectIdentityAuthenticationSection = ({ identity, refetchIdentity }: Props) => { const { popUp, handlePopUpToggle, handlePopUpOpen } = usePopUp([ - "viewAuthMethod", "identityAuthMethod", - "upgradePlan" + "upgradePlan", + "revokeAuthMethod" ]); const hasAuthMethods = Boolean(identity.authMethods.length); + const { mutateAsync: revokeUniversalAuth } = useDeleteIdentityUniversalAuth(); + const { mutateAsync: revokeTokenAuth } = useDeleteIdentityTokenAuth(); + const { mutateAsync: revokeKubernetesAuth } = useDeleteIdentityKubernetesAuth(); + const { mutateAsync: revokeGcpAuth } = useDeleteIdentityGcpAuth(); + const { mutateAsync: revokeTlsCertAuth } = useDeleteIdentityTlsCertAuth(); + const { mutateAsync: revokeAwsAuth } = useDeleteIdentityAwsAuth(); + const { mutateAsync: revokeAzureAuth } = useDeleteIdentityAzureAuth(); + const { mutateAsync: revokeAliCloudAuth } = useDeleteIdentityAliCloudAuth(); + const { mutateAsync: revokeOciAuth } = useDeleteIdentityOciAuth(); + const { mutateAsync: revokeOidcAuth } = useDeleteIdentityOidcAuth(); + const { mutateAsync: revokeJwtAuth } = useDeleteIdentityJwtAuth(); + const { mutateAsync: revokeLdapAuth } = useDeleteIdentityLdapAuth(); + + const RemoveAuthMap = { + [IdentityAuthMethod.KUBERNETES_AUTH]: revokeKubernetesAuth, + [IdentityAuthMethod.GCP_AUTH]: revokeGcpAuth, + [IdentityAuthMethod.TLS_CERT_AUTH]: revokeTlsCertAuth, + [IdentityAuthMethod.AWS_AUTH]: revokeAwsAuth, + [IdentityAuthMethod.AZURE_AUTH]: revokeAzureAuth, + [IdentityAuthMethod.ALICLOUD_AUTH]: revokeAliCloudAuth, + [IdentityAuthMethod.UNIVERSAL_AUTH]: revokeUniversalAuth, + [IdentityAuthMethod.TOKEN_AUTH]: revokeTokenAuth, + [IdentityAuthMethod.OCI_AUTH]: revokeOciAuth, + [IdentityAuthMethod.OIDC_AUTH]: revokeOidcAuth, + [IdentityAuthMethod.JWT_AUTH]: revokeJwtAuth, + [IdentityAuthMethod.LDAP_AUTH]: revokeLdapAuth + }; + + const handleDeleteAuthMethod = async (authMethod: IdentityAuthMethod) => { + await RemoveAuthMap[authMethod]({ + identityId: identity.id, + projectId: identity.projectId! + }); + + createNotification({ + text: "Successfully removed auth method", + type: "success" + }); + handlePopUpToggle("revokeAuthMethod", false); + }; + return ( <> - + Authentication Configure authentication methods {hasAuthMethods && @@ -65,7 +115,7 @@ export const ProjectIdentityAuthenticationSection = ({ identity, refetchIdentity > {(isAllowed) => ( {identity.authMethods.length > 0 ? ( - - - Method - - - - {identity.authMethods.map((authMethod) => ( - - handlePopUpOpen("viewAuthMethod", { - authMethod, - lockedOut: identity.activeLockoutAuthMethods?.includes(authMethod) ?? false, - refetchIdentity - }) - } - > - {identityAuthToNameMap[authMethod]} - -
- {identity.activeLockoutAuthMethods?.includes(authMethod) && ( - - - - - - )} - - - -
-
-
- ))} -
-
+ ) : ( @@ -175,13 +194,15 @@ export const ProjectIdentityAuthenticationSection = ({ identity, refetchIdentity text={(popUp.upgradePlan?.data as { description: string })?.description} isEnterpriseFeature={popUp.upgradePlan.data?.isEnterpriseFeature} /> - handlePopUpToggle("viewAuthMethod", isOpen)} - authMethod={popUp.viewAuthMethod.data?.authMethod} - lockedOut={popUp.viewAuthMethod.data?.lockedOut || false} - identityId={identity.id} - onResetAllLockouts={popUp.viewAuthMethod.data?.refetchIdentity} + handlePopUpToggle("revokeAuthMethod", isOpen)} + deleteKey="confirm" + buttonText="Remove" + onDeleteApproved={() => + handleDeleteAuthMethod(popUp.revokeAuthMethod.data as IdentityAuthMethod) + } /> ); diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx index a5a9e3488..f26dd60da 100644 --- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx +++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx @@ -12,7 +12,6 @@ import { DetailValue, OrgIcon, ProjectIcon, - UnstableButton, UnstableButtonGroup, UnstableCard, UnstableCardAction, @@ -44,8 +43,10 @@ export const ProjectIdentityDetailsSection = ({ identity, isOrgIdentity, members return ( <> - - + + Details Machine identity details {!isOrgIdentity && ( @@ -57,17 +58,16 @@ export const ProjectIdentityDetailsSection = ({ identity, isOrgIdentity, members })} > {(isAllowed) => ( - { handlePopUpOpen("editIdentity"); }} size="xs" - variant="project" + variant="outline" > - Edit Details - + )} @@ -92,6 +92,7 @@ export const ProjectIdentityDetailsSection = ({ identity, isOrgIdentity, members variant="ghost" size="xs" > + {/* TODO(scott): color this should be a button variant */} {isCopyingId ? : } @@ -118,9 +119,13 @@ export const ProjectIdentityDetailsSection = ({ identity, isOrgIdentity, members {identity?.metadata?.length ? ( identity.metadata?.map((el) => ( - - {el.key} - {el.value} + + + {el.key} + + + {el.value} + )) ) : (