Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
address reviews
Andrey9ab1a0f0c9b1
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.tsindex 331a3baa71..eaf98fbbef 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@@ -552,8 +552,8 @@ export const registerPamWebAccessRouter = async (server: FastifyZodProvider) =>accountType: z.string(),actorEmail: z.string(),actorName: z.string(),- tokenVersionId: z.string().uuid(),- accessVersion: z.number(),+ tokenVersionId: z.string().uuid().optional(),+ accessVersion: z.number().optional(),reason: z.string().nullable().optional(),maxSessionDurationMs: z.number().optional(),selectedHost: z.string().nullable().optional(),@@ -575,11 +575,14 @@ export const registerPamWebAccessRouter = async (server: FastifyZodProvider) =>return;}- await server.services.authToken.validateUserSessionFreshness({- userId,- tokenVersionId: payload.tokenVersionId,- accessVersion: payload.accessVersion- });+ if (payload.tokenVersionId && payload.accessVersion !== undefined) {+ await server.services.authToken.validateUserSessionFreshness({+ userId,+ tokenVersionId: payload.tokenVersionId,+ accessVersion: payload.accessVersion,+ readFromPrimary: true+ });+ }await server.services.pamWebAccess.handleWebSocketConnection({socket: connection,diff --git a/backend/src/services/auth-token/auth-token-dal.ts b/backend/src/services/auth-token/auth-token-dal.tsindex 30f71f1fb8..4cbbb80d69 100644--- a/backend/src/services/auth-token/auth-token-dal.ts+++ b/backend/src/services/auth-token/auth-token-dal.ts@@ -14,10 +14,12 @@ export const tokenDALFactory = (db: TDbClient) => {const findOneTokenSession = async (filter: Partial<TAuthTokenSessions>,- tx?: Knex+ tx?: Knex,+ { readFromPrimary = false }: { readFromPrimary?: boolean } = {}): Promise<TAuthTokenSessions | undefined> => {try {- const doc = await (tx || db.replicaNode())(TableName.AuthTokenSession).where(filter).first();+ const reader = tx || (readFromPrimary ? db : db.replicaNode());+ const doc = await reader(TableName.AuthTokenSession).where(filter).first();return doc;} catch (error) {throw new DatabaseError({ error, name: "FindOneTokenSession" });diff --git a/backend/src/services/auth-token/auth-token-service.ts b/backend/src/services/auth-token/auth-token-service.tsindex cadf3e9863..129b28f52b 100644--- a/backend/src/services/auth-token/auth-token-service.ts+++ b/backend/src/services/auth-token/auth-token-service.ts@@ -358,13 +358,17 @@ export const tokenServiceFactory = ({ tokenDAL, userDAL, orgDAL, keyStore }: TAuconst validateUserSessionFreshness = async ({userId,tokenVersionId,- accessVersion+ accessVersion,+ readFromPrimary = false}: {userId: string;tokenVersionId: string;accessVersion: number;+ readFromPrimary?: boolean;}) => {- const session = await tokenDAL.findOneTokenSession({ id: tokenVersionId, userId });+ const session = await tokenDAL.findOneTokenSession({ id: tokenVersionId, userId }, undefined, {+ readFromPrimary+ });if (!session) throw new NotFoundError({ name: "Session not found" });if (accessVersion !== session.accessVersion) {throw new UnauthorizedError({ name: "StaleSession", message: "User session is stale, please re-authenticate" });