Skip to content

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

feat(pam): account password viewing with access requests

Andreye7116cbaa894
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-access-request-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-access-request-router.ts
index f7849396f1..3cf70be19e 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-access-request-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-access-request-router.ts
@@ -2,6 +2,7 @@ import z from "zod";
import { ApprovalRequestsSchema } from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
+import { PamAccessType } from "@app/ee/services/pam/pam-enums";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
@@ -13,6 +14,7 @@ const EnrichedRequestSchema = ApprovalRequestsSchema.extend({
accountName: z.string().nullable(),
accountType: z.string().nullable(),
folderName: z.string().nullable(),
+ accessType: z.nativeEnum(PamAccessType),
grantExpiresAt: z.date().nullable(),
grantStatus: z.string().nullable()
});
@@ -28,7 +30,11 @@ export const registerPamAccessRequestRouter = async (server: FastifyZodProvider)
accountId: z.string().uuid().optional(),
path: z.string().min(3).optional().describe("Account path in the format 'folderName/accountName'"),
reason: z.string().max(500).optional(),
- duration: z.string().min(1)
+ duration: z.string().min(1),
+ accessType: z
+ .nativeEnum(PamAccessType)
+ .default(PamAccessType.Session)
+ .describe("Whether the request unlocks launching sessions or viewing the account's credentials")
})
.refine((b) => Boolean(b.accountId) || Boolean(b.path), {
message: "Either 'accountId' or 'path' is required"
@@ -47,6 +53,7 @@ export const registerPamAccessRequestRouter = async (server: FastifyZodProvider)
projectId: req.internalPamProjectId,
reason: req.body.reason,
duration: req.body.duration,
+ accessType: req.body.accessType,
actorId: req.permission.id,
actor: req.permission.type,
actorOrgId: req.permission.orgId,
@@ -64,6 +71,7 @@ export const registerPamAccessRequestRouter = async (server: FastifyZodProvider)
accountId: result.accountId,
folderId: result.folderId,
duration: req.body.duration,
+ accessType: result.accessType,
reason: req.body.reason
}
}
@@ -181,6 +189,9 @@ export const registerPamAccessRequestRouter = async (server: FastifyZodProvider)
params: z.object({
accountId: z.string().uuid()
}),
+ querystring: z.object({
+ accessType: z.nativeEnum(PamAccessType).default(PamAccessType.Session)
+ }),
response: {
200: z.object({
steps: z.array(
@@ -203,6 +214,7 @@ export const registerPamAccessRequestRouter = async (server: FastifyZodProvider)
const result = await server.services.pamAccessRequest.getAccountApprovers({
accountId: req.params.accountId,
projectId: req.internalPamProjectId,
+ accessType: req.query.accessType,
actorId: req.permission.id,
actor: req.permission.type,
actorOrgId: req.permission.orgId,
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
index 26d3ed7a56..03cfd3aee5 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
@@ -22,6 +22,7 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { slugSchema } from "@app/server/lib/schemas";
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { withRoutePrefix } from "@app/server/lib/with-route-prefix";
+import { isUserSessionAuth } from "@app/server/plugins/auth/inject-identity";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
@@ -60,6 +61,11 @@ const PamAccountListItemSchema = SanitizedAccountListItemSchema.extend({
requireReason: z.boolean().describe("Whether the account's template requires a reason for access"),
accessStatus: z.nativeEnum(PamAccessStatus).describe("Current approval status for the caller"),
grantExpiresAt: z.date().nullable().describe("When the current grant expires, if granted"),
+ requiresCredentialApproval: z
+ .boolean()
+ .describe("Whether this account requires approval before its credentials can be viewed"),
+ supportsCredentialReveal: z.boolean().describe("Whether this account type stores a credential that can be revealed"),
+ credentialAccessStatus: z.nativeEnum(PamAccessStatus).describe("Current credential-approval status for the caller"),
permissions: z.any().array().describe("The caller's effective (packed) resource permissions on this account")
});
@@ -745,6 +751,70 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
}
});
+ server.route({
+ method: "POST",
+ url: "/:accountId/credentials",
+ schema: {
+ operationId: "getPamAccountCredentials",
+ description: "Reveal the stored credentials for a PAM account",
+ tags: [ApiDocsTags.PamAccounts],
+ params: z.object({ accountId: z.string().uuid().describe("The ID of the account") }),
+ body: z.object({
+ reason: z
+ .string()
+ .trim()
+ .max(500)
+ .optional()
+ .describe("Why the credentials are being viewed. Required when the template requires a reason."),
+ mfaSessionId: z
+ .string()
+ .max(64)
+ .optional()
+ .describe("A verified MFA session ID. Required when the template requires MFA.")
+ }),
+ response: {
+ 200: z.object({
+ accountType: z.string().describe("The account's platform type"),
+ credentials: z.record(z.unknown()).describe("The account's stored credentials, secrets included")
+ })
+ }
+ },
+ config: { rateLimit: writeLimit },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const result = await server.services.pamAccount.getCredentials({
+ accountId: req.params.accountId,
+ projectId: req.internalPamProjectId,
+ actorEmail: isUserSessionAuth(req.auth) ? (req.auth.user.email ?? "") : "",
+ reason: req.body.reason,
+ mfaSessionId: req.body.mfaSessionId,
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: req.permission.orgId,
+ projectId: req.internalPamProjectId,
+ event: {
+ type: EventType.PAM_ACCOUNT_CREDENTIALS_VIEW,
+ metadata: {
+ accountId: result.accountId,
+ accountName: result.accountName,
+ accountType: result.accountType,
+ folderId: result.folderId,
+ reason: result.reason,
+ grantExpiresAt: result.grantExpiresAt?.toISOString() ?? null
+ }
+ }
+ });
+
+ return { accountType: result.accountType, credentials: result.credentials };
+ }
+ });
+
server.route({
method: "POST",
url: "/:accountId/ssh-ca",
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-resource-role-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-resource-role-router.ts
index 72efdac3fe..48d3363a3c 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-resource-role-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-resource-role-router.ts
@@ -13,6 +13,12 @@ const DEFAULT_RESOURCE_ROLES = [
isDefault: true,
description: "Full control of accounts, folders, sessions, and memberships"
},
+ {
+ slug: PamResourceRole.Operator,
+ name: "Operator",
+ isDefault: true,
+ description: "Launch sessions and view account credentials; cannot approve requests or change configuration"
+ },
{
slug: PamResourceRole.Connector,
name: "Connector",
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 529665cc61..9a615b9096 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -736,6 +736,7 @@ export enum EventType {
PAM_ACCOUNT_UPDATE = "pam-account-update",
PAM_ACCOUNT_DELETE = "pam-account-delete",
PAM_ACCOUNT_SSH_CA_CREATE = "pam-account-ssh-ca-create",
+ PAM_ACCOUNT_CREDENTIALS_VIEW = "pam-account-credentials-view",
PAM_DISCOVERY_SOURCE_CREATE = "pam-discovery-source-create",
PAM_DISCOVERY_SOURCE_UPDATE = "pam-discovery-source-update",
PAM_DISCOVERY_SOURCE_DELETE = "pam-discovery-source-delete",
@@ -6059,6 +6060,18 @@ interface PamAccountSshCaCreateEvent {
};
}
+interface PamAccountCredentialsViewEvent {
+ type: EventType.PAM_ACCOUNT_CREDENTIALS_VIEW;
+ metadata: {
+ accountId: string;
+ accountName: string;
+ accountType: string;
+ folderId?: string | null;
+ reason?: string | null;
+ grantExpiresAt?: string | null;
+ };
+}
+
interface PamDiscoverySourceCreateEvent {
type: EventType.PAM_DISCOVERY_SOURCE_CREATE;
metadata: { sourceId: string; discoveryType: string; name: string };
@@ -6125,6 +6138,7 @@ interface PamAccessRequestCreateEvent {
accountId: string;
folderId: string;
duration: string;
+ accessType: string;
reason?: string;
};
}
@@ -7749,6 +7763,7 @@ export type Event =
| PamAccountUpdateEvent
| PamAccountDeleteEvent
| PamAccountSshCaCreateEvent
+ | PamAccountCredentialsViewEvent
| PamDiscoverySourceCreateEvent
| PamDiscoverySourceUpdateEvent
| PamDiscoverySourceDeleteEvent
diff --git a/backend/src/ee/services/pam-access-request/pam-access-request-service.ts b/backend/src/ee/services/pam-access-request/pam-access-request-service.ts
index aaf2a6f83a..2baff6db4a 100644
--- a/backend/src/ee/services/pam-access-request/pam-access-request-service.ts
+++ b/backend/src/ee/services/pam-access-request/pam-access-request-service.ts
@@ -56,7 +56,13 @@ import { TUserDALFactory } from "@app/services/user/user-dal";
import { TWorkflowIntegrationDALFactory } from "@app/services/workflow-integration/workflow-integration-dal";
import { WorkflowIntegration } from "@app/services/workflow-integration/workflow-integration-types";
-import { PamAccessStatus, PamNotificationEvent, PamProductRole, PamSessionStatus } from "../pam/pam-enums";
+import {
+ PamAccessStatus,
+ PamAccessType,
+ PamNotificationEvent,
+ PamProductRole,
+ PamSessionStatus
+} from "../pam/pam-enums";
import { resolveAccountByPath } from "../pam/pam-fns";
import {
checkAccountAccess,
@@ -374,7 +380,8 @@ export const pamAccessRequestServiceFactory = ({
...r,
accountName: account?.name ?? null,
accountType: account?.templateId ? (templateTypeMap.get(account.templateId) ?? null) : null,
- folderName: folder?.name ?? null
+ folderName: folder?.name ?? null,
+ accessType: data?.requestData?.accessType ?? PamAccessType.Session
};
});
};
@@ -620,7 +627,16 @@ export const pamAccessRequestServiceFactory = ({
return { policyId: newPolicy.id, folderId, stepCount: steps.length, notificationConfigCount };
};
- const createRequest = async ({ accountId, path, projectId, reason, duration, ...ctx }: TCreateAccessRequestDTO) => {
+ const createRequest = async ({
+ accountId,
+ path,
+ projectId,
+ reason,
+ duration,
+ accessType = PamAccessType.Session,
+ ...ctx
+ }: TCreateAccessRequestDTO) => {
+ const isCredentialRequest = accessType === PamAccessType.Credential;
const trimmedReason = reason?.trim() || undefined;
await verifyProductMembership(permissionService, projectId, ctx);
@@ -636,26 +652,37 @@ export const pamAccessRequestServiceFactory = ({
throw new NotFoundError({ message: "Account not found" });
}
- // Approval is a layer on top of standing access: only users who could launch sessions on this
- // account may request the temporary grant that unlocks the gated launch.
+ // Approval is a layer on top of standing access: only users who already hold the underlying
+ // permission may request the temporary grant that unlocks it.
await checkAccountAccess(
permissionService,
account.id,
account.folderId,
projectId,
- ResourcePermissionPamResourceActions.LaunchSessions,
+ isCredentialRequest
+ ? ResourcePermissionPamResourceActions.ViewCredentials
+ : ResourcePermissionPamResourceActions.LaunchSessions,
ctx
);
const accessControls = resolveAccessControls(account.templatePolicies);
- if (!accessControls.requiresApproval) {
- throw new BadRequestError({ message: "This account does not require approval" });
+ const gateEnabled = isCredentialRequest
+ ? accessControls.requiresCredentialApproval
+ : accessControls.requiresApproval;
+ if (!gateEnabled) {
+ throw new BadRequestError({
+ message: isCredentialRequest
+ ? "This account does not require approval to view its credentials"
+ : "This account does not require approval"
+ });
}
if (accessControls.requireReason && !trimmedReason) {
throw new BadRequestError({
name: "PAM_REASON_REQUIRED",
- message: "A reason is required to request access to this account"
+ message: isCredentialRequest
+ ? "A reason is required to request credential access to this account"
+ : "A reason is required to request access to this account"
});
}
@@ -690,11 +717,18 @@ export const pamAccessRequestServiceFactory = ({
const hasPendingForAccount = existingPending.some((r) => {
const data = r.requestData as { version: number; requestData: TPamAccessRequestData } | null;
- return data?.requestData?.accountId === account.id;
+ return (
+ data?.requestData?.accountId === account.id &&
+ (data?.requestData?.accessType ?? PamAccessType.Session) === accessType
+ );
});
if (hasPendingForAccount) {
- throw new BadRequestError({ message: "You already have a pending request for this account" });
+ throw new BadRequestError({
+ message: isCredentialRequest
+ ? "You already have a pending credential request for this account"
+ : "You already have a pending request for this account"
+ });
}
const policySteps = await approvalPolicyDAL.findStepsByPolicyId(policy.id);
@@ -716,13 +750,15 @@ export const pamAccessRequestServiceFactory = ({
}));
const isIdentityActor = ctx.actor === ActorType.IDENTITY;
+ const accessTypeLabel = isCredentialRequest ? "credential access" : "access";
const { name: requesterName, email: requesterEmail } = await resolveRequesterDisplay(ctx);
const requestData = {
accountId: account.id,
folderId: account.folderId,
reason: trimmedReason,
- duration
+ duration,
+ accessType
} as unknown as TApprovalRequestData;
const request = await createApprovalRequestWithSteps(
@@ -778,7 +814,7 @@ export const pamAccessRequestServiceFactory = ({
if (recipients.length > 0) {
await smtpService.sendMail({
recipients,
- subjectLine: "PAM Access Request",
+ subjectLine: isCredentialRequest ? "PAM Credential Access Request" : "PAM Access Request",
template: SmtpTemplates.AccessPamRequest,
substitutions: {
requesterFullName: requesterName,
@@ -787,6 +823,7 @@ export const pamAccessRequestServiceFactory = ({
accountName: account.name,
folderName: account.folderName ?? undefined,
accessDuration: formatDuration(duration),
+ accessTypeLabel,
reason: trimmedReason,
approvalUrl
}
@@ -809,13 +846,20 @@ export const pamAccessRequestServiceFactory = ({
accountName: account.name,
folderName: account.folderName ?? "",
accessDuration: formatDuration(duration),
+ accessTypeLabel,
reason: trimmedReason,
approvalUrl
}
}
});
- return { request, accountId: account.id, folderId: account.folderId, accountType: account.accountType };
+ return {
+ request,
+ accountId: account.id,
+ folderId: account.folderId,
+ accountType: account.accountType,
+ accessType
+ };
};
const listRequests = async ({ projectId, folderId, status, offset, limit, ...ctx }: TListAccessRequestsDTO) => {
@@ -1199,7 +1243,8 @@ export const pamAccessRequestServiceFactory = ({
type: ApprovalPolicyType.PamAccess,
attributes: {
accountId: requestData.requestData.accountId,
- folderId: requestData.requestData.folderId
+ folderId: requestData.requestData.folderId,
+ accessType: requestData.requestData.accessType ?? PamAccessType.Session
},
expiresAt
},
@@ -1287,9 +1332,11 @@ export const pamAccessRequestServiceFactory = ({
if (grant.granteeMachineIdentityId) granteeFilter = { identityId: grant.granteeMachineIdentityId };
else if (grant.granteeUserId) granteeFilter = { userId: grant.granteeUserId };
- const attrs = grant.attributes as { accountId?: string } | null;
+ const attrs = grant.attributes as { accountId?: string; accessType?: PamAccessType } | null;
if (!attrs?.accountId || !granteeFilter) return noSignals;
+ if ((attrs.accessType ?? PamAccessType.Session) === PamAccessType.Credential) return noSignals;
+
// Cover both active and starting sessions; a session mid-handshake would otherwise slip past
// revocation and go live. terminateSessionById flips the row, and the ALPN signal cuts the live
// tunnel, since neither the gateway nor the web-access loop watches the status column.
@@ -1443,6 +1490,7 @@ export const pamAccessRequestServiceFactory = ({
accountId,
accountFolderId,
projectId,
+ accessType = PamAccessType.Session,
...actorCtx
}: TCheckGrantDTO): Promise<TApprovalRequestGrants | null> => {
const grants = await approvalRequestGrantsDAL.find({
@@ -1457,8 +1505,16 @@ export const pamAccessRequestServiceFactory = ({
// the account lived in another folder must not authorize launch after the account is moved into a
// different (gated) folder whose approvers never reviewed it.
const forAccount = grants.filter((g) => {
- const attrs = g.attributes as { accountId?: string; folderId?: string | null } | null;
- return attrs?.accountId === accountId && (attrs?.folderId ?? null) === (accountFolderId ?? null);
+ const attrs = g.attributes as {
+ accountId?: string;
+ folderId?: string | null;
+ accessType?: PamAccessType;
+ } | null;
+ return (
+ attrs?.accountId === accountId &&
+ (attrs?.folderId ?? null) === (accountFolderId ?? null) &&
+ (attrs?.accessType ?? PamAccessType.Session) === accessType
+ );
});
// Prefer a still-valid grant; otherwise return an expired one (rather than null) so the caller can
// distinguish "grant expired" from "no grant" and signal PAM_GRANT_EXPIRED vs PAM_APPROVAL_REQUIRED.
@@ -1469,7 +1525,8 @@ export const pamAccessRequestServiceFactory = ({
const getAccessStatusBatch = async (
actorCtx: TAccessRequestActor,
accountIds: string[],
- projectId: string
+ projectId: string,
+ accessType: PamAccessType = PamAccessType.Session
): Promise<Map<string, { accessStatus: PamAccessStatus; grantExpiresAt: Date | null }>> => {
const result = new Map<string, { accessStatus: PamAccessStatus; grantExpiresAt: Date | null }>();
if (accountIds.length === 0) return result;
@@ -1485,8 +1542,9 @@ export const pamAccessRequestServiceFactory = ({
for (const grant of activeGrants) {
const isExpired = Boolean(grant.expiresAt && new Date(grant.expiresAt) <= now);
- const attrs = grant.attributes as { accountId?: string } | null;
- if (!isExpired && attrs?.accountId && accountIds.includes(attrs.accountId)) {
+ const attrs = grant.attributes as { accountId?: string; accessType?: PamAccessType } | null;
+ const grantAccessType = attrs?.accessType ?? PamAccessType.Session;
+ if (!isExpired && grantAccessType === accessType && attrs?.accountId && accountIds.includes(attrs.accountId)) {
result.set(attrs.accountId, {
accessStatus: PamAccessStatus.Granted,
grantExpiresAt: grant.expiresAt ? new Date(grant.expiresAt) : null
@@ -1504,7 +1562,8 @@ export const pamAccessRequestServiceFactory = ({
for (const request of pendingRequests) {
const data = request.requestData as { version: number; requestData: TPamAccessRequestData } | null;
const acctId = data?.requestData?.accountId;
- if (acctId && accountIds.includes(acctId) && !result.has(acctId)) {
+ const requestAccessType = data?.requestData?.accessType ?? PamAccessType.Session;
+ if (requestAccessType === accessType && acctId && accountIds.includes(acctId) && !result.has(acctId)) {
result.set(acctId, { accessStatus: PamAccessStatus.Pending, grantExpiresAt: null });
}
}
@@ -1524,9 +1583,14 @@ export const pamAccessRequestServiceFactory = ({
return new Set(scopeIds);
};
- // Requesters need to know who to ping for approval, so this is gated on LaunchSessions (the
- // request-access permission) rather than the policy-management check used for the full config.
- const getAccountApprovers = async ({ accountId, projectId, ...ctx }: TGetAccountApproversDTO) => {
+ // Requesters need to know who to ping for approval, so this is gated on the permission the
+ // request itself needs rather than the policy-management check used for the full config.
+ const getAccountApprovers = async ({
+ accountId,
+ projectId,
+ accessType = PamAccessType.Session,
+ ...ctx
+ }: TGetAccountApproversDTO) => {
await verifyProductMembership(permissionService, projectId, ctx);
const account = await pamAccountDAL.findByIdWithDetails(accountId);
@@ -1539,7 +1603,9 @@ export const pamAccessRequestServiceFactory = ({
account.id,
account.folderId,
projectId,
- ResourcePermissionPamResourceActions.LaunchSessions,
+ accessType === PamAccessType.Credential
+ ? ResourcePermissionPamResourceActions.ViewCredentials
+ : ResourcePermissionPamResourceActions.LaunchSessions,
ctx
);
@@ -1563,7 +1629,10 @@ export const pamAccessRequestServiceFactory = ({
});
const pendingForAccount = pendingRequests.find((r) => {
const data = r.requestData as { version: number; requestData: TPamAccessRequestData } | null;
- return data?.requestData?.accountId === account.id;
+ return (
+ data?.requestData?.accountId === account.id &&
+ (data?.requestData?.accessType ?? PamAccessType.Session) === accessType
+ );
});
if (pendingForAccount) {
diff --git a/backend/src/ee/services/pam-access-request/pam-access-request-types.ts b/backend/src/ee/services/pam-access-request/pam-access-request-types.ts
index ed8ba230cf..c89cb26d98 100644
--- a/backend/src/ee/services/pam-access-request/pam-access-request-types.ts
+++ b/backend/src/ee/services/pam-access-request/pam-access-request-types.ts
@@ -1,7 +1,7 @@
import { ApprovalRequestApprovalDecision, ApproverType } from "@app/services/approval-policy/approval-policy-enums";
import { ActorType } from "@app/services/auth/auth-type";
-import { PamNotificationEvent } from "../pam/pam-enums";
+import { PamAccessType, PamNotificationEvent } from "../pam/pam-enums";
import { TActorContext } from "../pam/pam-permission";
export type TGetApprovalConfigurationDTO = {
@@ -31,6 +31,7 @@ export type TCreateAccessRequestDTO = {
projectId: string;
reason?: string;
duration: string;
+ accessType?: PamAccessType;
} & TActorContext;
export type TListAccessRequestsDTO = {
@@ -72,6 +73,7 @@ export type TCheckGrantDTO = {
accountId: string;
accountFolderId?: string | null;
projectId: string;
+ accessType?: PamAccessType;
} & TAccessRequestActor;
export type TPamAccessRequestData = {
@@ -79,9 +81,11 @@ export type TPamAccessRequestData = {
folderId: string;
reason?: string;
duration: string;
+ accessType?: PamAccessType;
};
export type TGetAccountApproversDTO = {
accountId: string;
projectId: string;
+ accessType?: PamAccessType;
} & TActorContext;
diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.ts
index c537e55b09..fd9fdcc57d 100644
--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts
+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts
@@ -1330,3 +1330,9 @@ export const isCredentialConfigured = (
return typeof value === "string" && value.trim().length > 0;
});
};
+
+export const hasRetrievableCredentials = (accountType: PamAccountType): boolean => {
+ const config = ACCOUNT_TYPE_CONFIGS[accountType as TSupportedAccountType];
+ if (!config) return false;
+ return fieldsFromSchema(config.credentials, config.ui).some((field) => field.secret);
+};
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index c912c3b550..6cc4063f6c 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -19,14 +19,18 @@ import { hasPostgresErrorCode } from "@app/lib/errors/postgres";
import { logger } from "@app/lib/logger";
import { createSshKeyPair, SshCertKeyAlgorithm } from "@app/lib/ssh";
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
+import { ActorType } from "@app/services/auth/auth-type";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "@app/services/kms/kms-types";
import { TMembershipDALFactory } from "@app/services/membership/membership-dal";
import { TMembershipRoleDALFactory } from "@app/services/membership/membership-role-dal";
+import { TMfaSessionServiceFactory } from "@app/services/mfa-session/mfa-session-service";
+import { TOrgDALFactory } from "@app/services/org/org-dal";
import { TUserDALFactory } from "@app/services/user/user-dal";
import { testConnectionWithGateway } from "../gateway-v2/gateway-v2-fns";
-import { PamAccessStatus, PamAccountType, PamProductRole, PamSessionStatus } from "../pam/pam-enums";
+import { PamAccessStatus, PamAccessType, PamAccountType, PamProductRole, PamSessionStatus } from "../pam/pam-enums";
+import { enforceMfa } from "../pam/pam-mfa";
import {
checkAccountAccess,
checkFolderPermission,
@@ -54,6 +58,7 @@ import { TPamAccountDALFactory } from "./pam-account-dal";
import {
applyForcedFields,
getAccountAccessibilityIssues,
+ hasRetrievableCredentials,
isCredentialConfigured,
normalizeCredentialAuthMethod,
PamAccountAccessibilityIssue,
@@ -66,6 +71,7 @@ import {
import {
TCreatePamAccountDTO,
TDeletePamAccountDTO,
+ TGetPamAccountCredentialsDTO,
TGetPamAccountDTO,
TListAccessibleAccountsDTO,
TListPamAccountsDTO,
@@ -81,6 +87,11 @@ type TPamAccountServiceFactoryDep = {
pamSessionDAL: Pick<TPamSessionDALFactory, "find" | "update">;
pamDiscoverySourceDAL: Pick<TPamDiscoverySourceDALFactory, "find">;
userDAL: Pick<TUserDALFactory, "findById">;
+ orgDAL: Pick<TOrgDALFactory, "findOrgById">;
+ mfaSessionService: Pick<
+ TMfaSessionServiceFactory,
+ "createMfaSession" | "getMfaSession" | "deleteMfaSession" | "sendMfaCode"
+ >;
permissionService: Pick<
TPermissionServiceFactory,
"getProjectPermission" | "getResourcePermission" | "getOrgPermission"
@@ -98,7 +109,7 @@ type TPamAccountServiceFactoryDep = {
appConnectionDAL: Pick<TAppConnectionDALFactory, "findOne" | "findById">;
pamAccessRequestService: Pick<
TPamAccessRequestServiceFactory,
- "getAccessStatusBatch" | "getFolderPolicyConfigured" | "cleanupAccountResources"
+ "getAccessStatusBatch" | "getFolderPolicyConfigured" | "cleanupAccountResources" | "checkGrant"
>;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
};
@@ -157,6 +168,8 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
pamSessionDAL,
pamDiscoverySourceDAL,
userDAL,
+ orgDAL,
+ mfaSessionService,
permissionService,
kmsService,
gatewayV2Service,
@@ -229,34 +242,45 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
(a) => resolveAccessControls(a.templatePolicies).requiresApproval
);
const accountIdsRequiringApproval = accountsRequiringApproval.map((a) => a.id);
+ const accountIdsRequiringCredentialApproval = accounts
+ .filter((a) => resolveAccessControls(a.templatePolicies).requiresCredentialApproval)
+ .map((a) => a.id);
const folderIdsRequiringApproval = [
...new Set(accountsRequiringApproval.map((a) => a.folderId).filter(Boolean) as string[])
];
- const [accessStatusMap, foldersWithApprovalPolicy, permissionsByAccountId] = await Promise.all([
- deps.pamAccessRequestService.getAccessStatusBatch(
- { actorId: ctx.actorId, actor: ctx.actor },
- accountIdsRequiringApproval,
- projectId
- ),
- deps.pamAccessRequestService.getFolderPolicyConfigured(folderIdsRequiringApproval),
- // Resolve every account's effective permissions in one membership fetch
- getAccountPermissionRulesMap(
- membershipDAL,
- membershipRoleDAL,
- projectId,
- accounts.map((a) => ({ id: a.id, folderId: a.folderId })),
- ctx
- )
- ]);
+ const [accessStatusMap, credentialAccessStatusMap, foldersWithApprovalPolicy, permissionsByAccountId] =
+ await Promise.all([
+ deps.pamAccessRequestService.getAccessStatusBatch(
+ { actorId: ctx.actorId, actor: ctx.actor },
+ accountIdsRequiringApproval,
+ projectId
+ ),
+ deps.pamAccessRequestService.getAccessStatusBatch(
+ { actorId: ctx.actorId, actor: ctx.actor },
+ accountIdsRequiringCredentialApproval,
+ projectId,
+ PamAccessType.Credential
+ ),
+ deps.pamAccessRequestService.getFolderPolicyConfigured(folderIdsRequiringApproval),
+ // Resolve every account's effective permissions in one membership fetch
+ getAccountPermissionRulesMap(
+ membershipDAL,
+ membershipRoleDAL,
+ projectId,
+ accounts.map((a) => ({ id: a.id, folderId: a.folderId })),
+ ctx
+ )
+ ]);
return accounts.map((a) => {
const { accessibilityIssues, isAccessible } = computeAccessibility(a);
- const { requiresApproval, requireReason } = resolveAccessControls(a.templatePolicies);
+ const { requiresApproval, requiresCredentialApproval, requireReason } = resolveAccessControls(a.templatePolicies);
if (requiresApproval && a.folderId && !foldersWithApprovalPolicy.has(a.folderId)) {
accessibilityIssues.push(PamAccountAccessibilityIssue.NoApprovalConfig);
}
const statusEntry = accessStatusMap.get(a.id);
+ const credentialStatusEntry = credentialAccessStatusMap.get(a.id);
return {
id: a.id,
name: a.name,
@@ -274,9 +298,14 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
accessibilityIssues,
isStale: a.isStale,
requiresApproval,
+ requiresCredentialApproval,
+ supportsCredentialReveal: hasRetrievableCredentials(a.accountType as PamAccountType),
requireReason,
accessStatus: requiresApproval ? (statusEntry?.accessStatus ?? PamAccessStatus.None) : PamAccessStatus.None,
grantExpiresAt: statusEntry?.grantExpiresAt ?? null,
+ credentialAccessStatus: requiresCredentialApproval
+ ? (credentialStatusEntry?.accessStatus ?? PamAccessStatus.None)
+ : PamAccessStatus.None,
permissions: permissionsByAccountId.get(a.id) ?? [],
createdAt: a.createdAt,
updatedAt: a.updatedAt
@@ -331,6 +360,103 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
};
};
+ const getCredentials = async ({
+ accountId,
+ projectId,
+ actorEmail,
+ reason,
+ mfaSessionId,
+ ...ctx
+ }: TGetPamAccountCredentialsDTO & TActorContext) => {
+ await verifyMembership(projectId, ctx);
+
+ const account = await pamAccountDAL.findByIdWithDetails(accountId);
+ if (!account || account.projectId !== projectId) {
+ throw new NotFoundError({ message: `Account with ID '${accountId}' not found` });
+ }
+
+ await checkAccount(
+ accountId,
+ account.folderId,
+ projectId,
+ ResourcePermissionPamResourceActions.ViewCredentials,
+ ctx
+ );
+
+ const accountType = account.accountType as PamAccountType;
+ if (!hasRetrievableCredentials(accountType)) {
+ throw new BadRequestError({
+ message: `Account '${account.name}' mints a short-lived credential per session and stores nothing to reveal`
+ });
+ }
+
+ const policy = resolveAccessControls(account.templatePolicies);
+ const trimmedReason = reason?.trim() || null;
+
+ let grantExpiresAt: Date | null = null;
+ if (policy.requiresCredentialApproval) {
+ const grant = await deps.pamAccessRequestService.checkGrant({
+ actorId: ctx.actorId,
+ actor: ctx.actor,
+ accountId: account.id,
+ accountFolderId: account.folderId,
+ projectId,
+ accessType: PamAccessType.Credential
+ });
+ if (!grant) {
+ throw new ForbiddenRequestError({
+ name: "PAM_APPROVAL_REQUIRED",
+ message: "Approval is required to view this account's credentials"
+ });
+ }
+
+ if (grant.expiresAt) {
+ if (new Date(grant.expiresAt).getTime() <= Date.now()) {
+ throw new ForbiddenRequestError({
+ name: "PAM_GRANT_EXPIRED",
+ message: "Your approved credential access has expired"
+ });
+ }
+ grantExpiresAt = new Date(grant.expiresAt);
+ }
+ }
+
+ if (policy.requireReason && !trimmedReason) {
+ throw new BadRequestError({
+ name: "PAM_REASON_REQUIRED",
+ message: "A reason is required to view this account's credentials"
+ });
+ }
+
+ if (policy.requireMfa) {
+ if (ctx.actor !== ActorType.USER) {
+ 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: ctx.actorId, orgId: ctx.actorOrgId, actorEmail, accountId: account.id, mfaSessionId }
+ );
+ }
+
+ const credentials = normalizeCredentialAuthMethod(
+ accountType,
+ await decrypt(projectId, account.encryptedCredentials)
+ );
+
+ return {
+ accountId: account.id,
+ accountName: account.name,
+ accountType,
+ folderId: account.folderId,
+ credentials,
+ grantExpiresAt,
+ reason: trimmedReason
+ };
+ };
+
// throws to block create/update when the account can't reach/authenticate its target
const assertConnectionOk = async (
accountType: PamAccountType,
@@ -1097,6 +1223,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
list,
listAccessible,
getById,
+ getCredentials,
create,
update,
deleteAccount,
diff --git a/backend/src/ee/services/pam-account/pam-account-types.ts b/backend/src/ee/services/pam-account/pam-account-types.ts
index 7cd932b30b..45eb10b9c6 100644
--- a/backend/src/ee/services/pam-account/pam-account-types.ts
+++ b/backend/src/ee/services/pam-account/pam-account-types.ts
@@ -43,6 +43,14 @@ export type TGetPamAccountDTO = {
projectId: string;
};
+export type TGetPamAccountCredentialsDTO = {
+ accountId: string;
+ projectId: string;
+ actorEmail: string;
+ reason?: string;
+ mfaSessionId?: string;
+};
+
export type TListPamAccountsDTO = {
projectId: string;
folderId?: string;
diff --git a/backend/src/ee/services/pam/CLAUDE.md b/backend/src/ee/services/pam/CLAUDE.md
index bda90a1286..0fd4668caa 100644
--- a/backend/src/ee/services/pam/CLAUDE.md
+++ b/backend/src/ee/services/pam/CLAUDE.md
@@ -32,7 +32,8 @@ new deps with `Pick<>`).
## Permissions
Two tiers: **product membership** (`PamProductRole`: Admin/Member) + **resource membership** scoped to a
-folder or account (`PamResourceRole`: Admin/Connector/Auditor). Shared helpers live in
+folder or account (`PamResourceRole`: Admin/Operator/Connector/Auditor; Operator is Connector plus
+`ViewCredentials`, with no approval rights so credential approval can't be self-served). Shared helpers live in
`pam/pam-permission.ts` (`verifyProductMembership`, `checkAccountAccess`, `getResourceIdsWithActions`, …) —
use them instead of re-implementing. Every list/mutation endpoint checks an **action**, not just
membership. There is **no org-admin fallback**: permission needs project-scoped membership.
@@ -59,6 +60,13 @@ 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.
+- **Session launch and credential reveal (`pamAccountService.getCredentials`) are independent gates over
+ one folder policy.** `requiresApproval` / `requiresCredentialApproval` turn them on; both use the same
+ `PamAccess` policy and approvers, told apart by `accessType` on the request data and grant attributes.
+ **A missing `accessType` means session**, so a grant predating credential access can never unlock a
+ reveal — never treat it as a wildcard. Hence `checkGrant`/`getAccessStatusBatch` take an `accessType`,
+ pending requests dedupe per (account, accessType), and `revokeGrantRow` skips session termination for a
+ credential grant.
- PAM endpoints accept JWT + identity tokens, including CLI session launch (`POST /pam/sessions/access`)
and raising access requests (`POST /pam/access-requests`); web access stays JWT-only, as does
reviewing/revoking (identities are never approvers). MFA-gated accounts still reject machine actors,
diff --git a/backend/src/ee/services/pam/pam-enums.ts b/backend/src/ee/services/pam/pam-enums.ts
index 5a8a4898da..19f0b561a7 100644
--- a/backend/src/ee/services/pam/pam-enums.ts
+++ b/backend/src/ee/services/pam/pam-enums.ts
@@ -16,6 +16,7 @@ export enum PamAccountType {
export enum PamResourceRole {
Admin = "admin",
+ Operator = "operator",
Connector = "connector",
Auditor = "auditor"
}
@@ -58,6 +59,11 @@ export enum PamPostgresAuthMethod {
AwsIam = "aws-iam"
}
+export enum PamAccessType {
+ Session = "session",
+ Credential = "credential"
+}
+
// The caller's just-in-time approval state for an account gated behind an access request flow
export enum PamAccessStatus {
None = "none",
diff --git a/backend/src/ee/services/pam/pam-policies.test.ts b/backend/src/ee/services/pam/pam-policies.test.ts
index 6ed3e17969..4aad00598d 100644
--- a/backend/src/ee/services/pam/pam-policies.test.ts
+++ b/backend/src/ee/services/pam/pam-policies.test.ts
@@ -88,6 +88,7 @@ describe("validatePolicyValues", () => {
describe("resolveAccessControls", () => {
const DEFAULTS = {
requiresApproval: false,
+ requiresCredentialApproval: false,
requireReason: false,
requireMfa: false,
maxSessionDurationSeconds: null
@@ -111,7 +112,7 @@ describe("resolveAccessControls", () => {
[PamPolicyType.RequireMfa]: true,
[PamPolicyType.MaxSessionDuration]: 3600
})
- ).toEqual({ requiresApproval: false, requireReason: true, requireMfa: true, maxSessionDurationSeconds: 3600 });
+ ).toEqual({ ...DEFAULTS, requireReason: true, requireMfa: true, maxSessionDurationSeconds: 3600 });
});
test("resolves each policy independently of the others", () => {
diff --git a/backend/src/ee/services/pam/pam-policies.ts b/backend/src/ee/services/pam/pam-policies.ts
index a44f2a788c..32bf37d922 100644
--- a/backend/src/ee/services/pam/pam-policies.ts
+++ b/backend/src/ee/services/pam/pam-policies.ts
@@ -5,6 +5,7 @@ import { PamAccountType } from "./pam-enums";
export enum PamPolicyType {
RequiresApproval = "requires-approval",
+ RequiresCredentialApproval = "requires-credential-approval",
RequireMfa = "require-mfa",
RequireReason = "require-reason",
MaxSessionDuration = "max-session-duration",
@@ -50,6 +51,8 @@ export const patternsStringSchema = (maxPatterns = 20, maxPatternLength = 500) =
{ message: "One or more patterns are not valid regular expressions" }
);
+const CREDENTIAL_BEARING_ACCOUNT_TYPES = Object.values(PamAccountType).filter((type) => type !== PamAccountType.AwsIam);
+
type TPamPolicyTypeOverride = {
description?: string;
schema?: z.ZodTypeAny;
@@ -70,6 +73,12 @@ export const PAM_POLICY_DEFINITIONS: Record<PamPolicyType, TPamPolicyDefinition>
appliesTo: "all",
schema: z.boolean()
},
+ [PamPolicyType.RequiresCredentialApproval]: {
+ label: "Require Approval for Credentials",
+ description: "Users must request and receive approval before viewing this account's credentials.",
+ appliesTo: CREDENTIAL_BEARING_ACCOUNT_TYPES,
+ schema: z.boolean()
+ },
[PamPolicyType.RequireMfa]: {
label: "Require MFA",
description: "Users must re-authenticate with MFA before accessing.",
@@ -171,6 +180,7 @@ export const resolvePolicy = (policyMap: unknown, policy: PamPolicyType): unknow
export type TPamAccessControls = {
requiresApproval: boolean;
+ requiresCredentialApproval: boolean;
requireReason: boolean;
requireMfa: boolean;
maxSessionDurationSeconds: number | null;
@@ -190,6 +200,7 @@ export const resolveAccessControls = (policyMap: unknown): TPamAccessControls =>
const duration = resolvePolicy(policyMap, PamPolicyType.MaxSessionDuration);
return {
requiresApproval: resolvePolicy(policyMap, PamPolicyType.RequiresApproval) === true,
+ requiresCredentialApproval: resolvePolicy(policyMap, PamPolicyType.RequiresCredentialApproval) === true,
requireReason: resolvePolicy(policyMap, PamPolicyType.RequireReason) === true,
requireMfa: resolvePolicy(policyMap, PamPolicyType.RequireMfa) === true,
maxSessionDurationSeconds: typeof duration === "number" ? duration : null
diff --git a/backend/src/ee/services/permission/default-roles.ts b/backend/src/ee/services/permission/default-roles.ts
index 9c51adc7fd..045b8e9d41 100644
--- a/backend/src/ee/services/permission/default-roles.ts
+++ b/backend/src/ee/services/permission/default-roles.ts
@@ -1122,6 +1122,20 @@ const buildPamResourceAdminPermissionRules = () => {
return rules;
};
+const buildPamResourceOperatorPermissionRules = () => {
+ const { can, rules } = new AbilityBuilder<MongoAbility<ResourcePermissionSet>>(createMongoAbility);
+ can(
+ [
+ ResourcePermissionPamResourceActions.ReadFolder,
+ ResourcePermissionPamResourceActions.ReadAccounts,
+ ResourcePermissionPamResourceActions.LaunchSessions,
+ ResourcePermissionPamResourceActions.ViewCredentials
+ ],
+ ResourcePermissionSub.PamResource
+ );
+ return rules;
+};
+
const buildPamResourceConnectorPermissionRules = () => {
const { can, rules } = new AbilityBuilder<MongoAbility<ResourcePermissionSet>>(createMongoAbility);
can(
@@ -1153,5 +1167,6 @@ const buildPamResourceAuditorPermissionRules = () => {
export const pamProjectAdminPermissions = projectAdminPermissions;
export const pamProjectMemberPermissions = buildPamProjectMemberPermissionRules();
export const pamResourceAdminPermissions = buildPamResourceAdminPermissionRules();
+export const pamResourceOperatorPermissions = buildPamResourceOperatorPermissionRules();
export const pamResourceConnectorPermissions = buildPamResourceConnectorPermissionRules();
export const pamResourceAuditorPermissions = buildPamResourceAuditorPermissionRules();
diff --git a/backend/src/ee/services/permission/permission-service.ts b/backend/src/ee/services/permission/permission-service.ts
index b322c33394..41afbcdf9d 100644
--- a/backend/src/ee/services/permission/permission-service.ts
+++ b/backend/src/ee/services/permission/permission-service.ts
@@ -26,6 +26,7 @@ import {
pamResourceAdminPermissions,
pamResourceAuditorPermissions,
pamResourceConnectorPermissions,
+ pamResourceOperatorPermissions,
projectAdminApplicationFallbackPermissions,
projectAdminPermissions,
projectAdminSignerFallbackPermissions,
@@ -208,6 +209,8 @@ export const resolveResourceRoleRules = (resourceType: ResourceType, role: strin
switch (role) {
case PamResourceRole.Admin:
return pamResourceAdminPermissions;
+ case PamResourceRole.Operator:
+ return pamResourceOperatorPermissions;
case PamResourceRole.Connector:
return pamResourceConnectorPermissions;
case PamResourceRole.Auditor:
diff --git a/backend/src/lib/workflow-integrations/types.ts b/backend/src/lib/workflow-integrations/types.ts
index 9932088906..5c55e9fc08 100644
--- a/backend/src/lib/workflow-integrations/types.ts
+++ b/backend/src/lib/workflow-integrations/types.ts
@@ -83,6 +83,7 @@ export type TNotification =
accountName: string;
folderName: string;
accessDuration: string;
+ accessTypeLabel?: string;
reason?: string;
approvalUrl: string;
};
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 24f18e5e6e..2b5115f5c4 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -2002,6 +2002,8 @@ export const registerRoutes = async (
pamSessionDAL,
pamDiscoverySourceDAL,
userDAL,
+ orgDAL,
+ mfaSessionService,
permissionService,
kmsService,
gatewayV2DAL,
diff --git a/backend/src/services/slack/slack-fns.ts b/backend/src/services/slack/slack-fns.ts
index 939d409cd4..4f68414bbd 100644
--- a/backend/src/services/slack/slack-fns.ts
+++ b/backend/src/services/slack/slack-fns.ts
@@ -270,8 +270,9 @@ const buildSlackPayload = (notification: TNotification) => {
const accountName = escapeSlackMrkdwn(payload.accountName);
const folderName = escapeSlackMrkdwn(payload.folderName);
const reason = payload.reason ? escapeSlackMrkdwn(payload.reason) : undefined;
+ const accessTypeLabel = escapeSlackMrkdwn(payload.accessTypeLabel ?? "access");
- const messageBody = `${requesterFullName} (${requesterEmail}) has requested access to ${accountName} in the ${folderName} folder.\n\nDuration: ${payload.accessDuration}${
+ const messageBody = `${requesterFullName} (${requesterEmail}) has requested ${accessTypeLabel} to ${accountName} in the ${folderName} folder.\n\nDuration: ${payload.accessDuration}${
reason ? `\n\nReason: ${reason}` : ""
}`;
@@ -291,7 +292,7 @@ const buildSlackPayload = (notification: TNotification) => {
type: "section",
text: {
type: "mrkdwn",
- text: `*${requesterFullName}* (${requesterEmail}) has requested access to *${accountName}* in the *${folderName}* folder.\n\n*Duration:* ${payload.accessDuration}${
+ text: `*${requesterFullName}* (${requesterEmail}) has requested ${accessTypeLabel} to *${accountName}* in the *${folderName}* folder.\n\n*Duration:* ${payload.accessDuration}${
reason ? `\n\n*Reason:* ${reason}` : ""
}`
}
diff --git a/backend/src/services/smtp/emails/AccessPamRequestTemplate.tsx b/backend/src/services/smtp/emails/AccessPamRequestTemplate.tsx
index 28e06f3468..995eb984d2 100644
--- a/backend/src/services/smtp/emails/AccessPamRequestTemplate.tsx
+++ b/backend/src/services/smtp/emails/AccessPamRequestTemplate.tsx
@@ -11,6 +11,7 @@ interface AccessPamRequestTemplateProps extends Omit<BaseEmailWrapperProps, "tit
accountName?: string;
folderName?: string;
accessDuration: string;
+ accessTypeLabel?: string;
reason?: string;
approvalUrl: string;
}
@@ -22,6 +23,7 @@ export const AccessPamRequestTemplate = ({
accountName,
folderName,
accessDuration,
+ accessTypeLabel = "access",
reason,
approvalUrl
}: AccessPamRequestTemplateProps) => {
@@ -39,7 +41,7 @@ export const AccessPamRequestTemplate = ({
<Section className="px-[24px] mb-[28px] mt-[36px] pt-[12px] pb-[8px] border border-solid border-gray-200 rounded-md bg-gray-50">
<Text className="text-black text-[14px] leading-[24px]">
<strong>{requesterFullName}</strong> (<BaseLink href={`mailto:${requesterEmail}`}>{requesterEmail}</BaseLink>)
- has requested access to <strong>{target}</strong> for <strong>{accessDuration}</strong>.
+ has requested {accessTypeLabel} to <strong>{target}</strong> for <strong>{accessDuration}</strong>.
</Text>
{reason && (
<Text className="text-[14px] text-slate-700 leading-[24px]">
diff --git a/docs/docs.json b/docs/docs.json
index 8e71f3e81c..dae5e9fb86 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -746,6 +746,7 @@
"group": "Accounts",
"pages": [
"documentation/platform/pam/accounts/overview",
+ "documentation/platform/pam/accounts/viewing-credentials",
"documentation/platform/pam/accounts/postgresql",
"documentation/platform/pam/accounts/mysql",
"documentation/platform/pam/accounts/mssql",
diff --git a/docs/documentation/platform/pam/access-requests/overview.mdx b/docs/documentation/platform/pam/access-requests/overview.mdx
index 244dbdf2dd..d23ee39f92 100644
--- a/docs/documentation/platform/pam/access-requests/overview.mdx
+++ b/docs/documentation/platform/pam/access-requests/overview.mdx
@@ -6,13 +6,20 @@ description: "Require approval before a member can use a sensitive account."
Some [accounts](/documentation/platform/pam/accounts/overview) are sensitive enough that simply having access to them should not be enough to use them. A production database or a domain admin account should be reachable only by people who are already trusted, but even for them, each individual use should clear an extra checkpoint. Access requests add that checkpoint: before a member can [launch a session](/documentation/platform/pam/sessions/overview) on a gated account, their access has to be approved.
+An account can gate two things independently, and each is requested separately:
+
+- **Session access**, gated by the template's **Require Approval** policy.
+- **Credential access**, gated by **Require Approval for Credentials**. See [Viewing credentials](/documentation/platform/pam/accounts/viewing-credentials).
+
+Everything below applies to both. An approved session request never reveals the credential, and an approved credential request never launches a session, so a member who needs both files both.
+
The same checkpoint applies to [AI agents](/documentation/platform/pam/ai-agents/overview). An agent requests access as whoever started it, a person or a [machine identity](/documentation/platform/identities/machine-identities), and waits for an approver either way.
## How it works
Approval sits on top of the access a member already holds. Two layers apply to a gated account:
-- **Membership** grants use access, the right to launch a session and connect to the account. This comes from the [Connector or Admin role](/documentation/platform/pam/concepts/access-control) on the [folder](/documentation/platform/pam/folders/overview) or account, and it is the record of who can ever get in.
+- **Membership** grants use access, the right to launch a session and connect to the account. This comes from the [Admin, Operator, or Connector role](/documentation/platform/pam/concepts/access-control) on the [folder](/documentation/platform/pam/folders/overview) or account, and it is the record of who can ever get in. Credential access needs the Operator or Admin role specifically.
- **Approval** decides whether a member is cleared to use that access right now.
A gated account needs both. A member requests access on an account they can already use, an approver signs off, and the member's access opens for the duration they asked for. When the duration runs out, the access closes again.
@@ -76,7 +83,7 @@ Once approved, the key icon switches to the rocket icon and the member can launc
### Reviewing a request
-Approvers are notified by email and in the app when a request needs them. From **Approval Requests**, an approver sees the requests waiting on them, each showing the requester, account, folder, reason, and duration.
+Approvers are notified by email and in the app when a request needs them. From **Approval Requests**, an approver sees the requests waiting on them, each showing the requester, account, folder, reason, and duration. A credential request carries a **Credentials** badge, so an approver can tell at a glance that approving hands over the raw password rather than opening a recorded session.
They **approve** or **reject** the request. A single approval from any one of the folder's seated approvers clears it; it does not have to come from a specific person.
@@ -129,6 +136,8 @@ When an agent reaches for a gated account, the request is filed for it automatic
</Accordion>
<Accordion title="Who can revoke access once it is granted?">
A Folder Admin. Revoking ends an active request right away and cuts off access before its duration runs out. Any active session using that access is terminated immediately.
+
+ Revoking a credential request is weaker: it stops further reveals, but a credential already copied is outside Infisical and stays valid until the account is rotated. It also leaves live sessions alone, since those are authorized by their own grant.
</Accordion>
<Accordion title="Do changes to a folder's approvers apply to requests already in flight?">
Removing an approver takes effect right away: someone dropped from the folder's approvers can no longer act on a request that is still pending. Adding an approver does not reach back into requests already in flight, so a pending request can only be cleared by the approvers it had when it was created. An approved request is already granted and keeps its access until it expires or is revoked, whatever changes afterward.
diff --git a/docs/documentation/platform/pam/accounts/viewing-credentials.mdx b/docs/documentation/platform/pam/accounts/viewing-credentials.mdx
new file mode 100644
index 0000000000..657cf7d778
--- /dev/null
+++ b/docs/documentation/platform/pam/accounts/viewing-credentials.mdx
@@ -0,0 +1,106 @@
+---
+title: "Viewing credentials"
+sidebarTitle: "Viewing credentials"
+description: "Read an account's stored password or key, with approval and an audit trail."
+---
+
+Most privileged work in Infisical never needs the password. A member [launches a session](/documentation/platform/pam/sessions/overview), the Gateway injects the credential, and the session is recorded. The credential stays inside the platform.
+
+Some work still needs the credential itself. A DBA has to paste a password into a desktop client that Infisical does not broker, or an engineer has to configure an appliance by hand. Viewing credentials covers that case: a member reads the stored password or key directly, once approved, and the reveal lands in the audit log.
+
+<Warning>
+ A revealed credential is outside Infisical. There is no session recording, no command blocking, and no way to end the access early. Prefer a session wherever one will do, and gate credential access with approval where you cannot.
+</Warning>
+
+## Who can view a credential
+
+Two things have to hold.
+
+- **Permission.** The member needs the **Operator** or **Admin** [role](/documentation/platform/pam/concepts/access-control) on the folder or account. Connector and Auditor cannot view credentials.
+- **Approval**, when the account's [template](/documentation/platform/pam/templates/overview) turns on **Require Approval for Credentials**. The member requests credential access and an approver signs off before the reveal works.
+
+This mirrors how session gating works: permission is the record of who can ever read the credential, and approval decides whether they are cleared to read it right now.
+
+## Viewing a credential
+
+<Steps>
+ <Step title="Open the account's menu">
+ From the **Accounts** page, open the menu on the account row and choose **View Credentials**. On a gated account the entry reads **Request Credentials** instead until you hold an approval.
+ </Step>
+ <Step title="Give a reason">
+ Enter why you need the credential. The reason is required when the template turns on **Require Reason**, and is recorded either way.
+ </Step>
+ <Step title="Complete MFA, if the template requires it">
+ An account whose template turns on **Require MFA** challenges you before the reveal, the same as it does before a session.
+ </Step>
+ <Step title="Read or copy the credential">
+ Sensitive fields are masked until you reveal them.
+ </Step>
+</Steps>
+
+## Gating credential access with approval
+
+Approval for credentials is configured the same way as approval for sessions, and shares the same approvers.
+
+<Steps>
+ <Step title="Turn on the policy (Product Admin)">
+ Go to **Privileged Access Management → Account Templates**, open the template for the account type, and turn on **Require Approval for Credentials**.
+ </Step>
+ <Step title="Onboard the account with that template (Folder Admin)">
+ Accounts using the template inherit the requirement.
+ </Step>
+ <Step title="Seat approvers in the folder (Folder Admin)">
+ Open the folder and go to its **Approvals** tab. The approvers seated there review both session and credential requests for the folder's accounts.
+ </Step>
+</Steps>
+
+A credential request carries a reason and a duration, is reviewed from **Approval Requests** like any other, and shows a **Credentials** badge so an approver can tell it apart from a session request. Once approved, the member can reveal the credential until the duration runs out.
+
+<Note>
+ Session and credential grants are independent. An approved session request never reveals the credential, and an approved credential request never launches a session. A member who needs both files both.
+</Note>
+
+## Rotate after a checkout
+
+A credential that has left the platform should not stay valid indefinitely. For account types that support it, set up [credential rotation](/documentation/platform/pam/accounts/overview) on the account so the revealed password is replaced on a schedule, and rotate on demand after a checkout you want to close out immediately.
+
+## Auditing
+
+Every reveal writes a **View PAM Account Credentials** entry to the [audit log](/documentation/platform/pam/auditing) with the member, the account, the reason they gave, and when their approval expires. The log is the record of who holds a credential outside Infisical, so review it alongside session recordings.
+
+## Frequently asked questions
+
+<AccordionGroup>
+ <Accordion title="Which account types can have their credentials viewed?">
+ Any account that stores a credential. AWS IAM accounts are the exception: Infisical assumes a role rather than storing a secret, so there is nothing to reveal and the option does not appear.
+ </Accordion>
+ <Accordion title="Can a machine identity view a credential?">
+ Yes, if it holds Operator or Admin on the folder or account, and an approval when the account is gated. An account whose template requires MFA stays out of reach, since no machine can complete the challenge.
+ </Accordion>
+ <Accordion title="Does revoking a credential grant take the credential back?">
+ No. Revoking stops further reveals, but a credential already copied is out of the platform and stays valid until it is rotated. Rotate the account to close that off.
+ </Accordion>
+ <Accordion title="Does revoking a credential grant end the member's sessions?">
+ No. Sessions are authorized by their own grant, so revoking credential access leaves live sessions running. Revoke the session grant to end those.
+ </Accordion>
+ <Accordion title="Can an approver approve their own credential request?">
+ No, the same separation of duties applies as for session requests. This is why the Operator role carries no approval rights: an Operator can request credential access but never clear their own request.
+ </Accordion>
+</AccordionGroup>
+
+## Next steps
+
+<CardGroup cols={2}>
+ <Card title="Access requests" icon="key" href="/documentation/platform/pam/access-requests/overview">
+ Gate sessions with the same approvers.
+ </Card>
+ <Card title="Account templates" icon="layer-group" href="/documentation/platform/pam/templates/overview">
+ Turn on Require Approval for Credentials.
+ </Card>
+ <Card title="Access control" icon="lock" href="/documentation/platform/pam/concepts/access-control">
+ Grant the Operator role.
+ </Card>
+ <Card title="Auditing" icon="list-check" href="/documentation/platform/pam/auditing">
+ Review who revealed which credential.
+ </Card>
+</CardGroup>
diff --git a/docs/documentation/platform/pam/concepts/access-control.mdx b/docs/documentation/platform/pam/concepts/access-control.mdx
index ad7b902a78..7916d329b5 100644
--- a/docs/documentation/platform/pam/concepts/access-control.mdx
+++ b/docs/documentation/platform/pam/concepts/access-control.mdx
@@ -48,9 +48,14 @@ Once someone is a product member, they still need to be granted access to specif
| Role | What they can do |
|------|------------------|
| **Admin** | Full control — accounts, folders, sessions, memberships |
+| **Operator** | Launch sessions and [view account credentials](/documentation/platform/pam/accounts/viewing-credentials) |
| **Connector** | Launch sessions and connect to accounts |
| **Auditor** | View audit logs and session recordings |
+<Note>
+ **Operator** is Connector plus the right to read an account's stored password or key. Grant it only where someone genuinely needs the credential in hand, since a revealed credential leaves no session recording. An Operator cannot approve requests or change configuration, so an account gated with **Require Approval for Credentials** still needs someone else to sign off.
+</Note>
+
### Folder vs account memberships
You can assign roles at two levels:
diff --git a/docs/documentation/platform/pam/templates/overview.mdx b/docs/documentation/platform/pam/templates/overview.mdx
index b24ba4542b..711e824b28 100644
--- a/docs/documentation/platform/pam/templates/overview.mdx
+++ b/docs/documentation/platform/pam/templates/overview.mdx
@@ -34,11 +34,17 @@ If you need different rules — say, 4-hour sessions with MFA for production —
<Step title="Configure policies">
| Option | What it does |
|--------|--------------|
+ | **Require Approval** | Users must request and receive approval before launching a session |
+ | **Require Approval for Credentials** | Users must request and receive approval before [viewing the account's credentials](/documentation/platform/pam/accounts/viewing-credentials) |
| **Require MFA** | Users must re-authenticate with MFA before connecting |
| **Require Reason** | A reason must be provided before connecting |
| **Max Session Duration** | How long someone can stay connected (in seconds) |
| **Command Blocking** | Regex patterns for commands to reject (one per line). Currently SSH only. |
+ <Note>
+ The two approval options are separate gates. Turning on **Require Approval** does not gate the credential, and an approved session request does not reveal it. Gate both if a session and the raw password should each need sign-off.
+ </Note>
+
<Note>
**Require MFA** puts an account out of reach of [AI agents](/documentation/platform/pam/ai-agents/overview), which cannot complete the challenge yet, and of [machine identities](/documentation/platform/identities/machine-identities), which never can. For accounts an agent needs, use a template without it and gate access with [approvals](/documentation/platform/pam/access-requests/overview) instead.
</Note>
diff --git a/frontend/src/hooks/api/auditLogs/constants.tsx b/frontend/src/hooks/api/auditLogs/constants.tsx
index c873899893..05b76cfecb 100644
--- a/frontend/src/hooks/api/auditLogs/constants.tsx
+++ b/frontend/src/hooks/api/auditLogs/constants.tsx
@@ -362,6 +362,7 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.PAM_ACCOUNT_ROTATE_CREDENTIALS]: "Rotate PAM Account Credentials",
[EventType.PAM_ACCOUNT_SET_ROTATION_ACCOUNT]: "Set PAM Account Rotation Account",
[EventType.PAM_ACCOUNT_SSH_CA_CREATE]: "Create PAM Account SSH CA",
+ [EventType.PAM_ACCOUNT_CREDENTIALS_VIEW]: "View PAM Account Credentials",
[EventType.PAM_APPROVAL_CONFIG_UPDATE]: "Update PAM Approval Configuration",
[EventType.PAM_DISCOVERY_SOURCE_CREATE]: "Create PAM Discovery Source",
[EventType.PAM_DISCOVERY_SOURCE_UPDATE]: "Update PAM Discovery Source",
@@ -496,6 +497,7 @@ export const projectToEventsMap: Partial<Record<ProjectType, EventType[]>> = {
EventType.PAM_ACCOUNT_ROTATE_CREDENTIALS,
EventType.PAM_ACCOUNT_SET_ROTATION_ACCOUNT,
EventType.PAM_ACCOUNT_SSH_CA_CREATE,
+ EventType.PAM_ACCOUNT_CREDENTIALS_VIEW,
EventType.PAM_APPROVAL_CONFIG_UPDATE,
EventType.PAM_DISCOVERY_SOURCE_CREATE,
EventType.PAM_DISCOVERY_SOURCE_UPDATE,
diff --git a/frontend/src/hooks/api/auditLogs/enums.tsx b/frontend/src/hooks/api/auditLogs/enums.tsx
index 2abe4658a1..632dce43df 100644
--- a/frontend/src/hooks/api/auditLogs/enums.tsx
+++ b/frontend/src/hooks/api/auditLogs/enums.tsx
@@ -350,6 +350,7 @@ export enum EventType {
PAM_ACCOUNT_ROTATE_CREDENTIALS = "pam-account-rotate-credentials",
PAM_ACCOUNT_SET_ROTATION_ACCOUNT = "pam-account-set-rotation-account",
PAM_ACCOUNT_SSH_CA_CREATE = "pam-account-ssh-ca-create",
+ PAM_ACCOUNT_CREDENTIALS_VIEW = "pam-account-credentials-view",
PAM_APPROVAL_CONFIG_UPDATE = "pam-approval-config-update",
PAM_DISCOVERY_SOURCE_CREATE = "pam-discovery-source-create",
PAM_DISCOVERY_SOURCE_UPDATE = "pam-discovery-source-update",
diff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.ts
index 261fe22a7d..9b16a4431c 100644
--- a/frontend/src/hooks/api/pam/enums.ts
+++ b/frontend/src/hooks/api/pam/enums.ts
@@ -64,6 +64,7 @@ export const formatRotationInterval = (seconds: number | null | undefined): stri
export enum PamPolicyType {
RequiresApproval = "requires-approval",
+ RequiresCredentialApproval = "requires-credential-approval",
RequireMfa = "require-mfa",
RequireReason = "require-reason",
MaxSessionDuration = "max-session-duration",
@@ -117,6 +118,11 @@ export enum PamResourcePermissionActions {
ViewAuditLogs = "view-audit-logs"
}
+export enum PamAccessType {
+ Session = "session",
+ Credential = "credential"
+}
+
// The caller's just-in-time approval state for an account gated behind an access request flow
export enum PamAccessStatus {
None = "none",
diff --git a/frontend/src/hooks/api/pam/mutations.tsx b/frontend/src/hooks/api/pam/mutations.tsx
index d08b5b0649..75c973ccec 100644
--- a/frontend/src/hooks/api/pam/mutations.tsx
+++ b/frontend/src/hooks/api/pam/mutations.tsx
@@ -23,9 +23,11 @@ import {
TDeletePamAccountTemplateDTO,
TDeletePamDiscoverySourceDTO,
TDeletePamFolderDTO,
+ TGetPamAccountCredentialsDTO,
TImportPamDiscoveredAccountResult,
TImportPamDiscoveredAccountsDTO,
TPamAccessResponse,
+ TPamAccountCredentials,
TPamAccountTemplate,
TPamDiscoverySource,
TPamFolder,
@@ -779,6 +781,18 @@ export const useCreatePamAccessRequest = () => {
});
};
+export const usePamAccountCredentials = () => {
+ return useMutation({
+ mutationFn: async ({ accountId, reason, mfaSessionId }: TGetPamAccountCredentialsDTO) => {
+ const { data } = await apiRequest.post<TPamAccountCredentials>(
+ `/api/v1/pam/accounts/${accountId}/credentials`,
+ { reason, mfaSessionId }
+ );
+ return data;
+ }
+ });
+};
+
export const useRotatePamAccount = () => {
const queryClient = useQueryClient();
return useMutation({
diff --git a/frontend/src/hooks/api/pam/queries.tsx b/frontend/src/hooks/api/pam/queries.tsx
index 48d6018910..d992197c5d 100644
--- a/frontend/src/hooks/api/pam/queries.tsx
+++ b/frontend/src/hooks/api/pam/queries.tsx
@@ -12,6 +12,7 @@ import { conditionsMatcher } from "@app/hooks/api/roles/permission-matcher";
import {
PamAccessStatus,
+ PamAccessType,
PamAccountType,
PamApproverType,
PamResourcePermissionActions,
@@ -110,8 +111,8 @@ export const pamKeys = {
pendingMyApproval: (params?: { folderId?: string }) =>
[...pamKeys.accessRequest(), "pending-my-approval", params] as const,
accessRequestCount: () => [...pamKeys.accessRequest(), "count"] as const,
- accountApprovers: (accountId: string) =>
- [...pamKeys.accessRequest(), "account-approvers", accountId] as const,
+ accountApprovers: (accountId: string, accessType: PamAccessType) =>
+ [...pamKeys.accessRequest(), "account-approvers", accountId, accessType] as const,
listAccessRequests: (params?: {
folderId?: string;
status?: string;
@@ -210,9 +211,12 @@ export type TPamAccountListItem = {
// the latest discovery scan didn't find it. Informational only, nothing about the account is blocked.
isStale: boolean;
requiresApproval: boolean;
+ requiresCredentialApproval: boolean;
+ supportsCredentialReveal: boolean;
requireReason: boolean;
accessStatus: PamAccessStatus;
grantExpiresAt: string | null;
+ credentialAccessStatus: PamAccessStatus;
permissions: ResourcePermissionResponse<PamFolderPermissionSet>["permissions"];
createdAt: string;
updatedAt: string;
@@ -237,9 +241,10 @@ export const useListPamAccounts = (
// poll while any are on screen so rows don't stay stuck as pending or still show Launch until a
// manual refresh; a fully static list costs nothing. Mirrors useListAccessiblePamAccounts.
refetchInterval: (query) => {
- const hasLiveAccessState = query.state.data?.some(
- (a) =>
- a.accessStatus === PamAccessStatus.Granted || a.accessStatus === PamAccessStatus.Pending
+ const hasLiveAccessState = query.state.data?.some((a) =>
+ [a.accessStatus, a.credentialAccessStatus].some(
+ (status) => status === PamAccessStatus.Granted || status === PamAccessStatus.Pending
+ )
);
return hasLiveAccessState ? 60_000 : false;
}
@@ -610,13 +615,17 @@ export type TPamApprovalWorkflowStep = {
approvers: { type: PamApproverType; name: string; memberCount?: number }[];
};
-export const useGetPamAccountApprovers = (accountId?: string) => {
+export const useGetPamAccountApprovers = (
+ accountId?: string,
+ accessType: PamAccessType = PamAccessType.Session
+) => {
return useQuery({
- queryKey: pamKeys.accountApprovers(accountId ?? ""),
+ queryKey: pamKeys.accountApprovers(accountId ?? "", accessType),
enabled: Boolean(accountId),
queryFn: async () => {
const { data } = await apiRequest.get<{ steps: TPamApprovalWorkflowStep[] }>(
- `/api/v1/pam/access-requests/accounts/${accountId}/approvers`
+ `/api/v1/pam/access-requests/accounts/${accountId}/approvers`,
+ { params: { accessType } }
);
return data.steps;
}
diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.ts
index 2cc4b99c6f..80c5558409 100644
--- a/frontend/src/hooks/api/pam/types/index.ts
+++ b/frontend/src/hooks/api/pam/types/index.ts
@@ -2,6 +2,7 @@ import { OrderByDirection } from "../../generic/types";
import {
PamAccessRequestDecision,
PamAccessStatus,
+ PamAccessType,
PamAccountOrderBy,
PamAccountType,
PamAccountView,
@@ -226,6 +227,17 @@ export type TPamAccount = {
updatedAt: string;
};
+export type TPamAccountCredentials = {
+ accountType: PamAccountType;
+ credentials: Record<string, unknown>;
+};
+
+export type TGetPamAccountCredentialsDTO = {
+ accountId: string;
+ reason?: string;
+ mfaSessionId?: string;
+};
+
export type TPamFolder = {
id: string;
parentId?: string | null;
@@ -339,6 +351,8 @@ export type TAccessiblePamAccount = {
requireReason?: boolean;
accessStatus?: PamAccessStatus;
grantExpiresAt?: string | null;
+ requiresCredentialApproval?: boolean;
+ credentialAccessStatus?: PamAccessStatus;
disabledReason?: string | null;
createdAt: string;
updatedAt: string;
@@ -686,6 +700,7 @@ export type TPamAccessRequest = {
folderId: string;
reason?: string;
duration: string;
+ accessType?: PamAccessType;
};
} | null;
expiresAt: string | null;
@@ -698,6 +713,7 @@ export type TPamAccessRequest = {
accountType?: PamAccountType;
folderName?: string;
host?: string;
+ accessType?: PamAccessType;
grantExpiresAt?: string | null;
grantStatus?: string | null;
};
@@ -737,6 +753,7 @@ export type TCreatePamAccessRequestDTO = {
accountId: string;
reason?: string;
duration: string;
+ accessType?: PamAccessType;
};
export type TReviewPamAccessRequestDTO = {
diff --git a/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsx b/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsx
index 6005ba0da3..984d492c61 100644
--- a/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsx
@@ -41,6 +41,7 @@ import {
import { Skeleton } from "@app/components/v3/generic/Skeleton";
import { useOrganization } from "@app/context";
import {
+ PamAccessType,
PamAccountType,
PamResourcePermissionActions,
TAccessiblePamAccount,
@@ -67,6 +68,7 @@ import { DeleteAccountModal } from "./components/DeleteAccountModal";
import { DeleteFolderModal } from "./components/DeleteFolderModal";
import { FolderAccountRows } from "./components/FolderAccountRows";
import { FolderDetailSheet } from "./components/FolderDetailSheet";
+import { ViewCredentialsModal } from "./components/ViewCredentialsModal";
const SKELETON_KEYS = ["s1", "s2", "s3", "s4", "s5"];
@@ -95,6 +97,18 @@ export const PamAccountsPage = () => {
// For regular users - request access flow
const [requestAccount, setRequestAccount] = useState<TAccessiblePamAccount | null>(null);
+ const [requestAccessType, setRequestAccessType] = useState(PamAccessType.Session);
+ const [credentialAccount, setCredentialAccount] = useState<TAccessiblePamAccount | null>(null);
+
+ const requestSessionAccess = (account: TAccessiblePamAccount) => {
+ setRequestAccessType(PamAccessType.Session);
+ setRequestAccount(account);
+ };
+
+ const requestCredentialAccess = (account: TAccessiblePamAccount) => {
+ setRequestAccessType(PamAccessType.Credential);
+ setRequestAccount(account);
+ };
const { popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
"createAccount",
@@ -330,7 +344,9 @@ export const PamAccountsPage = () => {
}
onOpenAccount={(id, tab) => accountSheet.openSheet(id, tab)}
onLaunchAccount={setLaunchAccount}
- onRequestAccess={setRequestAccount}
+ onRequestAccess={requestSessionAccess}
+ onViewCredentials={setCredentialAccount}
+ onRequestCredentialAccess={requestCredentialAccess}
onDeleteAccount={(accountId, accountName, accountType) =>
handlePopUpOpen("deleteAccount", {
accountId,
@@ -433,11 +449,23 @@ export const PamAccountsPage = () => {
<RequestAccessSheet
account={requestAccount}
+ accessType={requestAccessType}
isOpen={!!requestAccount}
onOpenChange={(open) => {
if (!open) setRequestAccount(null);
}}
/>
+
+ <ViewCredentialsModal
+ accountId={credentialAccount?.id}
+ accountName={credentialAccount?.name}
+ accountType={credentialAccount?.accountType}
+ requireReason={Boolean(credentialAccount?.requireReason)}
+ isOpen={credentialAccount !== null}
+ onOpenChange={(open) => {
+ if (!open) setCredentialAccount(null);
+ }}
+ />
</div>
);
};
diff --git a/frontend/src/pages/pam/PamAccountsPage/PamFolderPage/PamFolderPage.tsx b/frontend/src/pages/pam/PamAccountsPage/PamFolderPage/PamFolderPage.tsx
index f40ebec74e..3ad92007f2 100644
--- a/frontend/src/pages/pam/PamAccountsPage/PamFolderPage/PamFolderPage.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/PamFolderPage/PamFolderPage.tsx
@@ -44,6 +44,7 @@ import {
import { Skeleton } from "@app/components/v3/generic/Skeleton";
import { ROUTE_PATHS } from "@app/const/routes";
import {
+ PamAccessType,
PamAccountType,
PamResourcePermissionActions,
TAccessiblePamAccount,
@@ -70,6 +71,7 @@ import { DeleteAccountModal } from "../components/DeleteAccountModal";
import { DeleteFolderModal } from "../components/DeleteFolderModal";
import { FolderAccountRow } from "../components/FolderAccountRow";
import { FolderDetailSheet } from "../components/FolderDetailSheet";
+import { ViewCredentialsModal } from "../components/ViewCredentialsModal";
const SKELETON_KEYS = ["s1", "s2", "s3", "s4", "s5"];
@@ -123,6 +125,18 @@ export const PamFolderPage = () => {
const [launchAccount, setLaunchAccount] = useState<TAccessiblePamAccount | null>(null);
const [requestAccount, setRequestAccount] = useState<TAccessiblePamAccount | null>(null);
+ const [requestAccessType, setRequestAccessType] = useState(PamAccessType.Session);
+ const [credentialAccount, setCredentialAccount] = useState<TAccessiblePamAccount | null>(null);
+
+ const requestSessionAccess = (account: TAccessiblePamAccount) => {
+ setRequestAccessType(PamAccessType.Session);
+ setRequestAccount(account);
+ };
+
+ const requestCredentialAccess = (account: TAccessiblePamAccount) => {
+ setRequestAccessType(PamAccessType.Credential);
+ setRequestAccount(account);
+ };
const accountsRoute = {
to: "/organizations/$orgId/pam/accounts",
@@ -376,7 +390,9 @@ export const PamFolderPage = () => {
search={debouncedSearch}
onOpenAccount={(id, tab) => accountSheet.openSheet(id, tab)}
onLaunchAccount={setLaunchAccount}
- onRequestAccess={setRequestAccount}
+ onRequestAccess={requestSessionAccess}
+ onViewCredentials={setCredentialAccount}
+ onRequestCredentialAccess={requestCredentialAccess}
onDeleteAccount={(accountId, accountName, accountType) =>
handlePopUpOpen("deleteAccount", { accountId, accountName, accountType })
}
@@ -451,11 +467,23 @@ export const PamFolderPage = () => {
<RequestAccessSheet
account={requestAccount}
+ accessType={requestAccessType}
isOpen={!!requestAccount}
onOpenChange={(open) => {
if (!open) setRequestAccount(null);
}}
/>
+
+ <ViewCredentialsModal
+ accountId={credentialAccount?.id}
+ accountName={credentialAccount?.name}
+ accountType={credentialAccount?.accountType}
+ requireReason={Boolean(credentialAccount?.requireReason)}
+ isOpen={credentialAccount !== null}
+ onOpenChange={(open) => {
+ if (!open) setCredentialAccount(null);
+ }}
+ />
</div>
);
};
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx b/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx
index 81399b9eb5..26ddf2abff 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx
@@ -1,4 +1,4 @@
-import { Clock, KeyRound, MoreHorizontal, Rocket, Settings, Trash2 } from "lucide-react";
+import { Clock, Eye, KeyRound, MoreHorizontal, Rocket, Settings, Trash2 } from "lucide-react";
import {
DropdownMenu,
@@ -27,8 +27,13 @@ type Props = {
isAccessible: boolean;
requiresApproval: boolean;
accessStatus: PamAccessStatus;
+ requiresCredentialApproval: boolean;
+ supportsCredentialReveal: boolean;
+ credentialAccessStatus: PamAccessStatus;
onLaunch: () => void;
onRequestAccess: () => void;
+ onViewCredentials: () => void;
+ onRequestCredentialAccess: () => void;
onOpenTab: (tab: PamSheetTab) => void;
onDelete: () => void;
};
@@ -39,13 +44,20 @@ export const AccountActionsMenu = ({
isAccessible,
requiresApproval,
accessStatus,
+ requiresCredentialApproval,
+ supportsCredentialReveal,
+ credentialAccessStatus,
onLaunch,
onRequestAccess,
+ onViewCredentials,
+ onRequestCredentialAccess,
onOpenTab,
onDelete
}: Props) => {
const canLaunch = can(PamResourcePermissionActions.LaunchSessions);
const canDelete = can(PamResourcePermissionActions.DeleteAccounts);
+ const canViewCredentials =
+ supportsCredentialReveal && can(PamResourcePermissionActions.ViewCredentials);
const isRotatable = isRotatablePamAccountType(accountType);
const isGranted = accessStatus === PamAccessStatus.Granted;
@@ -58,6 +70,10 @@ export const AccountActionsMenu = ({
// Launch requires: account is provisioned AND user has permission AND (no approval needed OR already granted)
const canLaunchNow = isAccessible && canLaunch && (!requiresApproval || isGranted);
+ const isCredentialPending = credentialAccessStatus === PamAccessStatus.Pending;
+ const needsCredentialApproval =
+ requiresCredentialApproval && credentialAccessStatus !== PamAccessStatus.Granted;
+
const availableTabs = PAM_ACCOUNT_TABS.filter(
(tab) => (tab.value !== PamSheetTab.Rotation || isRotatable) && (!tab.action || can(tab.action))
);
@@ -114,6 +130,34 @@ export const AccountActionsMenu = ({
{!canLaunchNow && <TooltipContent side="left">{launchDisabledReason}</TooltipContent>}
</Tooltip>
)}
+ {canViewCredentials &&
+ (needsCredentialApproval ? (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <div>
+ <DropdownMenuItem
+ isDisabled={isCredentialPending}
+ onClick={onRequestCredentialAccess}
+ >
+ {isCredentialPending ? (
+ <Clock className="size-4" />
+ ) : (
+ <KeyRound className="size-4" />
+ )}
+ {isCredentialPending ? "Credential Request Pending" : "Request Credentials"}
+ </DropdownMenuItem>
+ </div>
+ </TooltipTrigger>
+ {isCredentialPending && (
+ <TooltipContent side="left">Your request is awaiting approval</TooltipContent>
+ )}
+ </Tooltip>
+ ) : (
+ <DropdownMenuItem onClick={onViewCredentials}>
+ <Eye className="size-4" />
+ View Credentials
+ </DropdownMenuItem>
+ ))}
<DropdownMenuSeparator />
<Tooltip>
<TooltipTrigger asChild>
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsx
index e89d36581a..9fa7188f8e 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsx
@@ -19,6 +19,8 @@ type Props = {
onOpenAccount: (accountId: string, tab?: PamSheetTab) => void;
onLaunchAccount: (account: TAccessiblePamAccount) => void;
onRequestAccess: (account: TAccessiblePamAccount) => void;
+ onViewCredentials: (account: TAccessiblePamAccount) => void;
+ onRequestCredentialAccess: (account: TAccessiblePamAccount) => void;
onDeleteAccount: (accountId: string, accountName: string, accountType: PamAccountType) => void;
indented?: boolean;
};
@@ -29,6 +31,8 @@ export const FolderAccountRow = ({
onOpenAccount,
onLaunchAccount,
onRequestAccess,
+ onViewCredentials,
+ onRequestCredentialAccess,
onDeleteAccount,
indented
}: Props) => {
@@ -60,6 +64,8 @@ export const FolderAccountRow = ({
requireReason: account.requireReason,
accessStatus,
grantExpiresAt: account.grantExpiresAt,
+ requiresCredentialApproval: account.requiresCredentialApproval,
+ credentialAccessStatus: account.credentialAccessStatus,
createdAt: account.createdAt,
updatedAt: account.updatedAt
};
@@ -93,8 +99,13 @@ export const FolderAccountRow = ({
isAccessible={account.isAccessible}
requiresApproval={requiresApproval}
accessStatus={accessStatus}
+ requiresCredentialApproval={account.requiresCredentialApproval}
+ supportsCredentialReveal={account.supportsCredentialReveal}
+ credentialAccessStatus={account.credentialAccessStatus}
onLaunch={() => onLaunchAccount(launchableAccount)}
onRequestAccess={() => onRequestAccess(launchableAccount)}
+ onViewCredentials={() => onViewCredentials(launchableAccount)}
+ onRequestCredentialAccess={() => onRequestCredentialAccess(launchableAccount)}
onOpenTab={(tab) => onOpenAccount(account.id, tab)}
onDelete={() => onDeleteAccount(account.id, account.name, accountType)}
/>
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx
index 45c684ac1a..cb5b3e7d7b 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx
@@ -21,6 +21,8 @@ type Props = {
onOpenAccount: (accountId: string, tab?: PamSheetTab) => void;
onLaunchAccount: (account: TAccessiblePamAccount) => void;
onRequestAccess: (account: TAccessiblePamAccount) => void;
+ onViewCredentials: (account: TAccessiblePamAccount) => void;
+ onRequestCredentialAccess: (account: TAccessiblePamAccount) => void;
onDeleteAccount: (accountId: string, accountName: string, accountType: PamAccountType) => void;
onOpenFolder: (tab?: PamSheetTab) => void;
onFolderAddAccount: () => void;
@@ -35,6 +37,8 @@ export const FolderAccountRows = ({
onOpenAccount,
onLaunchAccount,
onRequestAccess,
+ onViewCredentials,
+ onRequestCredentialAccess,
onDeleteAccount,
onOpenFolder,
onFolderAddAccount,
@@ -76,6 +80,8 @@ export const FolderAccountRows = ({
onOpenAccount={onOpenAccount}
onLaunchAccount={onLaunchAccount}
onRequestAccess={onRequestAccess}
+ onViewCredentials={onViewCredentials}
+ onRequestCredentialAccess={onRequestCredentialAccess}
onDeleteAccount={onDeleteAccount}
/>
))}
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/ViewCredentialsModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/ViewCredentialsModal.tsx
new file mode 100644
index 0000000000..9c1907daa6
--- /dev/null
+++ b/frontend/src/pages/pam/PamAccountsPage/components/ViewCredentialsModal.tsx
@@ -0,0 +1,236 @@
+import { useEffect, useReducer, useState } from "react";
+import { ClipboardCheck, Copy, Eye, EyeOff, ShieldCheck } from "lucide-react";
+
+import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
+ Button,
+ ButtonGroup,
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldContent,
+ FieldLabel,
+ IconButton,
+ Input,
+ TextArea
+} from "@app/components/v3";
+import { useTimedReset } from "@app/hooks";
+import {
+ PamAccountType,
+ TPamAccountCredentials,
+ usePamAccountCredentials,
+ usePamAccountTypeMap
+} from "@app/hooks/api/pam";
+
+import { extractMfaSessionId, useMfaChallenge } from "../../components/useMfaChallenge";
+
+type Props = {
+ accountId?: string;
+ accountName?: string;
+ accountType?: PamAccountType;
+ requireReason: boolean;
+ isOpen: boolean;
+ onOpenChange: (open: boolean) => void;
+};
+
+const errorMessageOf = (err: unknown) =>
+ (err as { response?: { data?: { message?: string } } })?.response?.data?.message ??
+ "Failed to reveal credentials. Please try again.";
+
+const CredentialField = ({
+ label,
+ value,
+ isSecret
+}: {
+ label: string;
+ value: string;
+ isSecret: boolean;
+}) => {
+ const [isRevealed, toggleRevealed] = useReducer((prev) => !prev, false);
+ const [, isCopied, setCopied] = useTimedReset<boolean>({ initialState: false });
+ const isMasked = isSecret && !isRevealed;
+
+ return (
+ <Field>
+ <FieldLabel>{label}</FieldLabel>
+ <FieldContent>
+ <ButtonGroup className="w-full">
+ <Input
+ value={value}
+ type={isMasked ? "password" : "text"}
+ readOnly
+ aria-label={label}
+ className="font-mono"
+ />
+ {isSecret && (
+ <IconButton
+ variant="outline"
+ aria-label={`${isRevealed ? "Hide" : "Reveal"} ${label}`}
+ onClick={toggleRevealed}
+ >
+ {isRevealed ? <EyeOff /> : <Eye />}
+ </IconButton>
+ )}
+ <IconButton
+ variant="outline"
+ aria-label={`Copy ${label}`}
+ onClick={() => {
+ navigator.clipboard.writeText(value);
+ setCopied(true);
+ }}
+ >
+ {isCopied ? <ClipboardCheck /> : <Copy />}
+ </IconButton>
+ </ButtonGroup>
+ </FieldContent>
+ </Field>
+ );
+};
+
+export const ViewCredentialsModal = ({
+ accountId,
+ accountName,
+ accountType,
+ requireReason,
+ isOpen,
+ onOpenChange
+}: Props) => {
+ const { map } = usePamAccountTypeMap();
+ const runMfaChallenge = useMfaChallenge();
+ const fetchCredentials = usePamAccountCredentials();
+
+ const [reason, setReason] = useState("");
+ const [credentials, setCredentials] = useState<TPamAccountCredentials>();
+ const [errorMessage, setErrorMessage] = useState("");
+ const [isVerifyingMfa, setIsVerifyingMfa] = useState(false);
+
+ useEffect(() => {
+ if (!isOpen) {
+ setReason("");
+ setCredentials(undefined);
+ setErrorMessage("");
+ setIsVerifyingMfa(false);
+ }
+ }, [isOpen]);
+
+ const reveal = async (mfaSessionId?: string) => {
+ if (!accountId) return;
+ setErrorMessage("");
+
+ try {
+ setCredentials(
+ await fetchCredentials.mutateAsync({
+ accountId,
+ reason: reason.trim() || undefined,
+ mfaSessionId
+ })
+ );
+ } catch (err) {
+ const challengeId = mfaSessionId ? undefined : extractMfaSessionId(err);
+ if (!challengeId) {
+ setErrorMessage(errorMessageOf(err));
+ return;
+ }
+
+ setIsVerifyingMfa(true);
+ const verified = await runMfaChallenge(challengeId);
+ setIsVerifyingMfa(false);
+ if (verified) await reveal(challengeId);
+ else setErrorMessage("MFA verification timed out or failed. Please try again.");
+ }
+ };
+
+ const descriptors = new Map(
+ (accountType ? (map[accountType]?.credentialFields ?? []) : []).map((f) => [f.key, f])
+ );
+ const fields = Object.entries(credentials?.credentials ?? {}).filter(
+ (entry): entry is [string, string] => typeof entry[1] === "string" && entry[1].length > 0
+ );
+
+ return (
+ <Dialog open={isOpen} onOpenChange={onOpenChange}>
+ <DialogContent className="max-w-2xl" onOpenAutoFocus={(e) => e.preventDefault()}>
+ <DialogHeader>
+ <DialogTitle>Account Credentials</DialogTitle>
+ <DialogDescription>
+ {credentials
+ ? `Stored credentials for ${accountName}. Copying one takes it outside Infisical, where no session recording applies.`
+ : `Reveal the stored credentials for ${accountName}. Every reveal is recorded in the audit log.`}
+ </DialogDescription>
+ </DialogHeader>
+
+ {errorMessage && (
+ <Alert variant="danger">
+ <AlertTitle>Could not reveal credentials</AlertTitle>
+ <AlertDescription>{errorMessage}</AlertDescription>
+ </Alert>
+ )}
+
+ {isVerifyingMfa && (
+ <Alert variant="info">
+ <ShieldCheck />
+ <AlertTitle>Waiting for MFA verification</AlertTitle>
+ <AlertDescription>
+ Complete the verification in the popup window. Leave this dialog open.
+ </AlertDescription>
+ </Alert>
+ )}
+
+ {credentials ? (
+ <div className="flex flex-col gap-4">
+ {fields.length === 0 && (
+ <p className="text-sm text-muted">This account has no credential configured yet.</p>
+ )}
+ {fields.map(([key, value]) => (
+ <CredentialField
+ key={key}
+ label={descriptors.get(key)?.label ?? key}
+ value={value}
+ // Unknown keys have no descriptor, so mask them rather than leaking a secret in the clear
+ isSecret={descriptors.get(key)?.secret ?? true}
+ />
+ ))}
+ </div>
+ ) : (
+ <Field>
+ <FieldLabel>
+ Reason{!requireReason && <span className="ml-1 text-xs text-muted">(optional)</span>}
+ </FieldLabel>
+ <FieldContent>
+ <TextArea
+ value={reason}
+ onChange={(e) => setReason(e.target.value)}
+ placeholder="Why do you need this credential?"
+ rows={3}
+ maxLength={500}
+ />
+ </FieldContent>
+ </Field>
+ )}
+
+ <DialogFooter>
+ <Button variant="ghost" onClick={() => onOpenChange(false)}>
+ {credentials ? "Close" : "Cancel"}
+ </Button>
+ {!credentials && (
+ <Button
+ variant="pam"
+ isPending={fetchCredentials.isPending || isVerifyingMfa}
+ isDisabled={requireReason && !reason.trim()}
+ onClick={() => reveal()}
+ >
+ <Eye />
+ Reveal
+ </Button>
+ )}
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+};
diff --git a/frontend/src/pages/pam/PamApprovalRequestsPage/PamApprovalRequestsPage.tsx b/frontend/src/pages/pam/PamApprovalRequestsPage/PamApprovalRequestsPage.tsx
index d6552f660e..7eac209ddd 100644
--- a/frontend/src/pages/pam/PamApprovalRequestsPage/PamApprovalRequestsPage.tsx
+++ b/frontend/src/pages/pam/PamApprovalRequestsPage/PamApprovalRequestsPage.tsx
@@ -3,7 +3,7 @@ import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
import { useNavigate, useSearch } from "@tanstack/react-router";
import { format } from "date-fns";
-import { FolderOpen, SearchIcon, ShieldCheck } from "lucide-react";
+import { FolderOpen, KeyRound, SearchIcon, ShieldCheck } from "lucide-react";
import { PageHeader } from "@app/components/v2";
import {
@@ -36,7 +36,7 @@ import {
PreferenceKey,
setUserTablePreference
} from "@app/helpers/userTablePreferences";
-import { useListPamPendingMyApproval } from "@app/hooks/api/pam";
+import { PamAccessType, useListPamPendingMyApproval } from "@app/hooks/api/pam";
import { TPamAccessRequest } from "@app/hooks/api/pam/types";
import { ProjectType } from "@app/hooks/api/projects/types";
@@ -70,6 +70,12 @@ const RequestRow = ({
<AccountPlatformIcon accountType={request.accountType} size={16} />
)}
{request.accountName ?? "-"}
+ {request.accessType === PamAccessType.Credential && (
+ <Badge variant="warning">
+ <KeyRound className="mr-1 size-3" />
+ Credentials
+ </Badge>
+ )}
</div>
</TableCell>
<TableCell className="text-sm">{request.folderName ?? "-"}</TableCell>
diff --git a/frontend/src/pages/pam/PamApprovalRequestsPage/components/ApprovalRequestDetailSheet.tsx b/frontend/src/pages/pam/PamApprovalRequestsPage/components/ApprovalRequestDetailSheet.tsx
index 15874c47e9..a073b68628 100644
--- a/frontend/src/pages/pam/PamApprovalRequestsPage/components/ApprovalRequestDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamApprovalRequestsPage/components/ApprovalRequestDetailSheet.tsx
@@ -1,14 +1,24 @@
import { useEffect, useState } from "react";
import { format } from "date-fns";
-import { Check, Clock, ShieldCheck, X } from "lucide-react";
+import { Check, Clock, KeyRound, ShieldCheck, X } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import { DeleteActionModal } from "@app/components/v2";
-import { Button, TextArea, Tooltip, TooltipContent, TooltipTrigger } from "@app/components/v3";
+import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
+ Button,
+ TextArea,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
+} from "@app/components/v3";
import { useUser } from "@app/context";
import {
PamAccessRequestDecision,
PamAccessRequestStatus,
+ PamAccessType,
useReviewPamAccessRequest,
useRevokePamAccessRequest
} from "@app/hooks/api/pam";
@@ -112,6 +122,13 @@ export const ApprovalRequestDetailSheet = ({ request, isOpen, onOpenChange }: Pr
? { label: "Actor", value: "Machine Identity" }
: { label: "Email", value: request?.requesterEmail ?? "-" },
{ label: "Folder", value: request?.folderName ?? "-" },
+ {
+ label: "Grants",
+ value:
+ request?.accessType === PamAccessType.Credential
+ ? "Credential access"
+ : "Session access"
+ },
...(request?.host ? [{ label: "Host", value: request.host }] : []),
{
label: "Requested At",
@@ -145,6 +162,17 @@ export const ApprovalRequestDetailSheet = ({ request, isOpen, onOpenChange }: Pr
</div>
)}
+ {request?.accessType === PamAccessType.Credential && (
+ <Alert variant="warning">
+ <KeyRound />
+ <AlertTitle>Approving reveals the stored credential</AlertTitle>
+ <AlertDescription>
+ The requester will be able to read this account&apos;s password or key directly
+ for the duration below, outside a recorded session.
+ </AlertDescription>
+ </Alert>
+ )}
+
<div>
<p className="mb-2 text-sm font-medium text-foreground">Access duration</p>
<div className="flex items-center gap-2 rounded-md border border-border bg-container px-3 py-2.5 text-sm text-foreground">
diff --git a/frontend/src/pages/pam/components/RequestAccessSheet.tsx b/frontend/src/pages/pam/components/RequestAccessSheet.tsx
index 4b558d1bb6..23b36c60c9 100644
--- a/frontend/src/pages/pam/components/RequestAccessSheet.tsx
+++ b/frontend/src/pages/pam/components/RequestAccessSheet.tsx
@@ -29,6 +29,7 @@ import {
} from "@app/components/v3";
import {
PamAccessStatus,
+ PamAccessType,
PamAccountType,
PamApproverType,
TAccessiblePamAccount,
@@ -66,6 +67,7 @@ type Props = {
account: TAccessiblePamAccount | null;
isOpen: boolean;
onOpenChange: (open: boolean) => void;
+ accessType?: PamAccessType;
};
const ApproverChip = ({
@@ -85,8 +87,16 @@ const ApproverChip = ({
);
};
-const ApprovalWorkflow = ({ accountId, isPending }: { accountId?: string; isPending: boolean }) => {
- const { data: steps } = useGetPamAccountApprovers(accountId);
+const ApprovalWorkflow = ({
+ accountId,
+ isPending,
+ accessType
+}: {
+ accountId?: string;
+ isPending: boolean;
+ accessType: PamAccessType;
+}) => {
+ const { data: steps } = useGetPamAccountApprovers(accountId, accessType);
if (!steps?.length) return null;
return (
@@ -137,10 +147,18 @@ const ApprovalWorkflow = ({ accountId, isPending }: { accountId?: string; isPend
);
};
-export const RequestAccessSheet = ({ account, isOpen, onOpenChange }: Props) => {
+export const RequestAccessSheet = ({
+ account,
+ isOpen,
+ onOpenChange,
+ accessType = PamAccessType.Session
+}: Props) => {
const { typeName, subtitle, metadata } = useAccountSheetDetails(account, isOpen);
const createRequest = useCreatePamAccessRequest();
- const isPending = account?.accessStatus === PamAccessStatus.Pending;
+ const isCredentialRequest = accessType === PamAccessType.Credential;
+ const isPending =
+ (isCredentialRequest ? account?.credentialAccessStatus : account?.accessStatus) ===
+ PamAccessStatus.Pending;
const requireReason = Boolean(account?.requireReason);
const schema = useMemo(() => makeSchema(requireReason), [requireReason]);
@@ -165,11 +183,17 @@ export const RequestAccessSheet = ({ account, isOpen, onOpenChange }: Props) =>
{
accountId: account.id,
duration: data.duration,
- reason: data.reason || undefined
+ reason: data.reason || undefined,
+ accessType
},
{
onSuccess: () => {
- createNotification({ text: "Access request submitted", type: "success" });
+ createNotification({
+ text: isCredentialRequest
+ ? "Credential access request submitted"
+ : "Access request submitted",
+ type: "success"
+ });
reset();
onOpenChange(false);
}
@@ -194,9 +218,13 @@ export const RequestAccessSheet = ({ account, isOpen, onOpenChange }: Props) =>
<div className="flex flex-1 flex-col gap-6">
<div className="flex items-center gap-2.5 rounded-md border border-border bg-container px-4 py-3">
<Clock className="size-4 shrink-0 text-warning" />
- <p className="text-sm text-foreground">Your access request is awaiting approval.</p>
+ <p className="text-sm text-foreground">
+ {isCredentialRequest
+ ? "Your credential request is awaiting approval."
+ : "Your access request is awaiting approval."}
+ </p>
</div>
- <ApprovalWorkflow accountId={account?.id} isPending />
+ <ApprovalWorkflow accountId={account?.id} isPending accessType={accessType} />
</div>
) : (
<form onSubmit={handleSubmit(onSubmit)} className="flex flex-1 flex-col">
@@ -213,7 +241,11 @@ export const RequestAccessSheet = ({ account, isOpen, onOpenChange }: Props) =>
<TextArea
{...field}
rows={4}
- placeholder="What are you working on?"
+ placeholder={
+ isCredentialRequest
+ ? "Why do you need this account's credentials?"
+ : "What are you working on?"
+ }
isError={!!fieldState.error}
/>
<FieldDescription>
@@ -247,7 +279,7 @@ export const RequestAccessSheet = ({ account, isOpen, onOpenChange }: Props) =>
</Field>
)}
/>
- <ApprovalWorkflow accountId={account?.id} isPending={false} />
+ <ApprovalWorkflow accountId={account?.id} isPending={false} accessType={accessType} />
</div>
<div className="flex items-center justify-end gap-2 border-t border-border pt-4">
<Button type="button" variant="ghost" onClick={() => handleOpenChange(false)}>
diff --git a/frontend/src/pages/pam/components/policyEditors/index.tsx b/frontend/src/pages/pam/components/policyEditors/index.tsx
index 64601d4241..d5f8cb2245 100644
--- a/frontend/src/pages/pam/components/policyEditors/index.tsx
+++ b/frontend/src/pages/pam/components/policyEditors/index.tsx
@@ -16,6 +16,7 @@ const CommandBlockingEditor = (props: PolicyEditorProps) => (
export const POLICY_EDITORS: Partial<Record<PamPolicyType, ComponentType<PolicyEditorProps>>> = {
[PamPolicyType.RequiresApproval]: BooleanPolicyEditor,
+ [PamPolicyType.RequiresCredentialApproval]: BooleanPolicyEditor,
[PamPolicyType.RequireMfa]: BooleanPolicyEditor,
[PamPolicyType.RequireReason]: BooleanPolicyEditor,
[PamPolicyType.MaxSessionDuration]: DurationPolicyEditor,
diff --git a/frontend/src/pages/pam/components/useMfaChallenge.ts b/frontend/src/pages/pam/components/useMfaChallenge.ts
new file mode 100644
index 0000000000..c56a5c6f65
--- /dev/null
+++ b/frontend/src/pages/pam/components/useMfaChallenge.ts
@@ -0,0 +1,61 @@
+import { useCallback, useRef } from "react";
+
+import { apiRequest } from "@app/config/request";
+import { MfaSessionStatus, TMfaSessionStatusResponse } from "@app/hooks/api/mfaSession/types";
+
+const MFA_POLL_INTERVAL = 2000;
+const MFA_TIMEOUT = 5 * 60 * 1000;
+
+type TMfaRequiredError = {
+ response?: {
+ data?: {
+ error?: string;
+ message?: string;
+ details?: { mfaSessionId?: string };
+ };
+ };
+};
+
+// An MFA-gated PAM request answers with SESSION_MFA_REQUIRED and a fresh session id to verify
+export const extractMfaSessionId = (err: unknown): string | undefined => {
+ const data = (err as TMfaRequiredError)?.response?.data;
+ return data?.error === "SESSION_MFA_REQUIRED" ? data.details?.mfaSessionId : undefined;
+};
+
+// Opens the verification page in a popup and resolves once the session goes active, false otherwise
+export const useMfaChallenge = () => {
+ const popupRef = useRef<Window | null>(null);
+
+ return useCallback(async (mfaSessionId: string) => {
+ popupRef.current = window.open(
+ `${window.location.origin}/mfa-session/${mfaSessionId}`,
+ "_blank"
+ );
+ const startTime = Date.now();
+
+ const verified = await new Promise<boolean>((resolve) => {
+ const interval = setInterval(async () => {
+ if (Date.now() - startTime > MFA_TIMEOUT) {
+ clearInterval(interval);
+ resolve(false);
+ return;
+ }
+ try {
+ const { data } = await apiRequest.get<TMfaSessionStatusResponse>(
+ `/api/v2/mfa-sessions/${mfaSessionId}/status`
+ );
+ if (data.status === MfaSessionStatus.ACTIVE) {
+ clearInterval(interval);
+ resolve(true);
+ }
+ } catch {
+ clearInterval(interval);
+ resolve(false);
+ }
+ }, MFA_POLL_INTERVAL);
+ });
+
+ if (popupRef.current && !popupRef.current.closed) popupRef.current.close();
+ return verified;
+ }, []);
+};