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
unify constants
Thiago Araujo da Silva14f22279b9c9
diff --git a/backend/src/services/alert/providers/identity-credential-alert-dal.ts b/backend/src/services/alert/providers/identity-credential-alert-dal.tsindex 432a6cc6bb..b9b032b9c7 100644--- a/backend/src/services/alert/providers/identity-credential-alert-dal.ts+++ b/backend/src/services/alert/providers/identity-credential-alert-dal.ts@@ -3,7 +3,7 @@ import { Knex } from "knex";import { TDbClient } from "@app/db";import { AccessScope, IdentityAuthMethod, TableName } from "@app/db/schemas";import { DatabaseError } from "@app/lib/errors";-import { MAX_TOKEN_AUTH_ACCESS_TOKEN_TTL_SECONDS } from "@app/services/identity-token-auth/identity-token-auth-types";+import { MAX_IDENTITY_ACCESS_TOKEN_TTL_SECONDS } from "@app/services/identity-access-token/identity-access-token-types";import { MAX_UA_CLIENT_SECRET_TTL_SECONDS } from "@app/services/identity-ua/identity-ua-types";export type TIdentityCredentialAlertDALFactory = ReturnType<typeof identityCredentialAlertDALFactory>;@@ -111,7 +111,7 @@ export const identityCredentialAlertDALFactory = (db: TDbClient) => {tx?: Knex): Promise<TExpiringTokenAuthToken[]> => {try {- const expiresAtSql = `${TableName.IdentityAccessToken}."createdAt" + make_interval(secs => LEAST(GREATEST(${TableName.IdentityAccessToken}."accessTokenTTL", 0), ${MAX_TOKEN_AUTH_ACCESS_TOKEN_TTL_SECONDS}))`;+ const expiresAtSql = `${TableName.IdentityAccessToken}."createdAt" + make_interval(secs => LEAST(GREATEST(${TableName.IdentityAccessToken}."accessTokenTTL", 0), ${MAX_IDENTITY_ACCESS_TOKEN_TTL_SECONDS}))`;const query = (tx || db.replicaNode())(TableName.IdentityAccessToken).where(`${TableName.IdentityAccessToken}.authMethod`, IdentityAuthMethod.TOKEN_AUTH)diff --git a/backend/src/services/alert/providers/identity-credential-alert-provider.ts b/backend/src/services/alert/providers/identity-credential-alert-provider.tsindex 81901864d6..c92265b84b 100644--- a/backend/src/services/alert/providers/identity-credential-alert-provider.ts+++ b/backend/src/services/alert/providers/identity-credential-alert-provider.ts@@ -250,8 +250,10 @@ export const identityCredentialAlertProviderFactory = ({asOf: input.asOf};- const uaSecrets = await identityCredentialAlertDAL.findExpiringUaClientSecrets(scan);- const tokenAuthTokens = await identityCredentialAlertDAL.findExpiringTokenAuthTokens(scan);+ const [uaSecrets, tokenAuthTokens] = await Promise.all([+ identityCredentialAlertDAL.findExpiringUaClientSecrets(scan),+ identityCredentialAlertDAL.findExpiringTokenAuthTokens(scan)+ ]);const targets: TExpiringCredentialTarget[] = [...uaSecrets.map((secret) => ({diff --git a/backend/src/services/identity-access-token/identity-access-token-dal.ts b/backend/src/services/identity-access-token/identity-access-token-dal.tsindex 8e9d5b322e..5be8a0d712 100644--- a/backend/src/services/identity-access-token/identity-access-token-dal.ts+++ b/backend/src/services/identity-access-token/identity-access-token-dal.ts@@ -6,6 +6,8 @@ import { DatabaseError } from "@app/lib/errors";import { ormify, selectAllTableCols } from "@app/lib/knex";import { logger } from "@app/lib/logger";+import { MAX_IDENTITY_ACCESS_TOKEN_TTL_SECONDS } from "./identity-access-token-types";+export type TIdentityAccessTokenDALFactory = ReturnType<typeof identityAccessTokenDALFactory>;export const identityAccessTokenDALFactory = (db: TDbClient) => {@@ -34,7 +36,6 @@ export const identityAccessTokenDALFactory = (db: TDbClient) => {const BATCH_SIZE = 5000;const MAX_RETRY_ON_FAILURE = 3;const QUERY_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes- const MAX_TTL = 315_360_000; // Maximum TTL value in seconds (10 years)// Get the current timestamp from the database at the start of the operation// This ensures all queries use the same "now" value for consistency@@ -77,12 +78,12 @@ export const identityAccessTokenDALFactory = (db: TDbClient) => {+ make_interval(secs => LEAST("${TableName.IdentityAccessToken}"."accessTokenTTL", -- Token's specified TTL- ? -- Capped by MAX_TTL (parameterized value)+ ? -- Capped by MAX_IDENTITY_ACCESS_TOKEN_TTL_SECONDS))< ?::timestamptz AT TIME ZONE 'UTC' -- Check if the calculated time is before now (cast to UTC timestamp for comparison)`,- [MAX_TTL, nowTimestamp]+ [MAX_IDENTITY_ACCESS_TOKEN_TTL_SECONDS, nowTimestamp]).select("id");diff --git a/backend/src/services/identity-access-token/identity-access-token-types.ts b/backend/src/services/identity-access-token/identity-access-token-types.tsindex eb96925088..7d8134a58d 100644--- a/backend/src/services/identity-access-token/identity-access-token-types.ts+++ b/backend/src/services/identity-access-token/identity-access-token-types.ts@@ -162,3 +162,5 @@ export type TRevocationDenyReason =| "auth-method"| "org-membership"| "org-membership-inactive";++export const MAX_IDENTITY_ACCESS_TOKEN_TTL_SECONDS = 315_360_000; // 10 yearsdiff --git a/backend/src/services/identity-token-auth/identity-token-auth-types.ts b/backend/src/services/identity-token-auth/identity-token-auth-types.tsindex 032aa14ba2..f8ea304d29 100644--- a/backend/src/services/identity-token-auth/identity-token-auth-types.ts+++ b/backend/src/services/identity-token-auth/identity-token-auth-types.ts@@ -55,5 +55,3 @@ export type TRevokeTokenAuthTokenDTO = {tokenId: string;isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;--export const MAX_TOKEN_AUTH_ACCESS_TOKEN_TTL_SECONDS = 315_360_000;