Skip to content

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

feat; add mi to pam access

Sheen Capadngan963298376081
diff --git a/backend/src/db/migrations/20260803120000_add-pam-session-identity-id.ts b/backend/src/db/migrations/20260803120000_add-pam-session-identity-id.ts
new file mode 100644
index 0000000000..11a664f1ef
--- /dev/null
+++ b/backend/src/db/migrations/20260803120000_add-pam-session-identity-id.ts
@@ -0,0 +1,28 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+// Sessions launched by machine identities need a machine-readable actor link, mirroring userId.
+// SET NULL keeps session history alive after identity deletion (actorName carries the display name).
+export async function up(knex: Knex): Promise<void> {
+ const hasColumn = await knex.schema.hasColumn(TableName.PamSession, "identityId");
+ if (!hasColumn) {
+ await knex.schema.alterTable(TableName.PamSession, (t) => {
+ t.uuid("identityId").nullable();
+ t.foreign("identityId").references("id").inTable(TableName.Identity).onDelete("SET NULL");
+ // FK columns must be indexed (Postgres does not auto-index them); partial since most sessions are user-launched
+ t.index("identityId", "pam_sessions_identityid_index", {
+ predicate: knex.whereNotNull("identityId")
+ });
+ });
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ const hasColumn = await knex.schema.hasColumn(TableName.PamSession, "identityId");
+ if (hasColumn) {
+ await knex.schema.alterTable(TableName.PamSession, (t) => {
+ t.dropColumn("identityId");
+ });
+ }
+}
diff --git a/backend/src/db/schemas/pam-sessions.ts b/backend/src/db/schemas/pam-sessions.ts
index 7d6ac6e9b6..e5a95be38f 100644
--- a/backend/src/db/schemas/pam-sessions.ts
+++ b/backend/src/db/schemas/pam-sessions.ts
@@ -39,7 +39,8 @@ export const PamSessionsSchema = z.object({
gatewayUploadTokenHash: zodBuffer.nullable().optional(),
gatewayId: z.string().uuid().nullable().optional(),
folderName: z.string().nullable().optional(),
- selectedHost: z.string().nullable().optional()
+ selectedHost: z.string().nullable().optional(),
+ identityId: z.string().uuid().nullable().optional()
});
export type TPamSessions = z.infer<typeof PamSessionsSchema>;
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-membership-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-membership-router.ts
index 3f6cd6cb96..2cf822dc1b 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-membership-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-membership-router.ts
@@ -331,13 +331,23 @@ export const registerPamProductMembershipRouter = async (server: FastifyZodProvi
operationId: "listPamProductIdentityMembers",
description: "List identity members of the PAM product",
tags: [ApiDocsTags.PamMemberships],
- response: { 200: z.object({ members: z.array(MemberSchema) }) }
+ response: {
+ 200: z.object({
+ members: z.array(
+ MemberSchema.extend({
+ name: z.string(),
+ identityProjectId: z.string().uuid().nullable().optional(),
+ identityOrgId: z.string().uuid().nullable().optional()
+ })
+ )
+ })
+ }
},
config: { rateLimit: readLimit },
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const all = await server.services.pamMembership.listProductMembers(actorCtx(req));
- return { members: all.filter((m) => m.identityId) };
+ const members = await server.services.pamMembership.listProductIdentityMembers(actorCtx(req));
+ return { members };
}
});
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
index 5b5695481e..c956af28f1 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
@@ -22,6 +22,7 @@ const SanitizedSessionSchema = PamSessionsSchema.pick({
accountType: true,
accountName: true,
userId: true,
+ identityId: true,
actorName: true,
actorEmail: true,
actorIp: true,
@@ -340,10 +341,17 @@ export const registerPamWebAccessRouter = async (server: FastifyZodProvider) =>
})
}
},
- onRequest: verifyAuth([AuthMode.JWT]),
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- if (req.auth.authMode !== AuthMode.JWT) {
- throw new BadRequestError({ message: "Account access requires JWT authentication" });
+ let actorEmail = "";
+ let actorName = "";
+ if (req.auth.authMode === AuthMode.JWT) {
+ actorEmail = req.auth.user.email ?? "";
+ actorName = `${req.auth.user.firstName ?? ""} ${req.auth.user.lastName ?? ""}`.trim();
+ } else if (req.auth.authMode === AuthMode.IDENTITY_ACCESS_TOKEN) {
+ actorName = req.auth.identityName;
+ } else {
+ throw new BadRequestError({ message: "Account access requires user or machine identity authentication" });
}
const result = await server.services.pamSession.access({
@@ -355,8 +363,8 @@ export const registerPamWebAccessRouter = async (server: FastifyZodProvider) =>
actorOrgId: req.permission.orgId,
actorAuthMethod: req.permission.authMethod
},
- actorEmail: req.auth.user.email ?? "",
- actorName: `${req.auth.user.firstName ?? ""} ${req.auth.user.lastName ?? ""}`.trim(),
+ actorEmail,
+ actorName,
actorIp: req.realIp ?? "",
actorUserAgent: req.headers["user-agent"] ?? "",
reason: req.body.reason,
diff --git a/backend/src/ee/services/pam-membership/pam-membership-service.ts b/backend/src/ee/services/pam-membership/pam-membership-service.ts
index 260d6f2a19..3b99334e6b 100644
--- a/backend/src/ee/services/pam-membership/pam-membership-service.ts
+++ b/backend/src/ee/services/pam-membership/pam-membership-service.ts
@@ -52,7 +52,7 @@ type TPamMembershipServiceFactoryDep = {
pamAccountDAL: Pick<TPamAccountDALFactory, "findById">;
userDAL: Pick<TUserDALFactory, "findById" | "find">;
groupDAL: Pick<TGroupDALFactory, "findById">;
- identityDAL: Pick<TIdentityDALFactory, "findById">;
+ identityDAL: Pick<TIdentityDALFactory, "findById" | "find">;
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission">;
usageMeteringService: Pick<TUsageMeteringServiceFactory, "emitForProject">;
};
@@ -168,7 +168,8 @@ export const pamMembershipServiceFactory = ({
const validateActorExists = async (
dto: { userId?: string; groupId?: string; identityId?: string },
- orgId: string
+ orgId: string,
+ projectId: string
) => {
const { column, id, kind } = resolveActorColumn(dto);
@@ -192,8 +193,12 @@ export const pamMembershipServiceFactory = ({
} else {
const identity = await identityDAL.findById(id);
if (!identity) throw new NotFoundError({ message: `Identity with ID '${id}' not found` });
- if (identity.projectId) {
- throw new BadRequestError({ message: "Project-scoped identities cannot be added as PAM members" });
+ // Identities scoped to the PAM project itself are first-class PAM members (created in-product);
+ // identities scoped to any other project stay rejected.
+ if (identity.projectId && identity.projectId !== projectId) {
+ throw new BadRequestError({
+ message: "Identities scoped to another project cannot be added as PAM members"
+ });
}
const orgMemberships = await membershipDAL.find({
@@ -271,6 +276,37 @@ export const pamMembershipServiceFactory = ({
return resolveMemberships(memberships, PamProductRole.Member);
};
+ // Identity members enriched with the identity's name and scope, so the PAM UI never has to
+ // join against org- or project-level identity endpoints (the org list excludes PAM-scoped identities).
+ const listProductIdentityMembers = async ({ projectId, ...ctx }: TListPamProductMembersDTO & TActorContext) => {
+ await permissionService.getProjectPermission({
+ actor: ctx.actor,
+ actorId: ctx.actorId,
+ projectId,
+ actorAuthMethod: ctx.actorAuthMethod,
+ actorOrgId: ctx.actorOrgId,
+ actionProjectType: ActionProjectType.PAM
+ });
+
+ const memberships = await membershipDAL.find({ scope: AccessScope.Project, scopeProjectId: projectId });
+ const identityMemberships = memberships.filter((m) => m.actorIdentityId);
+ const resolved = await resolveMemberships(identityMemberships, PamProductRole.Member);
+
+ const identityIds = identityMemberships.map((m) => m.actorIdentityId).filter((v): v is string => Boolean(v));
+ const identities = identityIds.length ? await identityDAL.find({ $in: { id: identityIds } }) : [];
+ const identityById = new Map(identities.map((i) => [i.id, i]));
+
+ return resolved.map((m) => {
+ const identity = m.identityId ? identityById.get(m.identityId) : undefined;
+ return {
+ ...m,
+ name: identity?.name ?? "",
+ identityProjectId: identity?.projectId ?? null,
+ identityOrgId: identity?.orgId ?? null
+ };
+ });
+ };
+
const addProductMember = async ({ projectId, role, ...dto }: TAddPamProductMemberDTO & TActorContext) => {
await checkProductAdmin(projectId, dto);
@@ -280,7 +316,7 @@ export const pamMembershipServiceFactory = ({
});
}
- const { column, id, kind } = await validateActorExists(dto, dto.actorOrgId);
+ const { column, id, kind } = await validateActorExists(dto, dto.actorOrgId, projectId);
const result = await membershipDAL.transaction(async (tx) => {
const existing = await membershipDAL.find(
@@ -503,6 +539,17 @@ export const pamMembershipServiceFactory = ({
const { column, id, kind } = resolveActorColumn(dto);
+ // A PAM-scoped identity's product membership IS its reason to exist; removing just the
+ // membership would orphan it. Delete the identity itself instead.
+ if (kind === PamMemberKind.Identity) {
+ const identity = await identityDAL.findById(id);
+ if (identity?.projectId === projectId) {
+ throw new BadRequestError({
+ message: "This identity is managed by PAM. Delete the identity instead of removing its membership."
+ });
+ }
+ }
+
const result = await membershipDAL.transaction(async (tx) => {
const [membership] = await membershipDAL.find(
{ scope: AccessScope.Project, scopeProjectId: projectId, [column]: id },
@@ -586,7 +633,7 @@ export const pamMembershipServiceFactory = ({
throw new BadRequestError({ message: `Invalid expiry duration '${expiry}'` });
}
- const { column, id, kind } = await validateActorExists(dto, dto.actorOrgId);
+ const { column, id, kind } = await validateActorExists(dto, dto.actorOrgId, projectId);
await validateProductMember(projectId, dto);
return membershipDAL.transaction(async (tx) => {
@@ -908,6 +955,7 @@ export const pamMembershipServiceFactory = ({
return {
listProductMembers,
+ listProductIdentityMembers,
addProductMember,
addProductUserMembers,
updateProductMemberRole,
diff --git a/backend/src/ee/services/pam-session/pam-session-fns.ts b/backend/src/ee/services/pam-session/pam-session-fns.ts
index fa50f2c34a..ae7cd893c4 100644
--- a/backend/src/ee/services/pam-session/pam-session-fns.ts
+++ b/backend/src/ee/services/pam-session/pam-session-fns.ts
@@ -15,14 +15,15 @@ export const resolvePamSessionDistinctId = async ({
session,
userDAL
}: {
- session: { actorEmail: string; userId?: string | null };
+ session: { actorEmail: string; actorName?: string | null; userId?: string | null };
userDAL: Pick<TUserDALFactory, "findById">;
}) => {
if (session.userId) {
const user = await userDAL.findById(session.userId);
if (user?.username) return user.username;
}
- return session.actorEmail;
+ // Machine identity sessions have no email; fall back to the identity name
+ return session.actorEmail || session.actorName || "unknown";
};
export const reportPamSessionEnded = async ({
diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.ts
index 482d614bbd..6d5b3cc453 100644
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@ -8,6 +8,7 @@ import { SshCertType } from "@app/ee/services/ssh/ssh-certificate-authority-type
import { SshCertKeyAlgorithm } from "@app/ee/services/ssh-certificate/ssh-certificate-types";
import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
import { ms } from "@app/lib/ms";
+import { alphaNumericNanoId } from "@app/lib/nanoid";
import { ActorType } from "@app/services/auth/auth-type";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "@app/services/kms/kms-types";
@@ -425,6 +426,10 @@ export const pamSessionServiceFactory = ({
}) => {
const account = await resolveAccountByPath(projectId, path);
+ // Machine identities launch sessions via identity access tokens; human-only controls
+ // (MFA, access-request approval) cannot be satisfied by them and are rejected explicitly below.
+ const isUserActor = actor.actor === ActorType.USER;
+
const policy = resolveAccessControls(account.templatePolicies);
const { requiresApproval } = policy;
@@ -441,6 +446,12 @@ export const pamSessionServiceFactory = ({
const trimmedReason = reason?.trim() || null;
if (policy.requireMfa) {
+ if (!isUserActor) {
+ throw new ForbiddenRequestError({
+ message:
+ "This account requires MFA verification, which machine identities cannot perform. Remove the MFA policy from the account's template to allow machine identity access."
+ });
+ }
await enforceMfa(
{ mfaSessionService, orgDAL, userDAL },
{ userId: actor.actorId, orgId: actor.actorOrgId, actorEmail, accountId: account.id, mfaSessionId }
@@ -464,6 +475,12 @@ export const pamSessionServiceFactory = ({
// guided into requesting access (where the request reason is collected) rather than being
// blocked on a launch reason for a session they cannot start yet.
if (requiresApproval) {
+ if (!isUserActor) {
+ throw new ForbiddenRequestError({
+ message:
+ "This account is gated behind access-request approval, which machine identities cannot request. Grant the identity access to a non-gated account instead."
+ });
+ }
const grant = await pamAccessRequestService.checkGrant({
userId: actor.actorId,
accountId: account.id,
@@ -521,12 +538,23 @@ export const pamSessionServiceFactory = ({
const rawConnectionDetails = await decrypt(projectId, account.encryptedConnectionDetails);
const roleArn = rawConnectionDetails.roleArn as string;
+ // Machine identities have no email; fall back to the identity name for STS attribution.
+ const federatedUsername = actorEmail || actorName;
+
+ // STS requires roleSessionName to be 2-64 chars; pad short names with random characters
+ // so the actor's name stays recognizable in CloudTrail (1-char identity name, user with
+ // no email and empty names)
+ let roleSessionName = federatedUsername.replace(new RE2(/[^\w+=,.@-]/g), "_").substring(0, 64);
+ if (roleSessionName.length < 2) {
+ roleSessionName = `${roleSessionName}${alphaNumericNanoId(8)}`;
+ }
+
const stsCredentials = await generateAwsIamSessionCredentials({
roleArn,
// PAM is one project per org, so the actor's org owns this account. We use the org ID as the
// STS External ID so the customer's role trust policy scopes assumption to this Infisical org.
externalId: actor.actorOrgId,
- roleSessionName: actorEmail.replace(new RE2(/[^\w+=,.@-]/g), "_").substring(0, 64),
+ roleSessionName,
sessionDuration: stsDurationSeconds
});
@@ -547,7 +575,7 @@ export const pamSessionServiceFactory = ({
metadata.sessionToken = stsCredentials.sessionToken;
metadata.expiresAt = expiresAt.toISOString();
metadata.roleArn = roleArn;
- metadata.federatedUsername = actorEmail;
+ metadata.federatedUsername = federatedUsername;
const awsAccountId = extractAwsAccountIdFromArn(roleArn);
if (awsAccountId) {
@@ -568,7 +596,9 @@ export const pamSessionServiceFactory = ({
actorUserAgent,
projectId,
accountId: account.id,
- userId: actor.actorId,
+ // userId FKs users and identityId FKs identities; exactly one is set based on the actor type
+ userId: isUserActor ? actor.actorId : null,
+ identityId: isUserActor ? null : actor.actorId,
reason: trimmedReason,
folderName: account.folderName
});
@@ -604,7 +634,7 @@ export const pamSessionServiceFactory = ({
resolveSelectedHost(account.accountType as PamAccountType, rawConnectionDetails, targetHost) ??
gatewayTarget.host;
- const user = await userDAL.findById(actor.actorId);
+ const user = isUserActor ? await userDAL.findById(actor.actorId) : null;
const expiresAt = new Date(Date.now() + sessionDurationMs);
const session = await pamSessionDAL.create({
@@ -619,7 +649,9 @@ export const pamSessionServiceFactory = ({
actorUserAgent,
projectId,
accountId: account.id,
- userId: actor.actorId,
+ // userId FKs users and identityId FKs identities; exactly one is set based on the actor type
+ userId: isUserActor ? actor.actorId : null,
+ identityId: isUserActor ? null : actor.actorId,
gatewayId: effectiveGatewayId,
reason: trimmedReason,
folderName: account.folderName,
@@ -638,8 +670,8 @@ export const pamSessionServiceFactory = ({
duration: sessionDurationMs,
actorMetadata: {
id: actor.actorId,
- type: ActorType.USER,
- name: user?.email ?? ""
+ type: actor.actor,
+ name: user?.email ?? actorName
}
});
diff --git a/backend/src/ee/services/pam/CLAUDE.md b/backend/src/ee/services/pam/CLAUDE.md
index 17a8884e36..40684ed69c 100644
--- a/backend/src/ee/services/pam/CLAUDE.md
+++ b/backend/src/ee/services/pam/CLAUDE.md
@@ -44,8 +44,9 @@ Gotchas:
product-level bucket and is hidden from resource viewers.
- Gated accounts (`requiresApproval`) require `LaunchSessions` **and** a valid approval grant, enforced in
both the session and web-access services.
-- PAM endpoints accept JWT + identity tokens; session launch/web-access are JWT-only; gateway-facing
- endpoints use `AuthMode.GATEWAY_ACCESS_TOKEN`.
+- PAM endpoints accept JWT + identity tokens, including CLI session launch (`POST /pam/sessions/access`);
+ web access stays JWT-only, and MFA/approval-gated accounts reject machine actors. Sessions store
+ `identityId` (not `userId`) for machine actors. Gateway-facing endpoints use `AuthMode.GATEWAY_ACCESS_TOKEN`.
## PAM Project (consolidated + lazy)
diff --git a/backend/src/services/identity-v2/identity-service.ts b/backend/src/services/identity-v2/identity-service.ts
index cc48356d98..0a624c8fa2 100644
--- a/backend/src/services/identity-v2/identity-service.ts
+++ b/backend/src/services/identity-v2/identity-service.ts
@@ -142,12 +142,14 @@ export const identityV2ServiceFactory = ({
const project = await requestMemoize(requestMemoKeys.projectFindById(scopeData.projectId), () =>
projectDAL.findById(scopeData.projectId)
);
- if (project?.type === ProjectType.CertificateManager) {
+ if (project?.type === ProjectType.CertificateManager || project?.type === ProjectType.PAM) {
const invalidRoles = data.roles.filter(
(r) => r.role !== ProjectMembershipRole.Admin && r.role !== ProjectMembershipRole.Member
);
if (invalidRoles.length > 0) {
- throw new BadRequestError({ message: "Certificate Manager only supports Admin and Member roles." });
+ throw new BadRequestError({
+ message: `${project.type === ProjectType.PAM ? "PAM" : "Certificate Manager"} only supports Admin and Member roles.`
+ });
}
}
@@ -232,7 +234,8 @@ export const identityV2ServiceFactory = ({
let projectMemberRole = ProjectMembershipRole.NoAccess as string;
if (scopeData.scope === AccessScope.Project && !resolvedRoleDocs) {
const project = await projectDAL.findById(scopeData.projectId);
- if (project?.type === ProjectType.CertificateManager) {
+ // PAM's project membership IS its product membership, so NoAccess would be meaningless there
+ if (project?.type === ProjectType.CertificateManager || project?.type === ProjectType.PAM) {
projectMemberRole = ProjectMembershipRole.Member;
}
}
diff --git a/frontend/src/hooks/api/identities/constants.tsx b/frontend/src/hooks/api/identities/constants.tsx
index 66338f538a..37885db451 100644
--- a/frontend/src/hooks/api/identities/constants.tsx
+++ b/frontend/src/hooks/api/identities/constants.tsx
@@ -1,5 +1,19 @@
import { IdentityAuthMethod } from "./enums";
+// Sensible Universal Auth defaults used by in-product identity creation flows (Cert Manager, PAM)
+export const UNIVERSAL_AUTH_DEFAULTS = {
+ clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
+ accessTokenTTL: 2592000,
+ accessTokenMaxTTL: 2592000,
+ accessTokenNumUsesLimit: 0,
+ accessTokenPeriod: 0,
+ lockoutEnabled: true,
+ lockoutThreshold: 3,
+ lockoutDurationSeconds: 300,
+ lockoutCounterResetSeconds: 30
+};
+
export const identityAuthToNameMap: { [I in IdentityAuthMethod]: string } = {
[IdentityAuthMethod.TOKEN_AUTH]: "Token Auth",
[IdentityAuthMethod.UNIVERSAL_AUTH]: "Universal Auth",
diff --git a/frontend/src/hooks/api/identities/index.tsx b/frontend/src/hooks/api/identities/index.tsx
index 70d4541384..c731cb7c39 100644
--- a/frontend/src/hooks/api/identities/index.tsx
+++ b/frontend/src/hooks/api/identities/index.tsx
@@ -1,4 +1,4 @@
-export { identityAuthToNameMap } from "./constants";
+export { identityAuthToNameMap, UNIVERSAL_AUTH_DEFAULTS } from "./constants";
export { IdentityAuthMethod } from "./enums";
export * from "./mutations";
export * from "./queries";
diff --git a/frontend/src/hooks/api/pam/queries.tsx b/frontend/src/hooks/api/pam/queries.tsx
index 4b29b1bb45..60a96960d1 100644
--- a/frontend/src/hooks/api/pam/queries.tsx
+++ b/frontend/src/hooks/api/pam/queries.tsx
@@ -35,6 +35,7 @@ import {
TPamDiscoverySource,
TPamDiscoveryTypeOption,
TPamFolderWithCount,
+ TPamIdentityMember,
TPamMember,
TPamMembersData,
TPamResourceRole,
@@ -442,7 +443,7 @@ export const useListPamProductIdentities = () => {
return useQuery({
queryKey: pamKeys.productIdentities(),
queryFn: async () => {
- const { data } = await apiRequest.get<{ members: TPamMember[] }>(
+ const { data } = await apiRequest.get<{ members: TPamIdentityMember[] }>(
"/api/v1/pam/memberships/identities"
);
return data.members;
diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.ts
index b575d3fab7..d8be4da56e 100644
--- a/frontend/src/hooks/api/pam/types/index.ts
+++ b/frontend/src/hooks/api/pam/types/index.ts
@@ -285,6 +285,7 @@ export type TPamSession = {
selectedHost?: string | null;
accessMethod?: string | null;
userId?: string | null;
+ identityId?: string | null;
actorName: string;
actorEmail: string;
actorIp: string;
@@ -436,6 +437,13 @@ export type TPamMember = {
createdAt: string;
};
+// Identity members come back enriched with the identity's name and scope
+export type TPamIdentityMember = TPamMember & {
+ name: string;
+ identityProjectId?: string | null;
+ identityOrgId?: string | null;
+};
+
export type TPamResourceRole = {
slug: string;
name: string;
diff --git a/frontend/src/hooks/api/projectIdentity/mutations.tsx b/frontend/src/hooks/api/projectIdentity/mutations.tsx
index 00a0eb0013..379f7065bd 100644
--- a/frontend/src/hooks/api/projectIdentity/mutations.tsx
+++ b/frontend/src/hooks/api/projectIdentity/mutations.tsx
@@ -22,9 +22,12 @@ export const useCreateProjectIdentity = () => {
);
return data.identity;
},
- onSuccess: () => {
+ onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({ queryKey: projectIdentityQuery.allKey() });
queryClient.invalidateQueries({ queryKey: identitiesKeys.searchIdentitiesRoot });
+ queryClient.invalidateQueries({
+ queryKey: projectKeys.getProjectIdentityMemberships(projectId)
+ });
queryClient.invalidateQueries({
queryKey: subscriptionQueryKeys.all()
});
diff --git a/frontend/src/hooks/api/projectIdentity/types.ts b/frontend/src/hooks/api/projectIdentity/types.ts
index 3e67003910..ec57accd7b 100644
--- a/frontend/src/hooks/api/projectIdentity/types.ts
+++ b/frontend/src/hooks/api/projectIdentity/types.ts
@@ -13,6 +13,7 @@ export type TCreateProjectIdentityDTO = {
name: string;
hasDeleteProtection?: boolean;
metadata?: TMetadata[];
+ roles?: { role: string }[];
};
export type TUpdateProjectIdentityDTO = {
diff --git a/frontend/src/pages/pam/PamAccessControlPage/components/AddIdentityModal.tsx b/frontend/src/pages/pam/PamAccessControlPage/components/AddIdentityModal.tsx
index 89154b5c70..ef5aa25791 100644
--- a/frontend/src/pages/pam/PamAccessControlPage/components/AddIdentityModal.tsx
+++ b/frontend/src/pages/pam/PamAccessControlPage/components/AddIdentityModal.tsx
@@ -1,6 +1,6 @@
import { useMemo, useState } from "react";
+import { useQueryClient } from "@tanstack/react-query";
import { useNavigate } from "@tanstack/react-router";
-import { ExternalLink } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import {
@@ -13,16 +13,31 @@ import {
DialogTitle,
Field,
FieldLabel,
- FilterableSelect
+ FilterableSelect,
+ Input,
+ Tabs,
+ TabsList,
+ TabsTrigger
} from "@app/components/v3";
import { useOrganization, useProject } from "@app/context";
-import { useGetIdentityMembershipOrgs, useListProjectIdentityMemberships } from "@app/hooks/api";
+import { useGetIdentityMembershipOrgs } from "@app/hooks/api";
+import { UNIVERSAL_AUTH_DEFAULTS, useAddIdentityUniversalAuth } from "@app/hooks/api/identities";
import { IdentityMembershipOrg } from "@app/hooks/api/identities/types";
-import { useAddPamProductIdentityMember } from "@app/hooks/api/pam";
+import {
+ pamKeys,
+ useAddPamProductIdentityMember,
+ useListPamProductIdentities
+} from "@app/hooks/api/pam";
+import { useCreateProjectIdentity } from "@app/hooks/api/projectIdentity";
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
import { ProductRoleOptionList } from "./ProductRoleOptionList";
+enum AddIdentityMode {
+ Create = "create",
+ Assign = "assign"
+}
+
type Props = {
isOpen: boolean;
onOpenChange: (open: boolean) => void;
@@ -32,36 +47,84 @@ export const AddIdentityModal = ({ isOpen, onOpenChange }: Props) => {
const { currentOrg } = useOrganization();
const { currentProject } = useProject();
const navigate = useNavigate();
- const { mutate: addIdentity, isPending } = useAddPamProductIdentityMember();
+ const queryClient = useQueryClient();
+
+ const { mutate: addIdentity, isPending: isAssigning } = useAddPamProductIdentityMember();
+ const { mutate: createProjectIdentity, isPending: isCreating } = useCreateProjectIdentity();
+ const { mutate: addUniversalAuth, isPending: isAttachingAuth } = useAddIdentityUniversalAuth();
+ const [mode, setMode] = useState<AddIdentityMode>(AddIdentityMode.Create);
+ const [name, setName] = useState("");
const [selectedIdentity, setSelectedIdentity] = useState<IdentityMembershipOrg | null>(null);
const [selectedRole, setSelectedRole] = useState<string>(ProjectMembershipRole.Member);
+ const isSubmitting = isAssigning || isCreating || isAttachingAuth;
+
const { data: orgIdentitiesData } = useGetIdentityMembershipOrgs({
organizationId: currentOrg.id,
limit: 1000
});
- const { data: projectIdentitiesData } = useListProjectIdentityMemberships({
- projectId: currentProject.id,
- projectType: currentProject.type
- });
+ const { data: productIdentities } = useListPamProductIdentities();
const availableIdentities = useMemo(() => {
- const assignedIds = new Set(
- (projectIdentitiesData?.identityMemberships || []).map((m) => m.identity.id)
- );
+ const assignedIds = new Set((productIdentities ?? []).map((m) => m.identityId).filter(Boolean));
return (orgIdentitiesData?.identityMemberships || []).filter(
(m) => !assignedIds.has(m.identity.id)
);
- }, [orgIdentitiesData, projectIdentitiesData]);
+ }, [orgIdentitiesData, productIdentities]);
const handleClose = () => {
+ setMode(AddIdentityMode.Create);
+ setName("");
setSelectedIdentity(null);
setSelectedRole(ProjectMembershipRole.Member);
onOpenChange(false);
};
- const handleSubmit = () => {
+ // Once creation succeeds the identity and its PAM membership already exist, so land on the
+ // identity page whether or not auth attached, rather than leaving the user to re-create.
+ const finishCreate = (identityId: string, authAttached: boolean) => {
+ // The generic create mutation doesn't know about PAM's member list
+ queryClient.invalidateQueries({ queryKey: pamKeys.productIdentities() });
+
+ createNotification(
+ authAttached
+ ? { text: "Machine identity created", type: "success" }
+ : {
+ text: "Machine identity created, but attaching Universal Auth failed. Add an auth method from the identity page.",
+ type: "error"
+ }
+ );
+ handleClose();
+ navigate({
+ to: "/organizations/$orgId/pam/identities/$identityId",
+ params: { orgId: currentOrg.id, identityId }
+ });
+ };
+
+ const handleCreate = () => {
+ createProjectIdentity(
+ {
+ name: name.trim(),
+ projectId: currentProject.id,
+ hasDeleteProtection: true,
+ roles: [{ role: selectedRole }]
+ },
+ {
+ onSuccess: (created) => {
+ addUniversalAuth(
+ { projectId: currentProject.id, identityId: created.id, ...UNIVERSAL_AUTH_DEFAULTS },
+ {
+ onSuccess: () => finishCreate(created.id, true),
+ onError: () => finishCreate(created.id, false)
+ }
+ );
+ }
+ }
+ );
+ };
+
+ const handleAssign = () => {
if (!selectedIdentity) return;
addIdentity(
@@ -79,16 +142,65 @@ export const AddIdentityModal = ({ isOpen, onOpenChange }: Props) => {
);
};
+ const handleSubmit = () => {
+ if (mode === AddIdentityMode.Create) {
+ handleCreate();
+ } else {
+ handleAssign();
+ }
+ };
+
+ const isSubmitDisabled = mode === AddIdentityMode.Create ? !name.trim() : !selectedIdentity;
+
return (
<Dialog open={isOpen} onOpenChange={onOpenChange}>
<DialogContent className="overflow-visible sm:max-w-xl">
<DialogHeader>
- <DialogTitle>Add Identity</DialogTitle>
- <DialogDescription>Add an existing organization identity.</DialogDescription>
+ <DialogTitle>Add Machine Identity</DialogTitle>
+ <DialogDescription>
+ Create a new machine identity or assign an existing organization identity.
+ </DialogDescription>
</DialogHeader>
- {availableIdentities.length ? (
- <div className="flex flex-col gap-5">
+ <div className="flex flex-col gap-5">
+ <div className="flex flex-col gap-2">
+ <Tabs
+ className="w-full"
+ value={mode}
+ onValueChange={(next) => {
+ setMode(next as AddIdentityMode);
+ if (next === AddIdentityMode.Create) {
+ setSelectedIdentity(null);
+ } else {
+ setName("");
+ }
+ }}
+ >
+ <TabsList className="w-full">
+ <TabsTrigger value={AddIdentityMode.Create}>Create New</TabsTrigger>
+ <TabsTrigger value={AddIdentityMode.Assign}>Assign Existing</TabsTrigger>
+ </TabsList>
+ </Tabs>
+ <p className="text-sm text-muted">
+ {mode === AddIdentityMode.Create
+ ? "Create a dedicated machine identity managed at the PAM level."
+ : "Reuse an existing machine identity from your organization."}
+ </p>
+ </div>
+
+ {mode === AddIdentityMode.Create ? (
+ <Field>
+ <FieldLabel>
+ Name <span className="text-product-pam">*</span>
+ </FieldLabel>
+ <Input
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ autoFocus
+ placeholder="Machine 1"
+ />
+ </Field>
+ ) : (
<Field>
<FieldLabel>
Identity <span className="text-product-pam">*</span>
@@ -102,53 +214,29 @@ export const AddIdentityModal = ({ isOpen, onOpenChange }: Props) => {
placeholder="Select identity..."
/>
</Field>
+ )}
- <Field>
- <FieldLabel>
- Product role <span className="text-product-pam">*</span>
- </FieldLabel>
- <ProductRoleOptionList value={selectedRole} onChange={setSelectedRole} />
- </Field>
- </div>
- ) : (
- <div className="flex flex-col gap-4">
- <p className="text-sm text-muted">
- All organization identities have already been added. Create a new identity at the
- organization level first.
- </p>
- <Button
- variant="pam"
- className="self-end"
- onClick={() => {
- handleClose();
- navigate({
- to: "/organizations/$orgId/access-management" as never,
- params: { orgId: currentOrg.id } as never,
- search: { selectedTab: "identities" } as never
- });
- }}
- >
- <ExternalLink />
- Go to organization identities
- </Button>
- </div>
- )}
-
- {availableIdentities.length > 0 && (
- <DialogFooter>
- <Button variant="outline" onClick={handleClose}>
- Cancel
- </Button>
- <Button
- variant="pam"
- isDisabled={!selectedIdentity}
- isPending={isPending}
- onClick={handleSubmit}
- >
- Add Identity
- </Button>
- </DialogFooter>
- )}
+ <Field>
+ <FieldLabel>
+ Product role <span className="text-product-pam">*</span>
+ </FieldLabel>
+ <ProductRoleOptionList value={selectedRole} onChange={setSelectedRole} />
+ </Field>
+ </div>
+
+ <DialogFooter>
+ <Button variant="outline" onClick={handleClose}>
+ Cancel
+ </Button>
+ <Button
+ variant="pam"
+ isDisabled={isSubmitDisabled || isSubmitting}
+ isPending={isSubmitting}
+ onClick={handleSubmit}
+ >
+ {mode === AddIdentityMode.Create ? "Create Identity" : "Add Identity"}
+ </Button>
+ </DialogFooter>
</DialogContent>
</Dialog>
);
diff --git a/frontend/src/pages/pam/PamAccessControlPage/components/IdentitiesTab.tsx b/frontend/src/pages/pam/PamAccessControlPage/components/IdentitiesTab.tsx
index 304ad6101e..b71de75a43 100644
--- a/frontend/src/pages/pam/PamAccessControlPage/components/IdentitiesTab.tsx
+++ b/frontend/src/pages/pam/PamAccessControlPage/components/IdentitiesTab.tsx
@@ -1,4 +1,6 @@
import { useMemo, useState } from "react";
+import { useQueryClient } from "@tanstack/react-query";
+import { useNavigate } from "@tanstack/react-router";
import { format } from "date-fns";
import { MoreHorizontalIcon, PencilIcon, Plus, SearchIcon, Trash2Icon } from "lucide-react";
@@ -24,7 +26,10 @@ import {
InputGroup,
InputGroupAddon,
InputGroupInput,
+ OrgIcon,
+ ProjectIcon,
Skeleton,
+ SubOrgIcon,
Table,
TableBody,
TableCell,
@@ -32,11 +37,20 @@ import {
TableHeader,
TableRow
} from "@app/components/v3";
-import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
+import {
+ ProjectPermissionActions,
+ ProjectPermissionSub,
+ useOrganization,
+ useProject
+} from "@app/context";
import { formatProjectRoleName } from "@app/helpers/roles";
-import { useListProjectIdentityMemberships } from "@app/hooks/api";
-import { IdentityProjectMembershipV2 } from "@app/hooks/api/identities/types";
-import { useRemovePamProductIdentityMember } from "@app/hooks/api/pam";
+import {
+ pamKeys,
+ useListPamProductIdentities,
+ useRemovePamProductIdentityMember
+} from "@app/hooks/api/pam";
+import { TPamIdentityMember } from "@app/hooks/api/pam/types";
+import { useDeleteProjectIdentity } from "@app/hooks/api/projectIdentity";
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
import { AddIdentityModal } from "./AddIdentityModal";
@@ -44,38 +58,74 @@ import { IdentityRoleModal } from "./IdentityRoleModal";
export const IdentitiesTab = () => {
const { currentProject } = useProject();
+ const { currentOrg, isSubOrganization } = useOrganization();
+ const navigate = useNavigate();
+ const queryClient = useQueryClient();
const [search, setSearch] = useState("");
const [isAddIdentityOpen, setIsAddIdentityOpen] = useState(false);
- const [selectedIdentity, setSelectedIdentity] = useState<IdentityProjectMembershipV2 | null>(
- null
- );
- const [identityToRemove, setIdentityToRemove] = useState<IdentityProjectMembershipV2 | null>(
- null
- );
+ const [selectedIdentity, setSelectedIdentity] = useState<TPamIdentityMember | null>(null);
+ const [identityToRemove, setIdentityToRemove] = useState<TPamIdentityMember | null>(null);
- const { data: identitiesData, isPending } = useListProjectIdentityMemberships({
- projectId: currentProject.id,
- projectType: currentProject.type
- });
- const identities = identitiesData?.identityMemberships ?? [];
+ const { data: identities = [], isPending } = useListPamProductIdentities();
const removeIdentity = useRemovePamProductIdentityMember();
+ const deleteIdentity = useDeleteProjectIdentity();
const filteredIdentities = useMemo(
- () =>
- identities.filter((membership) =>
- membership.identity.name.toLowerCase().includes(search.toLowerCase())
- ),
+ () => identities.filter((member) => member.name.toLowerCase().includes(search.toLowerCase())),
[identities, search]
);
+ // Identities created inside PAM are scoped to the PAM project; removing their membership would
+ // orphan them, so they are deleted outright. Org-level identities just lose their membership.
+ const isPamManaged = (member: TPamIdentityMember) =>
+ member.identityProjectId === currentProject.id;
+
+ const renderManagedByBadge = (member: TPamIdentityMember) => {
+ if (isPamManaged(member)) {
+ return (
+ <Badge variant="project">
+ <ProjectIcon />
+ PAM
+ </Badge>
+ );
+ }
+ if (isSubOrganization && currentOrg.id === member.identityOrgId) {
+ return (
+ <Badge variant="sub-org">
+ <SubOrgIcon />
+ Sub-Organization
+ </Badge>
+ );
+ }
+ return (
+ <Badge variant="org">
+ <OrgIcon />
+ Organization
+ </Badge>
+ );
+ };
+
+ // Rejections propagate to DeleteActionModal, which keeps itself open; the global mutation
+ // error handler owns the toast.
const handleDeleteIdentity = async () => {
- if (!identityToRemove) return;
- await removeIdentity.mutateAsync({
- identityId: identityToRemove.identity.id,
- projectId: currentProject.id
- });
- createNotification({ text: "Identity removed", type: "success" });
+ if (!identityToRemove?.identityId) return;
+
+ if (isPamManaged(identityToRemove)) {
+ await deleteIdentity.mutateAsync({
+ identityId: identityToRemove.identityId,
+ projectId: currentProject.id
+ });
+ queryClient.invalidateQueries({ queryKey: pamKeys.productIdentities() });
+ createNotification({ text: "Identity deleted", type: "success" });
+ } else {
+ await removeIdentity.mutateAsync({
+ identityId: identityToRemove.identityId,
+ projectId: currentProject.id
+ });
+ createNotification({ text: "Identity removed", type: "success" });
+ }
+
setIdentityToRemove(null);
};
@@ -131,6 +181,7 @@ export const IdentitiesTab = () => {
<TableRow>
<TableHead>Identity</TableHead>
<TableHead>Role</TableHead>
+ <TableHead>Managed by</TableHead>
<TableHead>Added</TableHead>
<TableHead className="w-5" />
</TableRow>
@@ -145,85 +196,96 @@ export const IdentitiesTab = () => {
<TableCell>
<Skeleton className="h-4 w-20" />
</TableCell>
+ <TableCell>
+ <Skeleton className="h-4 w-24" />
+ </TableCell>
<TableCell>
<Skeleton className="h-4 w-16" />
</TableCell>
<TableCell />
</TableRow>
))}
- {filteredIdentities.map((membership) => {
- const primaryRole = membership.roles?.[0]?.role ?? ProjectMembershipRole.Member;
- return (
- <TableRow key={membership.id}>
- <TableCell className="font-medium">
- <HighlightText text={membership.identity.name} highlight={search} />
- </TableCell>
- <TableCell>
- <button type="button" onClick={() => setSelectedIdentity(membership)}>
- <Badge
- variant={primaryRole === ProjectMembershipRole.Admin ? "pam" : "neutral"}
+ {filteredIdentities.map((member) => (
+ <TableRow
+ key={member.membershipId}
+ className="cursor-pointer"
+ onClick={() =>
+ navigate({
+ to: "/organizations/$orgId/pam/identities/$identityId",
+ params: { orgId: currentOrg.id, identityId: member.identityId! }
+ })
+ }
+ >
+ <TableCell className="font-medium">
+ <HighlightText text={member.name} highlight={search} />
+ </TableCell>
+ <TableCell>
+ <button
+ type="button"
+ onClick={(e) => {
+ e.stopPropagation();
+ setSelectedIdentity(member);
+ }}
+ >
+ <Badge
+ variant={member.role === ProjectMembershipRole.Admin ? "pam" : "neutral"}
+ >
+ {formatProjectRoleName(member.role)}
+ </Badge>
+ </button>
+ </TableCell>
+ <TableCell>{renderManagedByBadge(member)}</TableCell>
+ <TableCell className="text-sm text-muted">
+ {member.createdAt ? format(new Date(member.createdAt), "MMM d, yyyy") : "—"}
+ </TableCell>
+ <TableCell onClick={(e) => e.stopPropagation()}>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ variant="ghost"
+ size="xs"
+ aria-label="Identity actions"
+ className="text-muted"
+ >
+ <MoreHorizontalIcon className="size-4" />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" onClick={(e) => e.stopPropagation()}>
+ <ProjectPermissionCan
+ I={ProjectPermissionActions.Edit}
+ a={ProjectPermissionSub.Identity}
>
- {formatProjectRoleName(
- primaryRole,
- membership.roles?.[0]?.customRoleName
+ {(isAllowed) => (
+ <DropdownMenuItem
+ isDisabled={!isAllowed}
+ onClick={() => setSelectedIdentity(member)}
+ >
+ <PencilIcon />
+ Edit
+ </DropdownMenuItem>
)}
- </Badge>
- </button>
- </TableCell>
- <TableCell className="text-sm text-muted">
- {membership.createdAt
- ? format(new Date(membership.createdAt), "MMM d, yyyy")
- : "—"}
- </TableCell>
- <TableCell>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- variant="ghost"
- size="xs"
- aria-label="Identity actions"
- className="text-muted"
- >
- <MoreHorizontalIcon className="size-4" />
- </IconButton>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" onClick={(e) => e.stopPropagation()}>
- <ProjectPermissionCan
- I={ProjectPermissionActions.Edit}
- a={ProjectPermissionSub.Identity}
- >
- {(isAllowed) => (
- <DropdownMenuItem
- isDisabled={!isAllowed}
- onClick={() => setSelectedIdentity(membership)}
- >
- <PencilIcon />
- Edit
- </DropdownMenuItem>
- )}
- </ProjectPermissionCan>
- <DropdownMenuSeparator />
- <ProjectPermissionCan
- I={ProjectPermissionActions.Delete}
- a={ProjectPermissionSub.Identity}
- >
- {(isAllowed) => (
- <DropdownMenuItem
- variant="danger"
- isDisabled={!isAllowed}
- onClick={() => setIdentityToRemove(membership)}
- >
- <Trash2Icon />
- Remove
- </DropdownMenuItem>
- )}
- </ProjectPermissionCan>
- </DropdownMenuContent>
- </DropdownMenu>
- </TableCell>
- </TableRow>
- );
- })}
+ </ProjectPermissionCan>
+ <DropdownMenuSeparator />
+ <ProjectPermissionCan
+ I={ProjectPermissionActions.Delete}
+ a={ProjectPermissionSub.Identity}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ variant="danger"
+ isDisabled={!isAllowed}
+ onClick={() => setIdentityToRemove(member)}
+ >
+ <Trash2Icon />
+ {isPamManaged(member) ? "Delete" : "Remove"}
+ </DropdownMenuItem>
+ )}
+ </ProjectPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </TableCell>
+ </TableRow>
+ ))}
</TableBody>
</Table>
)}
@@ -239,16 +301,31 @@ export const IdentitiesTab = () => {
}}
/>
- <DeleteActionModal
- isOpen={!!identityToRemove}
- onChange={(isOpen) => {
- if (!isOpen) setIdentityToRemove(null);
- }}
- title={`Remove ${identityToRemove?.identity.name ?? "identity"}?`}
- deleteKey="remove"
- buttonText="Remove"
- onDeleteApproved={handleDeleteIdentity}
- />
+ {identityToRemove && isPamManaged(identityToRemove) ? (
+ <DeleteActionModal
+ isOpen
+ onChange={(isOpen) => {
+ if (!isOpen) setIdentityToRemove(null);
+ }}
+ title={`Delete ${identityToRemove.name}?`}
+ subTitle="This identity is managed by PAM and will be permanently deleted."
+ deleteKey="delete"
+ buttonText="Delete"
+ onDeleteApproved={handleDeleteIdentity}
+ />
+ ) : (
+ <DeleteActionModal
+ isOpen={!!identityToRemove}
+ onChange={(isOpen) => {
+ if (!isOpen) setIdentityToRemove(null);
+ }}
+ title={`Remove ${identityToRemove?.name ?? "identity"} from PAM?`}
+ subTitle="The identity will lose its PAM access but remain available in your organization."
+ deleteKey="remove"
+ buttonText="Remove"
+ onDeleteApproved={handleDeleteIdentity}
+ />
+ )}
</div>
);
};
diff --git a/frontend/src/pages/pam/PamAccessControlPage/components/IdentityRoleModal.tsx b/frontend/src/pages/pam/PamAccessControlPage/components/IdentityRoleModal.tsx
index aa0978beab..3c31f8b573 100644
--- a/frontend/src/pages/pam/PamAccessControlPage/components/IdentityRoleModal.tsx
+++ b/frontend/src/pages/pam/PamAccessControlPage/components/IdentityRoleModal.tsx
@@ -12,14 +12,14 @@ import {
DialogTitle
} from "@app/components/v3";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
-import { IdentityProjectMembershipV2 } from "@app/hooks/api/identities/types";
import { useUpdatePamProductIdentityMember } from "@app/hooks/api/pam";
+import { TPamIdentityMember } from "@app/hooks/api/pam/types";
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
import { ProductRoleOptionList } from "./ProductRoleOptionList";
type Props = {
- identity: IdentityProjectMembershipV2 | null;
+ identity: TPamIdentityMember | null;
isOpen: boolean;
onOpenChange: (open: boolean) => void;
};
@@ -28,23 +28,23 @@ export const IdentityRoleModal = ({ identity, isOpen, onOpenChange }: Props) =>
const { currentProject } = useProject();
const updateRole = useUpdatePamProductIdentityMember();
- const currentRole = identity?.roles?.[0]?.role ?? ProjectMembershipRole.Member;
+ const currentRole = identity?.role ?? ProjectMembershipRole.Member;
const [selectedRole, setSelectedRole] = useState<string>(currentRole);
useEffect(() => {
if (identity) {
- setSelectedRole(identity.roles?.[0]?.role ?? ProjectMembershipRole.Member);
+ setSelectedRole(identity.role ?? ProjectMembershipRole.Member);
}
}, [identity]);
- if (!identity) return null;
+ if (!identity?.identityId) return null;
const hasChanges = selectedRole !== currentRole;
const handleSave = () => {
updateRole.mutate(
{
- identityId: identity.identity.id,
+ identityId: identity.identityId!,
role: selectedRole,
projectId: currentProject.id
},
@@ -63,7 +63,7 @@ export const IdentityRoleModal = ({ identity, isOpen, onOpenChange }: Props) =>
<DialogHeader>
<DialogTitle>Edit Role</DialogTitle>
<DialogDescription>
- Update the product role for {identity.identity.name || "this identity"}.
+ Update the product role for {identity.name || "this identity"}.
</DialogDescription>
</DialogHeader>
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx b/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx
index 2fcd1fa95c..d0b588cb7a 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx
@@ -47,7 +47,6 @@ import {
} from "@app/components/v3";
import { Skeleton } from "@app/components/v3/generic/Skeleton";
import { useOrganization, useUser } from "@app/context";
-import { useGetIdentityMembershipOrgs } from "@app/hooks/api";
import { useListAppConnections } from "@app/hooks/api/appConnections";
import { gatewayPoolsQueryKeys } from "@app/hooks/api/gateway-pools/queries";
import { gatewaysQueryKeys } from "@app/hooks/api/gateways/queries";
@@ -64,6 +63,7 @@ import {
useGetPamAccountTemplate,
useListAccountMembers,
useListFolderMembers,
+ useListPamProductIdentities,
useListPamResourceRoles,
usePamAccountActions,
usePamAccountTypeMap,
@@ -141,13 +141,17 @@ const PermissionsTab = ({
[orgGroups]
);
- const { data: orgIdentities } = useGetIdentityMembershipOrgs({ organizationId: currentOrg.id });
+ // Product identity members carry names for both org-level and PAM-scoped identities; the org
+ // identity list excludes project-scoped ones, so it can't resolve PAM-created identities.
+ const { data: productIdentities } = useListPamProductIdentities();
const identityNameMap = useMemo(
() =>
new Map(
- (orgIdentities?.identityMemberships ?? []).map((im) => [im.identity.id, im.identity.name])
+ (productIdentities ?? []).flatMap((m) =>
+ m.identityId ? [[m.identityId, m.name] as const] : []
+ )
),
- [orgIdentities]
+ [productIdentities]
);
const removeUser = useRemoveAccountMember();
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/AssignAccessModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/AssignAccessModal.tsx
index e6b074cdb9..33d387d4f4 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/AssignAccessModal.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/AssignAccessModal.tsx
@@ -21,7 +21,6 @@ import {
SelectValue
} from "@app/components/v3";
import { useOrganization } from "@app/context";
-import { useGetIdentityMembershipOrgs } from "@app/hooks/api";
import { useGetOrganizationGroups } from "@app/hooks/api/organization/queries";
import {
TPamResourceRole,
@@ -133,12 +132,9 @@ export const AssignAccessModal = ({
const { currentOrg } = useOrganization();
const { data: orgUsers } = useGetOrgUsers(currentOrg.id);
const { data: orgGroups } = useGetOrganizationGroups(currentOrg.id);
- const { data: orgIdentities } = useGetIdentityMembershipOrgs({
- organizationId: currentOrg.id,
- limit: 1000
- });
const { data: productMembers } = useListPamProductMembers();
const { data: productGroups } = useListPamProductGroups();
+ // Product identity members carry the identity name, covering both org-level and PAM-scoped identities
const { data: productIdentities } = useListPamProductIdentities();
const { data: resourceRoles } = useListPamResourceRoles();
@@ -194,10 +190,6 @@ export const AssignAccessModal = ({
() => new Set((productGroups ?? []).map((m) => m.groupId).filter(Boolean) as string[]),
[productGroups]
);
- const pamIdentityIds = useMemo(
- () => new Set((productIdentities ?? []).map((m) => m.identityId).filter(Boolean) as string[]),
- [productIdentities]
- );
const assigneeOptions = useMemo<AssigneeOption[]>(() => {
const groups: AssigneeOption[] = (orgGroups ?? [])
@@ -217,11 +209,12 @@ export const AssignAccessModal = ({
});
const existingIds = existingIdentityIds ?? new Set<string>();
- const identities: AssigneeOption[] = (orgIdentities?.identityMemberships ?? [])
- .filter((im) => pamIdentityIds.has(im.identity.id) && !existingIds.has(im.identity.id))
- .map((im) => ({
- value: im.identity.id,
- label: im.identity.name,
+ const identities: AssigneeOption[] = (productIdentities ?? [])
+ .filter((m): m is typeof m & { identityId: string } => Boolean(m.identityId))
+ .filter((m) => !existingIds.has(m.identityId))
+ .map((m) => ({
+ value: m.identityId,
+ label: m.name,
kind: PamMemberKind.Identity,
subtitle: "Machine Identity"
}));
@@ -230,10 +223,9 @@ export const AssignAccessModal = ({
}, [
orgGroups,
orgUsers,
- orgIdentities,
+ productIdentities,
pamGroupIds,
pamUserIds,
- pamIdentityIds,
existingGroupIds,
existingUserIds,
existingIdentityIds
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderDetailSheet.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderDetailSheet.tsx
index 1836bc2ae7..1f320a0856 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderDetailSheet.tsx
@@ -35,12 +35,12 @@ import {
} from "@app/components/v3";
import { Skeleton } from "@app/components/v3/generic/Skeleton";
import { useOrganization, useUser } from "@app/context";
-import { useGetIdentityMembershipOrgs } from "@app/hooks/api";
import { useGetOrganizationGroups } from "@app/hooks/api/organization/queries";
import {
TPamFolderWithCount,
TPamMember,
useListFolderMembers,
+ useListPamProductIdentities,
useListPamResourceRoles,
usePamFolderActions,
useRemoveFolderGroupMember,
@@ -181,13 +181,17 @@ const PermissionsTab = ({ folderId }: { folderId: string }) => {
[orgGroups]
);
- const { data: orgIdentities } = useGetIdentityMembershipOrgs({ organizationId: currentOrg.id });
+ // Product identity members carry names for both org-level and PAM-scoped identities; the org
+ // identity list excludes project-scoped ones, so it can't resolve PAM-created identities.
+ const { data: productIdentities } = useListPamProductIdentities();
const identityNameMap = useMemo(
() =>
new Map(
- (orgIdentities?.identityMemberships ?? []).map((im) => [im.identity.id, im.identity.name])
+ (productIdentities ?? []).flatMap((m) =>
+ m.identityId ? [[m.identityId, m.name] as const] : []
+ )
),
- [orgIdentities]
+ [productIdentities]
);
const removeUser = useRemoveFolderMember();
diff --git a/frontend/src/pages/pam/PamSessionsPage/PamSessionsPage.tsx b/frontend/src/pages/pam/PamSessionsPage/PamSessionsPage.tsx
index 34c89dfb17..f955250e1b 100644
--- a/frontend/src/pages/pam/PamSessionsPage/PamSessionsPage.tsx
+++ b/frontend/src/pages/pam/PamSessionsPage/PamSessionsPage.tsx
@@ -297,7 +297,13 @@ export const PamSessionsPage = () => {
<HighlightText text={session.actorName} highlight={search} />
</span>
<span className="text-xs text-muted">
- <HighlightText text={session.actorEmail} highlight={search} />
+ {/* identityId is SET NULL on identity deletion; a machine session with a
+ deleted identity has neither actor FK and an empty actorEmail */}
+ {session.identityId || (!session.userId && !session.actorEmail) ? (
+ "Machine Identity"
+ ) : (
+ <HighlightText text={session.actorEmail} highlight={search} />
+ )}
</span>
</div>
</TableCell>
diff --git a/frontend/src/pages/pam/PamSessionsPage/components/SessionDetailSheet.tsx b/frontend/src/pages/pam/PamSessionsPage/components/SessionDetailSheet.tsx
index bb8216b306..98638b6dd2 100644
--- a/frontend/src/pages/pam/PamSessionsPage/components/SessionDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamSessionsPage/components/SessionDetailSheet.tsx
@@ -274,7 +274,11 @@ export const SessionDetailSheet = ({ sessionId, isOpen, onOpenChange, onTerminat
</Badge>
)
},
- { label: "Email", value: session.actorEmail },
+ // identityId is SET NULL on identity deletion; a machine session with a deleted identity
+ // has neither actor FK and an empty actorEmail
+ session.identityId || (!session.userId && !session.actorEmail)
+ ? { label: "Actor", value: "Machine Identity" }
+ : { label: "Email", value: session.actorEmail },
{ label: "Folder", value: session.folderName || emptyValue },
{
label: "Started",
diff --git a/frontend/src/pages/project/AccessControlPage/components/IdentityTab/components/CreateProjectIdentity/CreateProjectIdentityForm.tsx b/frontend/src/pages/project/AccessControlPage/components/IdentityTab/components/CreateProjectIdentity/CreateProjectIdentityForm.tsx
index 0cf4eab5cf..2137fe5efc 100644
--- a/frontend/src/pages/project/AccessControlPage/components/IdentityTab/components/CreateProjectIdentity/CreateProjectIdentityForm.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/IdentityTab/components/CreateProjectIdentity/CreateProjectIdentityForm.tsx
@@ -30,7 +30,7 @@ import {
useListProjectIdentityMemberships,
useUpdateProjectIdentityMembership
} from "@app/hooks/api";
-import { useAddIdentityUniversalAuth } from "@app/hooks/api/identities";
+import { UNIVERSAL_AUTH_DEFAULTS, useAddIdentityUniversalAuth } from "@app/hooks/api/identities";
import { ProjectType } from "@app/hooks/api/projects/types";
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
import {
@@ -46,19 +46,6 @@ import {
TCreateProjectIdentityForm
} from "./schema";
-const UNIVERSAL_AUTH_DEFAULTS = {
- clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
- accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
- accessTokenTTL: 2592000,
- accessTokenMaxTTL: 2592000,
- accessTokenNumUsesLimit: 0,
- accessTokenPeriod: 0,
- lockoutEnabled: true,
- lockoutThreshold: 3,
- lockoutDurationSeconds: 300,
- lockoutCounterResetSeconds: 30
-};
-
const buildTemplatePermissions = (
projectType: ProjectType,
templateIds: string[]
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx
index e38f657b6b..e89f523a68 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx
@@ -47,6 +47,7 @@ import {
useGetProjectIdentityMembershipV2
} from "@app/hooks/api";
import { ActorType } from "@app/hooks/api/auditLogs/enums";
+import { useRemovePamProductIdentityMember } from "@app/hooks/api/pam";
import { projectIdentityQuery, useDeleteProjectIdentity } from "@app/hooks/api/projectIdentity";
import { ProjectType } from "@app/hooks/api/projects/types";
import { ProjectIdentityAuthenticationSection } from "@app/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection";
@@ -70,9 +71,30 @@ const Page = () => {
useGetProjectIdentityMembershipV2(projectId, identityId, currentProject?.type);
const { mutateAsync: removeIdentityMutateAsync } = useDeleteProjectIdentityMembership();
+ const { mutateAsync: removePamIdentityMutateAsync } = useRemovePamProductIdentityMember();
const isProjectIdentity = Boolean(identityMembershipDetails?.identity.projectId);
const isCertManager = currentProject?.type === ProjectType.CertificateManager;
+ const isPam = currentProject?.type === ProjectType.PAM;
+ // Products where the underlying project is an internal detail the user never sees
+ const isStandaloneProduct = isCertManager || isPam;
+
+ let removeMenuItemLabel = "Remove From Project";
+ if (isProjectIdentity) {
+ removeMenuItemLabel = "Delete Machine Identity";
+ } else if (isPam) {
+ removeMenuItemLabel = "Remove From PAM";
+ }
+
+ let accessControlLabel = "project";
+ if (isCertManager) {
+ accessControlLabel = "certificate manager";
+ } else if (isPam) {
+ accessControlLabel = "PAM";
+ }
+ const pageDescription = `Configure and manage${
+ isProjectIdentity ? " machine identity and " : " "
+ }${accessControlLabel} access control`;
const {
data: identity,
@@ -96,12 +118,21 @@ const Page = () => {
const [isPermissionAuditOpen, setIsPermissionAuditOpen] = useState(false);
const onRemoveIdentitySubmit = async () => {
- await removeIdentityMutateAsync({
- identityId,
- projectId
- });
+ if (isPam) {
+ // PAM removal goes through the PAM endpoint so PAM audit events fire and
+ // folder/account resource memberships are cleaned up (the generic route skips that)
+ await removePamIdentityMutateAsync({
+ identityId,
+ projectId
+ });
+ } else {
+ await removeIdentityMutateAsync({
+ identityId,
+ projectId
+ });
+ }
createNotification({
- text: "Successfully removed machine identity from project",
+ text: `Successfully removed machine identity from ${isPam ? "PAM" : "project"}`,
type: "success"
});
handlePopUpClose("removeIdentity");
@@ -166,19 +197,15 @@ const Page = () => {
className="mb-4 flex w-fit items-center gap-x-1 text-sm text-mineshaft-400 transition duration-100 hover:text-mineshaft-400/80"
>
<ChevronLeftIcon size={16} />
- {isCertManager ? "Machine Identities" : "Project Machine Identities"}
+ {isStandaloneProduct ? "Machine Identities" : "Project Machine Identities"}
</Link>
<PageHeader
scope={currentProject.type}
- description={
- isCertManager
- ? `Configure and manage${isProjectIdentity ? " machine identity and " : " "}certificate manager access control`
- : `Configure and manage${isProjectIdentity ? " machine identity and " : " "}project access control`
- }
+ description={pageDescription}
title={identityMembershipDetails.identity.name}
>
<div className="flex items-center gap-2">
- {!isCertManager && (
+ {!isStandaloneProduct && (
<Button variant="outline" onClick={() => setIsPermissionAuditOpen(true)}>
<ShieldIcon />
Permission Audit
@@ -245,7 +272,7 @@ const Page = () => {
: handlePopUpOpen("removeIdentity")
}
>
- {isProjectIdentity ? "Delete Machine Identity" : "Remove From Project"}
+ {removeMenuItemLabel}
</DropdownMenuItem>
)}
</ProjectPermissionCan>
@@ -319,7 +346,7 @@ const Page = () => {
identityMembershipDetails={identityMembershipDetails}
isMembershipDetailsLoading={isMembershipDetailsLoading}
/>
- {!isCertManager && (
+ {!isStandaloneProduct && (
<IdentityProjectAdditionalPrivilegeSection
identityMembershipDetails={identityMembershipDetails}
/>
@@ -328,9 +355,15 @@ const Page = () => {
</div>
<DeleteActionModal
isOpen={popUp.removeIdentity.isOpen}
- title={`Are you sure you want to remove ${identityMembershipDetails?.identity?.name} from the project?`}
+ title={`Are you sure you want to remove ${identityMembershipDetails?.identity?.name} from ${isPam ? "PAM" : "the project"}?`}
+ subTitle={
+ isPam
+ ? "The identity will lose its PAM access but remain available in your organization."
+ : undefined
+ }
onChange={(isOpen) => handlePopUpToggle("removeIdentity", isOpen)}
deleteKey="remove"
+ buttonText={isPam ? "Remove" : undefined}
onDeleteApproved={() => onRemoveIdentitySubmit()}
/>
<AssumePrivilegesModal
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx
index 404e1c336f..0ddb8d4f35 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx
@@ -128,14 +128,20 @@ export const IdentityRoleDetailsSection = ({
const hasRoles = Boolean(identityMembershipDetails?.roles.length);
const isCertManager = currentProject?.type === ProjectType.CertificateManager;
+ const isPam = currentProject?.type === ProjectType.PAM;
+ // Products where the underlying project is an internal detail the user never sees
+ const isStandaloneProduct = isCertManager || isPam;
+ // PAM has a single built-in product role edited from its own Access Control page; the generic
+ // multi-role editor (custom roles, temporary access) doesn't apply, so the card is read-only here.
+ const isRoleEditable = !isPam;
return (
<>
<Card>
<CardHeader>
- <CardTitle>{isCertManager ? "Roles" : "Project Roles"}</CardTitle>
+ <CardTitle>{isStandaloneProduct ? "Roles" : "Project Roles"}</CardTitle>
<CardDescription>Manage roles assigned to this machine identity</CardDescription>
- {hasRoles && (
+ {hasRoles && isRoleEditable && (
<CardAction>
<ProjectPermissionCan
I={ProjectPermissionActions.Edit}
@@ -220,9 +226,9 @@ export const IdentityRoleDetailsSection = ({
return (
<TableRow
key={`user-project-identity-${roleDetails?.id}`}
- className={isCertManager ? "" : "cursor-pointer"}
+ className={isStandaloneProduct ? "" : "cursor-pointer"}
onClick={
- isCertManager
+ isStandaloneProduct
? undefined
: () =>
navigate({
@@ -261,41 +267,43 @@ export const IdentityRoleDetailsSection = ({
)}
</TableCell>
<TableCell>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- size="xs"
- variant="ghost"
- onClick={(e) => e.stopPropagation()}
- >
- <EllipsisIcon />
- </IconButton>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <ProjectPermissionCan
- I={ProjectPermissionActions.Edit}
- a={subject(ProjectPermissionSub.Identity, {
- identityId: identityMembershipDetails.identity.id
- })}
- >
- {(isAllowed) => (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- handlePopUpOpen("deleteRole", {
- id: roleDetails?.id,
- slug: roleDetails?.customRoleName || roleDetails?.role
- });
- }}
- isDisabled={!isAllowed || !canModifyIdentityRoles}
- variant="danger"
- >
- Remove Role
- </DropdownMenuItem>
- )}
- </ProjectPermissionCan>
- </DropdownMenuContent>
- </DropdownMenu>
+ {isRoleEditable && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ size="xs"
+ variant="ghost"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <EllipsisIcon />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <ProjectPermissionCan
+ I={ProjectPermissionActions.Edit}
+ a={subject(ProjectPermissionSub.Identity, {
+ identityId: identityMembershipDetails.identity.id
+ })}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+ handlePopUpOpen("deleteRole", {
+ id: roleDetails?.id,
+ slug: roleDetails?.customRoleName || roleDetails?.role
+ });
+ }}
+ isDisabled={!isAllowed || !canModifyIdentityRoles}
+ variant="danger"
+ >
+ Remove Role
+ </DropdownMenuItem>
+ )}
+ </ProjectPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
</TableCell>
</TableRow>
);
@@ -308,43 +316,45 @@ export const IdentityRoleDetailsSection = ({
<EmptyTitle>This machine identity doesn&apos;t have any roles</EmptyTitle>
<EmptyDescription>Give this machine identity one or more roles</EmptyDescription>
</EmptyHeader>
- <EmptyContent>
- <ProjectPermissionCan
- I={ProjectPermissionActions.Edit}
- a={subject(ProjectPermissionSub.Identity, {
- identityId: identityMembershipDetails.identity.id
- })}
- >
- {(isAllowed) => {
- const isEditDisabled = !isAllowed || !canModifyIdentityRoles;
- const button = (
- <Button
- variant="project"
- size="xs"
- onClick={() => {
- handlePopUpOpen("modifyRole");
- }}
- isDisabled={isEditDisabled}
- >
- <PencilIcon />
- Edit Roles
- </Button>
- );
- return isEditDisabled ? (
- <Tooltip>
- <TooltipTrigger asChild>
- <span className="inline-block">{button}</span>
- </TooltipTrigger>
- <TooltipContent>
- You don&apos;t have permission to edit this identity&apos;s roles
- </TooltipContent>
- </Tooltip>
- ) : (
- button
- );
- }}
- </ProjectPermissionCan>
- </EmptyContent>
+ {isRoleEditable && (
+ <EmptyContent>
+ <ProjectPermissionCan
+ I={ProjectPermissionActions.Edit}
+ a={subject(ProjectPermissionSub.Identity, {
+ identityId: identityMembershipDetails.identity.id
+ })}
+ >
+ {(isAllowed) => {
+ const isEditDisabled = !isAllowed || !canModifyIdentityRoles;
+ const button = (
+ <Button
+ variant="project"
+ size="xs"
+ onClick={() => {
+ handlePopUpOpen("modifyRole");
+ }}
+ isDisabled={isEditDisabled}
+ >
+ <PencilIcon />
+ Edit Roles
+ </Button>
+ );
+ return isEditDisabled ? (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-block">{button}</span>
+ </TooltipTrigger>
+ <TooltipContent>
+ You don&apos;t have permission to edit this identity&apos;s roles
+ </TooltipContent>
+ </Tooltip>
+ ) : (
+ button
+ );
+ }}
+ </ProjectPermissionCan>
+ </EmptyContent>
+ )}
</Empty>
)
}
@@ -363,7 +373,11 @@ export const IdentityRoleDetailsSection = ({
>
<ModalContent
title="Roles"
- subTitle="Select one or more of the pre-defined or custom roles to configure project permissions."
+ subTitle={
+ isStandaloneProduct
+ ? "Select one or more of the pre-defined roles to configure access."
+ : "Select one or more of the pre-defined or custom roles to configure project permissions."
+ }
>
<IdentityRoleModify identityProjectMembership={identityMembershipDetails} />
</ModalContent>
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx
index 70b3ed621d..888bb87178 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx
@@ -73,7 +73,10 @@ type Props = {
export const IdentityRoleModify = ({ identityProjectMembership }: Props) => {
const { projectId, currentProject } = useProject();
const { subscription } = useSubscription();
- const { data: projectRoles, isPending: isRolesLoading } = useGetProjectRoles(projectId);
+ const { data: projectRoles, isPending: isRolesLoading } = useGetProjectRoles(
+ projectId,
+ currentProject?.type
+ );
const { permission } = useProjectPermission();
const {
popUp: upgradePlanPopUp,
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx
index 944c9ba72e..69b813f73c 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx
@@ -19,7 +19,7 @@ import {
} from "@app/components/v3";
import { ProjectPermissionIdentityActions, ProjectPermissionSub } from "@app/context";
import { IdentityAuthMethod, TProjectIdentity } from "@app/hooks/api";
-import { usePopUp } from "@app/hooks/usePopUp";
+import { usePopUp, UsePopUpState } from "@app/hooks/usePopUp";
import { IdentityAuthMethodModal } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal";
import { IdentityAuthMethodsTable } from "@app/views/IdentityAuthMethods";
@@ -36,6 +36,19 @@ export const ProjectIdentityAuthenticationSection = ({ identity, refetchIdentity
const hasAuthMethods = Boolean(identity.authMethods.length);
+ // The auth-method forms invalidate the project identity query using the route's :projectId, which
+ // PAM's identity route doesn't carry (its project is internal), so this card can go stale there.
+ // Refetch whenever the sheet closes to keep the method list in sync on every product.
+ const handleAuthMethodPopUpToggle = (
+ popUpName: keyof UsePopUpState<["identityAuthMethod", "upgradePlan"]>,
+ state?: boolean
+ ) => {
+ handlePopUpToggle(popUpName, state);
+ if (popUpName === "identityAuthMethod" && !state) {
+ refetchIdentity();
+ }
+ };
+
return (
<>
<Card>
@@ -123,7 +136,7 @@ export const ProjectIdentityAuthenticationSection = ({ identity, refetchIdentity
<IdentityAuthMethodModal
popUp={popUp}
handlePopUpOpen={handlePopUpOpen}
- handlePopUpToggle={handlePopUpToggle}
+ handlePopUpToggle={handleAuthMethodPopUpToggle}
/>
<UpgradePlanModal
isOpen={popUp.upgradePlan.isOpen}
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx
index bd514963ab..53fe9a4328 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx
@@ -51,6 +51,21 @@ export const ProjectIdentityDetailsSection = ({
}: Props) => {
const { currentProject } = useProject();
const isCertManager = currentProject?.type === ProjectType.CertificateManager;
+ const isPam = currentProject?.type === ProjectType.PAM;
+
+ let productLabel = "Project";
+ if (isCertManager) {
+ productLabel = "Certificate Manager";
+ } else if (isPam) {
+ productLabel = "PAM";
+ }
+
+ let joinedLabel = "Joined project";
+ if (isCertManager) {
+ joinedLabel = "Joined certificate manager";
+ } else if (isPam) {
+ joinedLabel = "Joined PAM";
+ }
// eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-unused-vars
const [_, isCopyingId, setCopyTextId] = useTimedReset<string>({
@@ -125,7 +140,7 @@ export const ProjectIdentityDetailsSection = ({
) : (
<Badge variant="project">
<ProjectIcon />
- {isCertManager ? "Certificate Manager" : "Project"}
+ {productLabel}
</Badge>
)}
</DetailValue>
@@ -150,14 +165,7 @@ export const ProjectIdentityDetailsSection = ({
</DetailValue>
</Detail>
<Detail>
- <DetailLabel>
- {/* eslint-disable-next-line no-nested-ternary */}
- {isOrgIdentity
- ? isCertManager
- ? "Joined certificate manager"
- : "Joined project"
- : "Created"}
- </DetailLabel>
+ <DetailLabel>{isOrgIdentity ? joinedLabel : "Created"}</DetailLabel>
<DetailValue>{format(membership.createdAt, "PPpp")}</DetailValue>
</Detail>
{!isOrgIdentity && (