Skip to content

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

merge main

Scott Wilson9002b2bf0865
diff --cc backend/src/services/membership-identity/membership-identity-service.ts
index 8f26a97080,3a092712b0..3ef21db8fa
--- a/backend/src/services/membership-identity/membership-identity-service.ts
+++ b/backend/src/services/membership-identity/membership-identity-service.ts
@@@ -1,9 -1,14 +1,15 @@@
import { Knex } from "knex";
- import { AccessScope, ProjectMembershipRole, TemporaryPermissionMode, TMembershipRolesInsert } from "@app/db/schemas";
+ import {
+ AccessScope,
+ ProjectMembershipRole,
+ RESOURCE_SCOPE,
+ TemporaryPermissionMode,
+ TMembershipRolesInsert
+ } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
+import { TKeyStoreFactory } from "@app/keystore/keystore";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { groupBy } from "@app/lib/fn";
import { ms } from "@app/lib/ms";
diff --cc frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx
index 4a5180705a,f5df800eaa..fc86436a5f
--- a/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx
@@@ -187,14 -182,9 +190,15 @@@ export const IdentityTab = withProjectP
"deleteIdentity",
"upgradePlan",
"addOptions",
- "identityAuthMethod"
++ "identityAuthMethod",
+ "assumePrivileges"
] as const);
+ const [viewAuthMethodState, setViewAuthMethodState] = useState<{
+ identityId: string;
+ authMethod: IdentityAuthMethod;
+ } | null>(null);
+
const onRemoveIdentitySubmit = async (identityId: string, isProjectIdentity: boolean) => {
if (isProjectIdentity) {
await deleteProjectIdentity({
@@@ -456,122 -444,81 +460,154 @@@
</Badge>
</TableCell>
<TableCell>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- variant="ghost"
- size="xs"
- onClick={(e) => e.stopPropagation()}
- >
- <MoreHorizontalIcon />
- </IconButton>
- </DropdownMenuTrigger>
- <DropdownMenuContent sideOffset={2} align="end">
- <ProjectPermissionCan
- I={ProjectPermissionIdentityActions.AssumePrivileges}
- a={subject(ProjectPermissionSub.Identity, {
- identityId: id
- })}
- >
- {(isAllowed) => (
- <Tooltip>
- <TooltipTrigger className="block w-full">
- <DropdownMenuItem
- isDisabled={!isAllowed}
- onClick={(evt) => {
- evt.stopPropagation();
- evt.preventDefault();
- handlePopUpOpen("assumePrivileges", {
- identityId: id
- });
- }}
+ <div className="flex items-center justify-end gap-2">
+ {(activeLockoutAuthMethods?.length ?? 0) > 0 && (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Badge isSquare variant="danger">
+ <LockIcon />
+ </Badge>
+ </TooltipTrigger>
+ <TooltipContent>
+ {`Locked out: ${(activeLockoutAuthMethods ?? [])
+ .map((m) => identityAuthToNameMap[m])
+ .join(", ")}`}
+ </TooltipContent>
+ </Tooltip>
+ )}
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ variant="ghost"
+ size="xs"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <MoreHorizontalIcon />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent sideOffset={2} align="end">
+ {identityProjectId && (
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger chevronOnLeft>
+ Manage Auth Methods
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent>
+ {(authMethods ?? []).map((method) => (
+ <DropdownMenuItem
+ key={method}
+ onClick={(evt) => {
+ evt.stopPropagation();
+ evt.preventDefault();
+ setViewAuthMethodState({
+ identityId: id,
+ authMethod: method
+ });
+ }}
+ >
+ {identityAuthToNameMap[method]}
+ {activeLockoutAuthMethods?.includes(method) && (
+ <Badge
+ isSquare
+ variant="danger"
+ className="ml-auto"
+ >
+ <LockIcon className="size-3!" />
+ </Badge>
+ )}
+ </DropdownMenuItem>
+ ))}
+ <ProjectPermissionCan
+ I={ProjectPermissionActions.Edit}
+ a={subject(ProjectPermissionSub.Identity, {
+ identityId: id
+ })}
>
- Assume Privileges
- {isAllowed && <InfoIcon className="text-muted" />}
- </DropdownMenuItem>
- </TooltipTrigger>
- {isAllowed && (
- <TooltipContent className="max-w-80" side="left">
- Assume the privileges of this machine identity,
- allowing you to replicate their access behavior.
- </TooltipContent>
- )}
- </Tooltip>
- )}
- </ProjectPermissionCan>
- <ProjectPermissionCan
- I={ProjectPermissionActions.Delete}
- a={subject(ProjectPermissionSub.Identity, {
- identityId: id
- })}
- >
- {(isAllowed) => (
- <DropdownMenuItem
- variant="danger"
- isDisabled={!isAllowed}
- onClick={(evt) => {
- evt.stopPropagation();
- evt.preventDefault();
- handlePopUpOpen("deleteIdentity", {
- identityId: id,
- name,
- isProjectIdentity: Boolean(identityProjectId)
- });
- }}
- >
- {identityProjectId ? <TrashIcon /> : <XIcon />}
- {/* eslint-disable-next-line no-nested-ternary */}
- {identityProjectId
- ? "Delete Machine Identity"
- : isCertManager
- ? "Remove From Certificate Manager"
- : "Remove From Project"}
- </DropdownMenuItem>
+ {(isAllowed) => (
+ <DropdownMenuItem
+ isDisabled={!isAllowed}
+ onClick={(evt) => {
+ evt.stopPropagation();
+ evt.preventDefault();
+ handlePopUpOpen("identityAuthMethod", {
+ identityId: id,
+ name,
+ allAuthMethods: authMethods ?? []
+ });
+ }}
+ >
+ <PlusIcon />
+ Add Auth Method
+ </DropdownMenuItem>
+ )}
+ </ProjectPermissionCan>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
)}
- </ProjectPermissionCan>
- </DropdownMenuContent>
- </DropdownMenu>
++ <ProjectPermissionCan
++ I={ProjectPermissionIdentityActions.AssumePrivileges}
++ a={subject(ProjectPermissionSub.Identity, {
++ identityId: id
++ })}
++ >
++ {(isAllowed) => (
++ <Tooltip>
++ <TooltipTrigger className="block w-full">
++ <DropdownMenuItem
++ isDisabled={!isAllowed}
++ onClick={(evt) => {
++ evt.stopPropagation();
++ evt.preventDefault();
++ handlePopUpOpen("assumePrivileges", {
++ identityId: id
++ });
++ }}
++ >
++ Assume Privileges
++ {isAllowed && <InfoIcon className="text-muted" />}
++ </DropdownMenuItem>
++ </TooltipTrigger>
++ {isAllowed && (
++ <TooltipContent className="max-w-80" side="left">
++ Assume the privileges of this machine identity,
++ allowing you to replicate their access behavior.
++ </TooltipContent>
++ )}
++ </Tooltip>
++ )}
++ </ProjectPermissionCan>
+ <ProjectPermissionCan
+ I={ProjectPermissionActions.Delete}
+ a={subject(ProjectPermissionSub.Identity, {
+ identityId: id
+ })}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ variant="danger"
+ isDisabled={!isAllowed}
+ onClick={(evt) => {
+ evt.stopPropagation();
+ evt.preventDefault();
+ handlePopUpOpen("deleteIdentity", {
+ identityId: id,
+ name,
+ isProjectIdentity: Boolean(identityProjectId)
+ });
+ }}
+ >
+ {identityProjectId ? <TrashIcon /> : <XIcon />}
+ {/* eslint-disable-next-line no-nested-ternary */}
+ {identityProjectId
+ ? "Delete Machine Identity"
+ : isCertManager
+ ? "Remove From Certificate Manager"
+ : "Remove From Project"}
+ </DropdownMenuItem>
+ )}
+ </ProjectPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
</TableCell>
</TableRow>
);
@@@ -689,36 -636,12 +725,42 @@@
)
}
/>
+ <IdentityAuthMethodModal
+ popUp={popUp}
+ handlePopUpOpen={handlePopUpOpen}
+ handlePopUpToggle={handlePopUpToggle}
+ />
+ {viewAuthMethodState &&
+ (() => {
+ const viewedIdentity = data?.identityMemberships?.find(
+ (m) => m.identity.id === viewAuthMethodState.identityId
+ )?.identity;
+ if (!viewedIdentity) return null;
+ return (
+ <IdentityAuthMethodSheet
+ open
+ onOpenChange={(open) => {
+ if (!open) setViewAuthMethodState(null);
+ }}
+ identityId={viewAuthMethodState.identityId}
+ identityName={viewedIdentity.name}
+ authMethod={viewAuthMethodState.authMethod}
+ allAuthMethods={viewedIdentity.authMethods ?? []}
+ isLockedOut={
+ viewedIdentity.activeLockoutAuthMethods?.includes(
+ viewAuthMethodState.authMethod
+ ) ?? false
+ }
+ onMutated={refetch}
+ />
+ );
+ })()}
+ <AssumePrivilegesModal
+ isOpen={popUp.assumePrivileges.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("assumePrivileges", isOpen)}
+ actorType={ActorType.IDENTITY}
+ actorId={(popUp.assumePrivileges.data as { identityId: string })?.identityId}
+ />
</>
);
},