Skip to content

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

cache per scope

Thiago Araujo da Silva078c97a7bbe2
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md
index 0a19b47212..71c7437072 100644
--- a/backend/CLAUDE.md
+++ b/backend/CLAUDE.md
@@ -1010,8 +1010,11 @@ Every class but management can be turned off per scope, and scopes do not inheri
rows for org-level events, each project has its own rows for its events, and a scope without a row uses
the default in `AUDIT_LOG_EVENT_CLASS_DEFAULTS` (data access on, authorization off). The rows live in
`audit_log_settings` (one per scope and class, `projectId` null for the org scope) behind
-`audit-log-settings-service.ts`, which caches the org's rows and all of its projects' rows in the
-keystore for 1 minute (`getEffectiveSettings`, never throws: a lookup failure records everything).
+`audit-log-settings-service.ts`. `getEffectiveSettings(orgId, projectId?)` caches per scope, not per
+org: one key for the org's rows plus `shouldUseNewPrivilegeSystem`, one key per org and project
+(`{}` when it has no rows), read together in one `MGET` for 10 minutes. Never build a value that
+holds every project in an org, since every event would fetch and parse it. Each write clears only its own scope's key, and
+the lookup never throws: a failure records everything.
Enforcement is `isAuditLogEventEnabled` in the settings service, called from `buildStreamEntry` in
`audit-log-queue.ts` with the settings memoized per request so a batch of events costs one read.
Suppressed events are dropped silently and do not count on the dropped counter. Management is
diff --git a/backend/src/ee/services/audit-log/audit-log-queue.test.ts b/backend/src/ee/services/audit-log/audit-log-queue.test.ts
index 34f57de242..56522b4ea9 100644
--- a/backend/src/ee/services/audit-log/audit-log-queue.test.ts
+++ b/backend/src/ee/services/audit-log/audit-log-queue.test.ts
@@ -99,7 +99,9 @@ const createHarness = async ({ clickhouse = false, streamsEnabled = false, gener
enqueueForLogs: vi.fn<(logs: unknown[]) => Promise<void>>(async () => undefined)
};
const auditLogSettingsService = {
- getEffectiveSettings: vi.fn<(orgId: string) => Promise<Record<string, unknown> | null>>(async () => null)
+ getEffectiveSettings: vi.fn<(orgId: string, projectId?: string | null) => Promise<Record<string, unknown> | null>>(
+ async () => null
+ )
};
const clickhouseClient = clickhouse
? {
@@ -254,7 +256,6 @@ describe("audit-log-queue pushToLog", () => {
describe("audit-log-queue event class settings", () => {
const settings = (overrides: Record<string, unknown> = {}) => ({
org: {},
- projects: {},
shouldUseNewPrivilegeSystem: true,
...overrides
});
@@ -290,8 +291,8 @@ describe("audit-log-queue event class settings", () => {
test("a project event uses the project's own setting, never the org's", async () => {
const { service, keyStore, auditLogSettingsService } = await createHarness();
- auditLogSettingsService.getEffectiveSettings.mockResolvedValue(
- settings({ org: { authentication: false }, projects: { "p-off": { authentication: false } } })
+ auditLogSettingsService.getEffectiveSettings.mockImplementation(async (_orgId, projectId) =>
+ settings({ org: { authentication: false }, project: projectId === "p-off" ? { authentication: false } : {} })
);
await service.pushToLog(dto({ projectId: "p-none", event: { type: "user-login", metadata: {} } }) as never);
@@ -299,12 +300,13 @@ describe("audit-log-queue event class settings", () => {
await service.pushToLog(dto({ projectId: "p-off", event: { type: "user-login", metadata: {} } }) as never);
expect(keyStore.streamAdd).toHaveBeenCalledTimes(1);
+ expect(auditLogSettingsService.getEffectiveSettings).toHaveBeenLastCalledWith(expect.any(String), "p-off");
});
test("an org-scoped event ignores project settings", async () => {
const { service, keyStore, auditLogSettingsService } = await createHarness();
auditLogSettingsService.getEffectiveSettings.mockResolvedValueOnce(
- settings({ org: {}, projects: { p1: { authentication: false } } })
+ settings({ org: {}, project: { authentication: false } })
);
await service.pushToLog(dto({ event: { type: "user-login", metadata: {} } }) as never);
diff --git a/backend/src/ee/services/audit-log/audit-log-queue.ts b/backend/src/ee/services/audit-log/audit-log-queue.ts
index 4c26b32365..ebe6be0bc4 100644
--- a/backend/src/ee/services/audit-log/audit-log-queue.ts
+++ b/backend/src/ee/services/audit-log/audit-log-queue.ts
@@ -109,8 +109,8 @@ export const auditLogQueueServiceFactory = async ({
if (!orgId) return null;
if (!isAlwaysRecordedEventClass(getAuditLogEventClass(data.event.type))) {
- const settings = await requestMemoize(requestMemoKeys.auditLogSettings(orgId), () =>
- auditLogSettingsService.getEffectiveSettings(orgId)
+ const settings = await requestMemoize(requestMemoKeys.auditLogSettings(orgId, projectId), () =>
+ auditLogSettingsService.getEffectiveSettings(orgId, projectId)
);
if (!isAuditLogEventEnabled(settings, data.event.type, projectId)) return null;
}
diff --git a/backend/src/ee/services/audit-log/audit-log-service.test.ts b/backend/src/ee/services/audit-log/audit-log-service.test.ts
index 544ce5b8e2..ea4a0fc7ac 100644
--- a/backend/src/ee/services/audit-log/audit-log-service.test.ts
+++ b/backend/src/ee/services/audit-log/audit-log-service.test.ts
@@ -61,11 +61,13 @@ const createHarness = ({ windowAcquired = true, storedCount = "0", retentionDays
};
const licenseService = { getPlan: vi.fn(async () => ({ auditLogsRetentionDays: retentionDays })) };
const auditLogSettingsService = {
- getEffectiveSettings: vi.fn<(orgId: string) => Promise<TEffectiveAuditLogSettings>>(async () => ({
- org: {},
- projects: { "project-1": { [AuditLogEventClass.Authorization]: true } },
- shouldUseNewPrivilegeSystem: true
- }))
+ getEffectiveSettings: vi.fn<(orgId: string, projectId?: string | null) => Promise<TEffectiveAuditLogSettings>>(
+ async () => ({
+ org: {},
+ project: { [AuditLogEventClass.Authorization]: true },
+ shouldUseNewPrivilegeSystem: true
+ })
+ )
};
const service = auditLogServiceFactory({
@@ -172,7 +174,7 @@ describe("recordPermissionDenied", () => {
const { service, keyStore, auditLogQueue, auditLogSettingsService } = createHarness();
auditLogSettingsService.getEffectiveSettings.mockResolvedValueOnce({
org: {},
- projects: { "project-1": { [AuditLogEventClass.Authorization]: false } },
+ project: { [AuditLogEventClass.Authorization]: false },
shouldUseNewPrivilegeSystem: true
});
diff --git a/backend/src/ee/services/audit-log/audit-log-service.ts b/backend/src/ee/services/audit-log/audit-log-service.ts
index 6a7f4f7a57..6e5b4e17f5 100644
--- a/backend/src/ee/services/audit-log/audit-log-service.ts
+++ b/backend/src/ee/services/audit-log/audit-log-service.ts
@@ -303,11 +303,9 @@ export const auditLogServiceFactory = ({
if (appCfg.DISABLE_AUDIT_LOG_GENERATION) return;
try {
- const settings = await requestMemoize(requestMemoKeys.auditLogSettings(orgId), () =>
- auditLogSettingsService.getEffectiveSettings(orgId)
+ const settings = await requestMemoize(requestMemoKeys.auditLogSettings(orgId, projectId), () =>
+ auditLogSettingsService.getEffectiveSettings(orgId, projectId)
);
- // Skip on a failed lookup (null) instead of recording everything: authorization is opt-in, and
- // we can't tell if the org is on the new privilege system.
if (!settings?.shouldUseNewPrivilegeSystem) return;
if (!isAuditLogEventEnabled(settings, EventType.PERMISSION_DENIED, projectId)) return;
diff --git a/backend/src/ee/services/audit-log/audit-log-settings-service.test.ts b/backend/src/ee/services/audit-log/audit-log-settings-service.test.ts
index 7ab42ab65c..01914f9e9c 100644
--- a/backend/src/ee/services/audit-log/audit-log-settings-service.test.ts
+++ b/backend/src/ee/services/audit-log/audit-log-settings-service.test.ts
@@ -1,6 +1,7 @@
import { createMongoAbility, ForbiddenError } from "@casl/ability";
import { beforeEach, describe, expect, test, vi } from "vitest";
+import { KeyStorePrefixes } from "@app/keystore/keystore";
import { ActorType } from "@app/services/auth/auth-type";
import {
@@ -33,7 +34,6 @@ vi.mock("@app/lib/logger", () => ({
const settings = (overrides: Partial<TEffectiveAuditLogSettings> = {}): TEffectiveAuditLogSettings => ({
org: {},
- projects: {},
shouldUseNewPrivilegeSystem: true,
...overrides
});
@@ -44,9 +44,7 @@ describe("isAuditLogEventEnabled", () => {
test("a project uses its own row or the default, never the org's row", () => {
expect(isAuditLogEventEnabled(settings({ org: { [eventClass]: false } }), eventType, "p1")).toBe(true);
- expect(isAuditLogEventEnabled(settings({ projects: { p1: { [eventClass]: false } } }), eventType, "p1")).toBe(
- false
- );
+ expect(isAuditLogEventEnabled(settings({ project: { [eventClass]: false } }), eventType, "p1")).toBe(false);
});
test("an org-scoped event uses the org's row or the default", () => {
@@ -64,7 +62,7 @@ describe("isAuditLogEventEnabled", () => {
test("data access is always recorded, even with a row that says otherwise", () => {
const off = settings({
org: { [AuditLogEventClass.DataAccess]: false },
- projects: { p1: { [AuditLogEventClass.DataAccess]: false } }
+ project: { [AuditLogEventClass.DataAccess]: false }
});
expect(isAuditLogEventEnabled(off, EventType.GET_SECRETS)).toBe(true);
expect(isAuditLogEventEnabled(off, EventType.GET_SECRETS, "p1")).toBe(true);
@@ -102,7 +100,7 @@ const createHarness = ({ rows = [] as TRow[], shouldUseNewPrivilegeSystem = true
insertMany: vi.fn(async (data: TRow[]) => data)
};
const keyStore = {
- getItem: vi.fn(async () => null),
+ getItems: vi.fn(async (keys: string[]): Promise<(string | null)[]> => keys.map(() => null)),
setItemWithExpiry: vi.fn(async () => "OK"),
deleteItem: vi.fn(async () => 1)
};
@@ -149,31 +147,74 @@ describe("getEffectiveSettings", () => {
vi.clearAllMocks();
});
- test("loads only the org's own rows, split by scope", async () => {
- const { service, auditLogSettingsDAL } = createHarness({
- rows: [
- { orgId: "org-1", projectId: null, eventClass: "data-access", isEnabled: false },
- { orgId: "org-1", projectId: "p1", eventClass: "authentication", isEnabled: false },
- { orgId: "org-2", projectId: null, eventClass: "management", isEnabled: false }
- ]
- });
+ const scopedRows: TRow[] = [
+ { orgId: "org-1", projectId: null, eventClass: "data-access", isEnabled: false },
+ { orgId: "org-1", projectId: "p1", eventClass: "authentication", isEnabled: false },
+ { orgId: "org-1", projectId: "p2", eventClass: "authentication", isEnabled: true },
+ { orgId: "org-2", projectId: null, eventClass: "management", isEnabled: false }
+ ];
+
+ test("without a project, loads and caches only the org's own rows", async () => {
+ const { service, auditLogSettingsDAL, keyStore } = createHarness({ rows: scopedRows });
const result = await service.getEffectiveSettings("org-1");
- expect(auditLogSettingsDAL.find).toHaveBeenCalledWith({ orgId: "org-1" });
+ expect(auditLogSettingsDAL.find).toHaveBeenCalledTimes(1);
+ expect(auditLogSettingsDAL.find).toHaveBeenCalledWith({ orgId: "org-1", projectId: null });
+ expect(result).toEqual({ org: { "data-access": false }, shouldUseNewPrivilegeSystem: true });
+ expect(keyStore.setItemWithExpiry).toHaveBeenCalledTimes(1);
+ });
+
+ test("with a project, loads only that project's rows besides the org's", async () => {
+ const { service, auditLogSettingsDAL, keyStore } = createHarness({ rows: scopedRows });
+
+ const result = await service.getEffectiveSettings("org-1", "p1");
+
+ expect(auditLogSettingsDAL.find).toHaveBeenCalledWith({ orgId: "org-1", projectId: "p1" });
expect(result).toEqual({
org: { "data-access": false },
- projects: { p1: { authentication: false } },
+ project: { authentication: false },
shouldUseNewPrivilegeSystem: true
});
+ expect(keyStore.setItemWithExpiry).toHaveBeenCalledTimes(2);
});
- test("caches the loaded settings", async () => {
+ test("caches a project with no rows as empty so it isn't reloaded", async () => {
const { service, keyStore } = createHarness();
- await service.getEffectiveSettings("org-1");
+ await service.getEffectiveSettings("org-1", "p-none");
- expect(keyStore.setItemWithExpiry).toHaveBeenCalledTimes(1);
+ expect(keyStore.setItemWithExpiry).toHaveBeenCalledWith(
+ KeyStorePrefixes.AuditLogProjectSettings("org-1", "p-none"),
+ expect.any(Number),
+ "{}"
+ );
+ });
+
+ test("serves both scopes from one cache read without touching the database", async () => {
+ const { service, auditLogSettingsDAL, orgDAL, keyStore } = createHarness();
+ keyStore.getItems.mockResolvedValueOnce([
+ JSON.stringify({ overrides: { authentication: false }, shouldUseNewPrivilegeSystem: false }),
+ JSON.stringify({ authorization: true })
+ ]);
+
+ const result = await service.getEffectiveSettings("org-1", "p1");
+
+ expect(keyStore.getItems).toHaveBeenCalledTimes(1);
+ expect(orgDAL.findById).not.toHaveBeenCalled();
+ expect(auditLogSettingsDAL.find).not.toHaveBeenCalled();
+ expect(result).toEqual({
+ org: { authentication: false },
+ project: { authorization: true },
+ shouldUseNewPrivilegeSystem: false
+ });
+ });
+
+ test("returns null so everything is recorded when the database lookup fails", async () => {
+ const { service, auditLogSettingsDAL } = createHarness();
+ auditLogSettingsDAL.find.mockRejectedValueOnce(new Error("db down"));
+
+ await expect(service.getEffectiveSettings("org-1", "p1")).resolves.toBeNull();
});
});
@@ -302,6 +343,7 @@ describe("updateOrgSettings", () => {
expect.anything()
);
expect(keyStore.deleteItem).toHaveBeenCalledTimes(1);
+ expect(keyStore.deleteItem).toHaveBeenCalledWith(KeyStorePrefixes.AuditLogOrgSettings("org-1"));
expect(result).toEqual({
shouldUseNewPrivilegeSystem: true,
eventClasses: [
@@ -365,6 +407,15 @@ describe("updateProjectSettings", () => {
expect(auditLogSettingsDAL.delete).toHaveBeenCalledWith({ orgId: "org-1", projectId: "p1" }, expect.anything());
});
+
+ test("invalidates only the project's cached settings", async () => {
+ const { service, keyStore } = createHarness();
+
+ await service.updateProjectSettings({ ...projectActor, eventClasses: fullEventClasses });
+
+ expect(keyStore.deleteItem).toHaveBeenCalledTimes(1);
+ expect(keyStore.deleteItem).toHaveBeenCalledWith(KeyStorePrefixes.AuditLogProjectSettings("org-1", "p1"));
+ });
});
describe("built-in roles", () => {
diff --git a/backend/src/ee/services/audit-log/audit-log-settings-service.ts b/backend/src/ee/services/audit-log/audit-log-settings-service.ts
index 417bcadd19..e3599d6575 100644
--- a/backend/src/ee/services/audit-log/audit-log-settings-service.ts
+++ b/backend/src/ee/services/audit-log/audit-log-settings-service.ts
@@ -32,6 +32,7 @@ import { TAuditLogSettingsDALFactory } from "./audit-log-settings-dal";
import {
TAuditLogEventClassOverrides,
TAuditLogEventClassSetting,
+ TCachedOrgAuditLogSettings,
TEffectiveAuditLogSettings,
TGetOrgAuditLogSettingsDTO,
TGetProjectAuditLogSettingsDTO,
@@ -44,7 +45,7 @@ type TAuditLogSettingsServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById">;
projectDAL: Pick<TProjectDALFactory, "findById">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission" | "getProjectPermission">;
- keyStore: Pick<TKeyStoreFactory, "getItem" | "setItemWithExpiry" | "deleteItem">;
+ keyStore: Pick<TKeyStoreFactory, "getItems" | "setItemWithExpiry" | "deleteItem">;
};
export type TAuditLogSettingsServiceFactory = ReturnType<typeof auditLogSettingsServiceFactory>;
@@ -62,7 +63,7 @@ export const isAuditLogEventEnabled = (
const eventClass = getAuditLogEventClass(eventType);
if (isAlwaysRecordedEventClass(eventClass)) return true;
if (!settings) return true;
- const scope = projectId ? settings.projects[projectId] : settings.org;
+ const scope = projectId ? settings.project : settings.org;
return scope?.[eventClass] ?? AUDIT_LOG_EVENT_CLASS_DEFAULTS[eventClass];
};
@@ -156,51 +157,91 @@ export const auditLogSettingsServiceFactory = ({
shouldUseNewPrivilegeSystem: Boolean(org.shouldUseNewPrivilegeSystem)
});
- const invalidateCache = async (orgId: string) => {
+ const deleteCachedItem = async (key: string, scopeLog: string) => {
try {
- await keyStore.deleteItem(KeyStorePrefixes.AuditLogOrgSettings(orgId));
+ await keyStore.deleteItem(key);
} catch (error) {
- logger.warn(error, `audit-log-settings: failed to invalidate cached settings [orgId=${orgId}]`);
+ logger.warn(error, `audit-log-settings: failed to invalidate cached settings [${scopeLog}]`);
}
};
- const loadSettings = async (orgId: string): Promise<TEffectiveAuditLogSettings | null> => {
+ const invalidateCache = (orgId: string) =>
+ deleteCachedItem(KeyStorePrefixes.AuditLogOrgSettings(orgId), `orgId=${orgId}`);
+
+ const invalidateScopeCache = (scope: TScope) =>
+ scope.projectId
+ ? deleteCachedItem(
+ KeyStorePrefixes.AuditLogProjectSettings(scope.orgId, scope.projectId),
+ `orgId=${scope.orgId}] [projectId=${scope.projectId}`
+ )
+ : invalidateCache(scope.orgId);
+
+ const loadOrgSettings = async (orgId: string): Promise<TCachedOrgAuditLogSettings | null> => {
const org = await orgDAL.findById(orgId);
if (!org) return null;
-
- const rows = await auditLogSettingsDAL.find({ orgId });
- const projectRows = new Map<string, TScopeRow[]>();
- rows.forEach((row) => {
- if (!row.projectId) return;
- projectRows.set(row.projectId, [...(projectRows.get(row.projectId) ?? []), row]);
- });
+ const rows = await auditLogSettingsDAL.find({ orgId, projectId: null });
return {
- org: toOverrides(rows.filter((row) => !row.projectId)),
- projects: Object.fromEntries(
- [...projectRows].map(([projectId, scopeRows]) => [projectId, toOverrides(scopeRows)])
- ),
+ overrides: toOverrides(rows),
shouldUseNewPrivilegeSystem: Boolean(org.shouldUseNewPrivilegeSystem)
};
};
- // Hot path: cached and never throws. If the lookup fails we just record everything.
- const getEffectiveSettings = async (orgId: string): Promise<TEffectiveAuditLogSettings | null> => {
- const cacheKey = KeyStorePrefixes.AuditLogOrgSettings(orgId);
+ const loadProjectSettings = async (orgId: string, projectId: string): Promise<TAuditLogEventClassOverrides> =>
+ toOverrides(await auditLogSettingsDAL.find({ orgId, projectId }));
+
+ const readCachedItems = async (keys: string[]) => {
try {
- const cached = await keyStore.getItem(cacheKey);
- if (cached) return JSON.parse(cached) as TEffectiveAuditLogSettings;
+ return await keyStore.getItems(keys);
} catch (error) {
- logger.warn(error, `audit-log-settings: failed to read cached settings [orgId=${orgId}]`);
+ logger.warn(error, `audit-log-settings: failed to read cached settings [keys=${keys.join(",")}]`);
+ return keys.map(() => null);
}
+ };
+ const cacheItem = async (key: string, value: unknown) => {
try {
- const settings = await loadSettings(orgId);
- if (settings) {
- await keyStore.setItemWithExpiry(cacheKey, KeyStoreTtls.AuditLogOrgSettingsInSeconds, JSON.stringify(settings));
+ await keyStore.setItemWithExpiry(key, KeyStoreTtls.AuditLogSettingsInSeconds, JSON.stringify(value));
+ } catch (error) {
+ logger.warn(error, `audit-log-settings: failed to cache settings [key=${key}]`);
+ }
+ };
+
+ const getEffectiveSettings = async (
+ orgId: string,
+ projectId?: string | null
+ ): Promise<TEffectiveAuditLogSettings | null> => {
+ const orgKey = KeyStorePrefixes.AuditLogOrgSettings(orgId);
+ const projectKey = projectId ? KeyStorePrefixes.AuditLogProjectSettings(orgId, projectId) : undefined;
+
+ try {
+ const [cachedOrg, cachedProject] = await readCachedItems(projectKey ? [orgKey, projectKey] : [orgKey]);
+
+ let orgSettings = cachedOrg ? (JSON.parse(cachedOrg) as TCachedOrgAuditLogSettings) : null;
+ if (!orgSettings) {
+ orgSettings = await loadOrgSettings(orgId);
+ if (!orgSettings) return null;
+ await cacheItem(orgKey, orgSettings);
}
- return settings;
+
+ let project: TAuditLogEventClassOverrides | undefined;
+ if (projectId && projectKey) {
+ project = cachedProject ? (JSON.parse(cachedProject) as TAuditLogEventClassOverrides) : undefined;
+ if (!project) {
+ project = await loadProjectSettings(orgId, projectId);
+ await cacheItem(projectKey, project);
+ }
+ }
+
+ return {
+ org: orgSettings.overrides,
+ project,
+ shouldUseNewPrivilegeSystem: orgSettings.shouldUseNewPrivilegeSystem
+ };
} catch (error) {
- logger.warn(error, `audit-log-settings: failed to load settings, recording all events [orgId=${orgId}]`);
+ logger.warn(
+ error,
+ `audit-log-settings: failed to load settings, recording all events [orgId=${orgId}] [projectId=${projectId}]`
+ );
return null;
}
};
@@ -220,7 +261,7 @@ export const auditLogSettingsServiceFactory = ({
tx
);
});
- await invalidateCache(scope.orgId);
+ await invalidateScopeCache(scope);
};
const getOrgSettings = async ({ actor }: TGetOrgAuditLogSettingsDTO) => {
diff --git a/backend/src/ee/services/audit-log/audit-log-settings-types.ts b/backend/src/ee/services/audit-log/audit-log-settings-types.ts
index ad2ae494f6..b644a6da6a 100644
--- a/backend/src/ee/services/audit-log/audit-log-settings-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-settings-types.ts
@@ -25,8 +25,13 @@ export type TUpdateProjectAuditLogSettingsDTO = TProjectPermission & {
// Missing key = not set at this scope.
export type TAuditLogEventClassOverrides = Partial<Record<AuditLogEventClass, boolean>>;
+export type TCachedOrgAuditLogSettings = {
+ overrides: TAuditLogEventClassOverrides;
+ shouldUseNewPrivilegeSystem: boolean;
+};
+
export type TEffectiveAuditLogSettings = {
org: TAuditLogEventClassOverrides;
- projects: Record<string, TAuditLogEventClassOverrides>;
+ project?: TAuditLogEventClassOverrides;
shouldUseNewPrivilegeSystem: boolean;
};
diff --git a/backend/src/keystore/keystore.ts b/backend/src/keystore/keystore.ts
index d83a27fbc6..5b454d7538 100644
--- a/backend/src/keystore/keystore.ts
+++ b/backend/src/keystore/keystore.ts
@@ -200,7 +200,9 @@ export const KeyStorePrefixes = {
// Set alongside the free plan getPlan caches when the License Server fails, so callers can tell it from a real answer.
LicenseCloudPlanFallback: (orgId: string) => `infisical-cloud-plan-fallback-${orgId}` as const,
LicenseCloudPlanLastKnown: (orgId: string) => `infisical-cloud-plan-last-known-${orgId}` as const,
- AuditLogOrgSettings: (orgId: string) => `audit-log-settings-${orgId}` as const,
+ AuditLogOrgSettings: (orgId: string) => `audit-log-settings-org-${orgId}` as const,
+ AuditLogProjectSettings: (orgId: string, projectId: string) =>
+ `audit-log-settings-project-${orgId}-${projectId}` as const,
AuditLogCollapseWindow: (key: string) => `audit-log-collapse-window-${key}` as const,
AuditLogCollapseCount: (key: string, windowStart: string) =>
`audit-log-collapse-count-${key}-${windowStart}` as const,
@@ -274,7 +276,7 @@ export const KeyStoreTtls = {
AuditLogMigrationAlertInSeconds: 604800, // 7 days
LicenseCloudPlanInSeconds: 900, // 15 minutes
LicenseCloudPlanLastKnownInSeconds: 86400, // 24 hours
- AuditLogOrgSettingsInSeconds: 600, // 10 minutes
+ AuditLogSettingsInSeconds: 600, // 10 minutes
PamDefaultProjectInSeconds: 300, // 5 minutes
AgentVaultDefaultProjectInSeconds: 300, // 5 minutes
// How long reads stay in stale-while-revalidate mode after a billing mutation (covers Stripe reconciliation).
diff --git a/backend/src/lib/request-context/memo-keys.ts b/backend/src/lib/request-context/memo-keys.ts
index 0470e15871..975692c15e 100644
--- a/backend/src/lib/request-context/memo-keys.ts
+++ b/backend/src/lib/request-context/memo-keys.ts
@@ -58,7 +58,7 @@ export const requestMemoKeys = {
projectFindById: (projectId: string) => `project:findById:${projectId}`,
- auditLogSettings: (orgId: string) => `audit-log-settings:${orgId}`,
+ auditLogSettings: (orgId: string, projectId?: string | null) => `audit-log-settings:${orgId}:${projectId ?? ""}`,
licensePlan: (orgId: string) => `license:plan:${orgId}`,