Skip to content

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

access route for CLI

x032205eb3f51d2e717
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
index 8892165ce1..0faf9b1890 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
@@ -3,6 +3,7 @@ import z from "zod";
import { PamSessionsSchema } from "@app/db/schemas";
import { EventType, UserAgentType } from "@app/ee/services/audit-log/audit-log-types";
+import { PamAccountType } from "@app/ee/services/pam/pam-enums";
import { PamRecordingStorageBackend } from "@app/ee/services/pam-session-recording/pam-recording-enums";
import { ApiDocsTags } from "@app/lib/api-docs/constants";
import { BadRequestError } from "@app/lib/errors";
@@ -205,6 +206,102 @@ export const registerPamSessionRouter = async (server: FastifyZodProvider) => {
};
export const registerPamWebAccessRouter = async (server: FastifyZodProvider) => {
+ server.route({
+ method: "POST",
+ url: "/access",
+ config: { rateLimit: writeLimit },
+ schema: {
+ operationId: "pamAccountAccess",
+ description: "Access a PAM account by path and obtain gateway connection details",
+ tags: [ApiDocsTags.PamSessions],
+ body: z.object({
+ path: z.string().trim().min(3).describe("Account path in the format 'folderName/accountName'"),
+ reason: z.string().trim().max(1000).optional().describe("Optional reason for the session"),
+ duration: z
+ .string()
+ .trim()
+ .optional()
+ .describe("Session duration (e.g. '1h', '30m'). Capped at the account's max session duration.")
+ }),
+ response: {
+ 200: z.object({
+ sessionId: z.string().describe("The ID of the created session"),
+ accountType: z.nativeEnum(PamAccountType).describe("The account type"),
+ relayHost: z.string().describe("The relay host to connect to"),
+ relayClientCertificate: z.string().describe("Client certificate for the relay connection"),
+ relayClientPrivateKey: z.string().describe("Client private key for the relay connection"),
+ relayServerCertificateChain: z.string().describe("Server certificate chain for the relay connection"),
+ gatewayClientCertificate: z.string().describe("Client certificate for the gateway connection"),
+ gatewayClientPrivateKey: z.string().describe("Client private key for the gateway connection"),
+ gatewayServerCertificateChain: z.string().describe("Server certificate chain for the gateway connection")
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ if (req.auth.authMode !== AuthMode.JWT) {
+ throw new BadRequestError({ message: "Account access requires JWT authentication" });
+ }
+
+ const result = await server.services.pamSession.access({
+ path: req.body.path,
+ projectId: req.internalPamProjectId,
+ actor: {
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod
+ },
+ actorEmail: req.auth.user.email ?? "",
+ actorName: `${req.auth.user.firstName ?? ""} ${req.auth.user.lastName ?? ""}`.trim(),
+ actorIp: req.realIp ?? "",
+ actorUserAgent: req.headers["user-agent"] ?? "",
+ reason: req.body.reason,
+ duration: req.body.duration
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: req.permission.orgId,
+ projectId: req.internalPamProjectId,
+ event: {
+ type: EventType.PAM_ACCOUNT_ACCESS,
+ metadata: {
+ accountId: result.accountId,
+ resourceName: result.accountName,
+ accountName: result.accountName,
+ reason: req.body.reason
+ }
+ }
+ });
+
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.PamAccountAccessed,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.permission.orgId,
+ properties: {
+ accountType: result.accountType,
+ orgId: req.permission.orgId,
+ duration: result.sessionDurationMs
+ }
+ })
+ .catch(() => {});
+
+ return {
+ sessionId: result.sessionId,
+ accountType: result.accountType,
+ relayHost: result.relayHost,
+ relayClientCertificate: result.relayClientCertificate,
+ relayClientPrivateKey: result.relayClientPrivateKey,
+ relayServerCertificateChain: result.relayServerCertificateChain,
+ gatewayClientCertificate: result.gatewayClientCertificate,
+ gatewayClientPrivateKey: result.gatewayClientPrivateKey,
+ gatewayServerCertificateChain: result.gatewayServerCertificateChain
+ };
+ }
+ });
+
server.route({
method: "POST",
url: "/:accountId/web-access-ticket",
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 657c013abf..e9bab7759e 100644
--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts
+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts
@@ -77,6 +77,26 @@ export const validateCredentials = (accountType: PamAccountType, data: unknown)
export { ACCOUNT_TYPE_CONFIGS };
+export type TGatewayTarget = { host: string; port?: number };
+
+export const extractGatewayTarget = (
+ accountType: PamAccountType,
+ rawConnectionDetails: Record<string, unknown>
+): TGatewayTarget => {
+ const validated = validateConnectionDetails(accountType, rawConnectionDetails);
+
+ switch (accountType) {
+ case PamAccountType.SSH:
+ case PamAccountType.Postgres:
+ return {
+ host: (validated as { host: string; port: number }).host,
+ port: (validated as { host: string; port: number }).port
+ };
+ default:
+ throw new Error(`No gateway target extraction defined for account type '${accountType}'`);
+ }
+};
+
export type TSshInternalMetadata = z.infer<(typeof ACCOUNT_TYPE_CONFIGS)[PamAccountType.SSH]["internalMetadata"]>;
export const parseInternalMetadata = (accountType: PamAccountType, data: unknown): TSshInternalMetadata | null => {
diff --git a/backend/src/ee/services/pam-session/pam-session-constants.ts b/backend/src/ee/services/pam-session/pam-session-constants.ts
new file mode 100644
index 0000000000..bdaf7ff370
--- /dev/null
+++ b/backend/src/ee/services/pam-session/pam-session-constants.ts
@@ -0,0 +1 @@
+export const DEFAULT_SESSION_DURATION_MS = 60 * 60 * 1000;
diff --git a/backend/src/ee/services/pam-session/pam-session-dal.ts b/backend/src/ee/services/pam-session/pam-session-dal.ts
index 8b62080870..22723ba1df 100644
--- a/backend/src/ee/services/pam-session/pam-session-dal.ts
+++ b/backend/src/ee/services/pam-session/pam-session-dal.ts
@@ -4,7 +4,7 @@ import { TDbClient } from "@app/db";
import { TableName } from "@app/db/schemas";
import { ormify, selectAllTableCols } from "@app/lib/knex";
-import { PamSessionStatus } from "../pam/pam-enums";
+import { PamAccessMethod, PamSessionStatus } from "../pam/pam-enums";
export type TPamSessionDALFactory = ReturnType<typeof pamSessionDALFactory>;
@@ -27,7 +27,7 @@ export const pamSessionDALFactory = (db: TDbClient) => {
const result = await (tx || db.replicaNode())(TableName.PamSession)
.where("userId", userId)
.where("projectId", projectId)
- .where("accessMethod", "web")
+ .where("accessMethod", PamAccessMethod.Web)
.whereIn("status", [PamSessionStatus.Starting, PamSessionStatus.Active])
.count("id as count")
.first();
@@ -40,7 +40,7 @@ export const pamSessionDALFactory = (db: TDbClient) => {
const updatedCount = await (tx || db)(TableName.PamSession)
.where("userId", userId)
.where("projectId", projectId)
- .where("accessMethod", "web")
+ .where("accessMethod", PamAccessMethod.Web)
.whereIn("status", [PamSessionStatus.Active, PamSessionStatus.Starting])
.where("expiresAt", "<", now)
.update({ status: PamSessionStatus.Ended, endedAt: now });
diff --git a/backend/src/ee/services/pam-session/pam-session-expiration-queue.ts b/backend/src/ee/services/pam-session/pam-session-expiration-queue.ts
new file mode 100644
index 0000000000..d113cb12f0
--- /dev/null
+++ b/backend/src/ee/services/pam-session/pam-session-expiration-queue.ts
@@ -0,0 +1,68 @@
+import { getConfig } from "@app/lib/config/env";
+import { logger } from "@app/lib/logger";
+import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
+
+import { TPamSessionDALFactory } from "./pam-session-dal";
+
+type TPamSessionExpirationServiceFactoryDep = {
+ queueService: TQueueServiceFactory;
+ pamSessionDAL: Pick<TPamSessionDALFactory, "endSessionById">;
+};
+
+export type TPamSessionExpirationServiceFactory = ReturnType<typeof pamSessionExpirationServiceFactory>;
+
+export const pamSessionExpirationServiceFactory = ({
+ queueService,
+ pamSessionDAL
+}: TPamSessionExpirationServiceFactoryDep) => {
+ const appCfg = getConfig();
+
+ const init = () => {
+ if (appCfg.isSecondaryInstance) {
+ return;
+ }
+
+ queueService.start(QueueName.PamSessionExpiration, async (job) => {
+ const { sessionId } = job.data;
+ try {
+ logger.info({ sessionId }, `${QueueName.PamSessionExpiration}: expiring session [sessionId=${sessionId}]`);
+ const updated = await pamSessionDAL.endSessionById(sessionId);
+ if (updated) {
+ logger.info({ sessionId }, `${QueueName.PamSessionExpiration}: session expired [sessionId=${sessionId}]`);
+ } else {
+ logger.info(
+ { sessionId },
+ `${QueueName.PamSessionExpiration}: session already ended or not found [sessionId=${sessionId}]`
+ );
+ }
+ } catch (error) {
+ logger.error(error, `${QueueName.PamSessionExpiration}: failed to expire session [sessionId=${sessionId}]`);
+ throw error;
+ }
+ });
+ };
+
+ const scheduleSessionExpiration = async (sessionId: string, expiresAt: Date) => {
+ const delayMs = Math.max(0, expiresAt.getTime() - Date.now());
+
+ await queueService.queue(
+ QueueName.PamSessionExpiration,
+ QueueJobs.PamSessionExpiration,
+ { sessionId },
+ {
+ jobId: `pam-session-expiration-${sessionId}`,
+ delay: delayMs
+ }
+ );
+
+ logger.info(
+ { sessionId, expiresAt: expiresAt.toISOString(), delayMs },
+ `${QueueName.PamSessionExpiration}: scheduled expiration [sessionId=${sessionId}]`
+ );
+ };
+
+ return {
+ init,
+ scheduleSessionExpiration
+ };
+};
diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.ts
index e54f2e1ece..c776beff70 100644
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@ -1,14 +1,19 @@
+import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";
+import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import { createSshCert, createSshKeyPair } from "@app/ee/services/ssh/ssh-certificate-authority-fns";
import { SshCertType } from "@app/ee/services/ssh/ssh-certificate-authority-types";
import { SshCertKeyAlgorithm } from "@app/ee/services/ssh-certificate/ssh-certificate-types";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
+import { ms } from "@app/lib/ms";
+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 { TUserDALFactory } from "@app/services/user/user-dal";
-import { PamAccountType, PamSessionStatus } from "../pam/pam-enums";
+import { PamAccessMethod, PamAccountType, PamSessionStatus } from "../pam/pam-enums";
import {
checkAccountAccess,
getViewSessionsResourceIds,
@@ -16,23 +21,31 @@ import {
verifyProductMembership
} from "../pam/pam-permission";
import { TPamAccountDALFactory } from "../pam-account/pam-account-dal";
-import { parseInternalMetadata } from "../pam-account/pam-account-schemas";
+import { extractGatewayTarget, parseInternalMetadata } from "../pam-account/pam-account-schemas";
import { PamTemplateAccessPolicySchema } from "../pam-account-template/pam-account-template-schemas";
+import { TPamFolderDALFactory } from "../pam-folder/pam-folder-dal";
import { PamRecordingStorageBackend } from "../pam-session-recording/pam-recording-enums";
import { generateSessionRecordingSecrets } from "../pam-session-recording/pam-recording-secrets";
import { ResourcePermissionPamResourceActions } from "../permission/resource-permission";
+import { DEFAULT_SESSION_DURATION_MS } from "./pam-session-constants";
import { TPamSessionDALFactory } from "./pam-session-dal";
+import { TPamSessionExpirationServiceFactory } from "./pam-session-expiration-queue";
type TPamSessionServiceFactoryDep = {
pamSessionDAL: Pick<
TPamSessionDALFactory,
- "findAccessibleByProjectId" | "findById" | "findOne" | "endSessionById" | "updateById"
+ "findAccessibleByProjectId" | "findById" | "findOne" | "create" | "endSessionById" | "updateById"
>;
- pamAccountDAL: Pick<TPamAccountDALFactory, "findByIdWithDetails">;
+ pamAccountDAL: Pick<TPamAccountDALFactory, "findByIdWithDetails" | "findOne">;
+ pamFolderDAL: Pick<TPamFolderDALFactory, "findOne">;
membershipDAL: Pick<TMembershipDALFactory, "findResourceMembershipsForActor">;
membershipRoleDAL: Pick<TMembershipRoleDALFactory, "find">;
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission">;
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPAMConnectionDetails">;
+ gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;
+ userDAL: Pick<TUserDALFactory, "findById">;
+ pamSessionExpirationService: Pick<TPamSessionExpirationServiceFactory, "scheduleSessionExpiration">;
};
export type TPamSessionServiceFactory = ReturnType<typeof pamSessionServiceFactory>;
@@ -40,10 +53,15 @@ export type TPamSessionServiceFactory = ReturnType<typeof pamSessionServiceFacto
export const pamSessionServiceFactory = ({
pamSessionDAL,
pamAccountDAL,
+ pamFolderDAL,
membershipDAL,
membershipRoleDAL,
permissionService,
- kmsService
+ kmsService,
+ gatewayV2Service,
+ gatewayPoolService,
+ userDAL,
+ pamSessionExpirationService
}: TPamSessionServiceFactoryDep) => {
const decrypt = async (projectId: string, blob: Buffer): Promise<Record<string, unknown>> => {
const { decryptor } = await kmsService.createCipherPairWithDataKey({ type: KmsDataKey.SecretManager, projectId });
@@ -203,7 +221,170 @@ export const pamSessionServiceFactory = ({
};
};
+ const resolveAccountByPath = async (projectId: string, path: string) => {
+ const separatorIdx = path.indexOf("/");
+ if (separatorIdx === -1) {
+ throw new BadRequestError({
+ message: "Path must be in the format 'folderName/accountName'"
+ });
+ }
+
+ const folderName = path.slice(0, separatorIdx);
+ const accountName = path.slice(separatorIdx + 1);
+ if (!folderName || !accountName) {
+ throw new BadRequestError({
+ message: "Path must be in the format 'folderName/accountName'"
+ });
+ }
+
+ const folder = await pamFolderDAL.findOne({ projectId, name: folderName });
+ if (!folder) {
+ throw new NotFoundError({ message: `Folder '${folderName}' not found` });
+ }
+
+ const accountRow = await pamAccountDAL.findOne({ folderId: folder.id, name: accountName });
+ if (!accountRow) {
+ throw new NotFoundError({ message: `Account '${accountName}' not found in folder '${folderName}'` });
+ }
+
+ const account = await pamAccountDAL.findByIdWithDetails(accountRow.id);
+ if (!account) {
+ throw new NotFoundError({ message: `Account '${accountName}' not found` });
+ }
+
+ return account;
+ };
+
+ const access = async ({
+ path,
+ projectId,
+ actor,
+ actorEmail,
+ actorName,
+ actorIp,
+ actorUserAgent,
+ reason,
+ duration
+ }: {
+ path: string;
+ projectId: string;
+ actor: TActorContext;
+ actorEmail: string;
+ actorName: string;
+ actorIp: string;
+ actorUserAgent: string;
+ reason?: string;
+ duration?: string;
+ }) => {
+ const account = await resolveAccountByPath(projectId, path);
+
+ const trimmedReason = reason?.trim() || null;
+
+ const accessPolicy = account.templateAccessPolicy
+ ? PamTemplateAccessPolicySchema.safeParse(account.templateAccessPolicy)
+ : null;
+ const policy = accessPolicy?.success ? accessPolicy.data : null;
+
+ if (policy?.requireReason && !trimmedReason) {
+ throw new BadRequestError({ message: "A reason is required to access this account" });
+ }
+
+ if (policy?.requireMfa) {
+ throw new BadRequestError({ message: "MFA verification is required to access this account" });
+ }
+
+ const maxDurationMs = policy?.maxSessionDurationSeconds
+ ? policy.maxSessionDurationSeconds * 1000
+ : DEFAULT_SESSION_DURATION_MS;
+
+ let sessionDurationMs = maxDurationMs;
+ if (duration) {
+ const parsed = ms(duration);
+ if (!parsed || parsed <= 0) {
+ throw new BadRequestError({ message: "Invalid duration format" });
+ }
+ sessionDurationMs = Math.min(parsed, maxDurationMs);
+ }
+
+ await checkAccount(
+ account.id,
+ account.folderId,
+ projectId,
+ ResourcePermissionPamResourceActions.LaunchSessions,
+ actor
+ );
+
+ const effectiveGatewayId = await gatewayPoolService.resolveEffectiveGatewayId({
+ gatewayId: account.gatewayId,
+ gatewayPoolId: account.gatewayPoolId
+ });
+ if (!effectiveGatewayId) {
+ throw new BadRequestError({ message: "Gateway not configured for this account" });
+ }
+
+ const rawConnectionDetails = await decrypt(projectId, account.encryptedConnectionDetails);
+ const gatewayTarget = extractGatewayTarget(account.accountType as PamAccountType, rawConnectionDetails);
+
+ const user = await userDAL.findById(actor.actorId);
+ const expiresAt = new Date(Date.now() + sessionDurationMs);
+
+ const session = await pamSessionDAL.create({
+ status: PamSessionStatus.Starting,
+ accessMethod: PamAccessMethod.Cli,
+ expiresAt,
+ accountName: account.name,
+ accountType: account.accountType,
+ actorEmail,
+ actorIp,
+ actorName,
+ actorUserAgent,
+ projectId,
+ accountId: account.id,
+ userId: actor.actorId,
+ gatewayId: effectiveGatewayId,
+ reason: trimmedReason,
+ folderName: account.folderName,
+ selectedHost: gatewayTarget.host
+ });
+
+ await pamSessionExpirationService.scheduleSessionExpiration(session.id, expiresAt);
+
+ const certs = await gatewayV2Service.getPAMConnectionDetails({
+ gatewayId: effectiveGatewayId,
+ sessionId: session.id,
+ accountType: account.accountType as PamAccountType,
+ host: gatewayTarget.host,
+ port: gatewayTarget.port,
+ duration: sessionDurationMs,
+ actorMetadata: {
+ id: actor.actorId,
+ type: ActorType.USER,
+ name: user?.email ?? ""
+ }
+ });
+
+ if (!certs) {
+ throw new BadRequestError({ message: "Failed to obtain gateway connection details" });
+ }
+
+ return {
+ sessionId: session.id,
+ accountId: account.id,
+ accountType: account.accountType as PamAccountType,
+ accountName: account.name,
+ sessionDurationMs,
+ relayHost: certs.relayHost,
+ relayClientCertificate: certs.relay.clientCertificate,
+ relayClientPrivateKey: certs.relay.clientPrivateKey,
+ relayServerCertificateChain: certs.relay.serverCertificateChain,
+ gatewayClientCertificate: certs.gateway.clientCertificate,
+ gatewayClientPrivateKey: certs.gateway.clientPrivateKey,
+ gatewayServerCertificateChain: certs.gateway.serverCertificateChain
+ };
+ };
+
return {
+ access,
listSessions,
getSessionById,
getSessionCredentials,
diff --git a/backend/src/ee/services/pam-web-access/pam-web-access-service.ts b/backend/src/ee/services/pam-web-access/pam-web-access-service.ts
index 7e75baf929..632624af65 100644
--- a/backend/src/ee/services/pam-web-access/pam-web-access-service.ts
+++ b/backend/src/ee/services/pam-web-access/pam-web-access-service.ts
@@ -28,8 +28,9 @@ import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "@app/services/kms/kms-types";
import { TUserDALFactory } from "@app/services/user/user-dal";
-import { PamSessionStatus } from "../pam/pam-enums";
+import { PamAccessMethod, PamSessionStatus } from "../pam/pam-enums";
import { TPamAccountDALFactory } from "../pam-account/pam-account-dal";
+import { extractGatewayTarget } from "../pam-account/pam-account-schemas";
import { TPamSessionDALFactory } from "../pam-session/pam-session-dal";
import { getSessionHandler, isWebAccessSupported } from "./pam-session-handler-registry";
import {
@@ -403,10 +404,8 @@ export const pamWebAccessServiceFactory = ({
return;
}
- const connectionDetails = (await decrypt(projectId, account.encryptedConnectionDetails)) as {
- host: string;
- port: number;
- };
+ const rawConnectionDetails = await decrypt(projectId, account.encryptedConnectionDetails);
+ const gatewayTarget = extractGatewayTarget(account.accountType as PamAccountType, rawConnectionDetails);
const credentials = await decrypt(projectId, account.encryptedCredentials);
const user = await userDAL.findById(userId);
@@ -415,7 +414,7 @@ export const pamWebAccessServiceFactory = ({
session = await pamSessionDAL.create({
status: PamSessionStatus.Starting,
- accessMethod: "web",
+ accessMethod: PamAccessMethod.Web,
expiresAt,
accountName,
accountType: account.accountType,
@@ -429,15 +428,15 @@ export const pamWebAccessServiceFactory = ({
gatewayId: effectiveGatewayId,
reason: accessReason?.trim() || null,
folderName: account.folderName,
- selectedHost: connectionDetails.host
+ selectedHost: gatewayTarget.host
});
const certs = await gatewayV2Service.getPAMConnectionDetails({
gatewayId: effectiveGatewayId,
sessionId: session.id,
accountType: handlerEntry.gatewayAccountType,
- host: connectionDetails.host,
- port: connectionDetails.port,
+ host: gatewayTarget.host,
+ port: gatewayTarget.port,
duration: sessionDurationMs,
actorMetadata: {
id: userId,
@@ -488,7 +487,7 @@ export const pamWebAccessServiceFactory = ({
try {
handlerResult = await handlerEntry.handler(ctx, {
- connectionDetails: connectionDetails as Record<string, unknown>,
+ connectionDetails: rawConnectionDetails,
credentials
});
} finally {
diff --git a/backend/src/ee/services/pam/pam-enums.ts b/backend/src/ee/services/pam/pam-enums.ts
index 516c2981a0..21a9628191 100644
--- a/backend/src/ee/services/pam/pam-enums.ts
+++ b/backend/src/ee/services/pam/pam-enums.ts
@@ -30,3 +30,8 @@ export enum PamSessionStatus {
Ended = "ended",
Terminated = "terminated"
}
+
+export enum PamAccessMethod {
+ Web = "web",
+ Cli = "cli"
+}
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 7ea9b15e2b..38c28e2298 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -104,6 +104,7 @@ import { pamFolderServiceFactory } from "@app/ee/services/pam-folder/pam-folder-
import { pamMembershipServiceFactory } from "@app/ee/services/pam-membership/pam-membership-service";
import { pamProjectResolverFactory } from "@app/ee/services/pam-project/pam-project-resolver";
import { pamSessionDALFactory } from "@app/ee/services/pam-session/pam-session-dal";
+import { pamSessionExpirationServiceFactory } from "@app/ee/services/pam-session/pam-session-expiration-queue";
import { pamSessionServiceFactory } from "@app/ee/services/pam-session/pam-session-service";
import { pamSessionEventChunkDALFactory } from "@app/ee/services/pam-session-recording/pam-recording-chunk-dal";
import { pamSessionChunkServiceFactory } from "@app/ee/services/pam-session-recording/pam-recording-chunk-service";
@@ -1689,13 +1690,23 @@ export const registerRoutes = async (
const pamSessionDAL = pamSessionDALFactory(db);
const pamSessionEventChunkDAL = pamSessionEventChunkDALFactory(db);
+ const pamSessionExpirationService = pamSessionExpirationServiceFactory({
+ queueService,
+ pamSessionDAL
+ });
+
const pamSessionService = pamSessionServiceFactory({
pamSessionDAL,
pamAccountDAL,
+ pamFolderDAL,
membershipDAL,
membershipRoleDAL,
permissionService,
- kmsService
+ kmsService,
+ gatewayV2Service,
+ gatewayPoolService,
+ userDAL,
+ pamSessionExpirationService
});
const pamSessionChunkService = pamSessionChunkServiceFactory({
@@ -3438,6 +3449,7 @@ export const registerRoutes = async (
certificateV3Queue.init();
digicertCaQueue.init();
digicertRevocationSyncQueue.init();
+ pamSessionExpirationService.init();
godaddyCaQueue.init();
caAutoRenewalQueue.startDailyAutoRenewalJob();
signerAutoRenewalQueue.start();