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
fix watched property
Thiago Araujo da Silva0cf70a223f5d
diff --git a/backend/src/services/alert/providers/identity-credential-alert-dal.test.ts b/backend/src/services/alert/providers/identity-credential-alert-dal.test.tsindex 3498039831..7dc2a997f8 100644--- a/backend/src/services/alert/providers/identity-credential-alert-dal.test.ts+++ b/backend/src/services/alert/providers/identity-credential-alert-dal.test.ts@@ -139,18 +139,17 @@ describe("identity credential alert dal", () => {expect(calls.whereNull).not.toContainEqual(`${TableName.Identity}.projectId`);});- test("a Token Auth scan only considers live Token Auth tokens with a max TTL", async () => {+ test("a Token Auth scan only considers live Token Auth tokens", async () => {const { dal, calls } = buildDAL();await dal.findExpiringTokenAuthTokens(scanArgs);expect(calls.where).toContainEqual([`${TableName.IdentityAccessToken}.authMethod`, IdentityAuthMethod.TOKEN_AUTH]);expect(calls.where).toContainEqual([`${TableName.IdentityAccessToken}.isAccessTokenRevoked`, false]);- // A max TTL of 0 means the token can be renewed forever, so it has no expiry to alert on.- expect(calls.where).toContainEqual([`${TableName.IdentityAccessToken}.accessTokenMaxTTL`, ">", 0]);+ expect(calls.where).toContainEqual([`${TableName.IdentityAccessToken}.accessTokenTTL`, ">", 0]);});- test("a Token Auth token expires at its creation time plus its clamped max TTL, not its first JWT's TTL", async () => {+ test("a Token Auth token expires at its creation time plus its clamped stored TTL, not its max TTL", async () => {const { dal, calls } = buildDAL();await dal.findExpiringTokenAuthTokens(scanArgs);@@ -159,8 +158,8 @@ describe("identity credential alert dal", () => {expect(expirySql.length).toBeGreaterThan(0);expirySql.forEach((sql) => {expect(sql).toContain(`${TableName.IdentityAccessToken}."createdAt"`);- expect(sql).toContain(`LEAST(GREATEST(${TableName.IdentityAccessToken}."accessTokenMaxTTL", 0), 315360000)`);- expect(sql).not.toContain('"accessTokenTTL"');+ expect(sql).toContain(`LEAST(GREATEST(${TableName.IdentityAccessToken}."accessTokenTTL", 0), 315360000)`);+ expect(sql).not.toContain('"accessTokenMaxTTL"');expect(sql).toContain("?::timestamptz");});});diff --git a/backend/src/services/alert/providers/identity-credential-alert-dal.ts b/backend/src/services/alert/providers/identity-credential-alert-dal.tsindex cadb343c59..432a6cc6bb 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_MAX_TTL_SECONDS } from "@app/services/identity-token-auth/identity-token-auth-types";+import { MAX_TOKEN_AUTH_ACCESS_TOKEN_TTL_SECONDS } from "@app/services/identity-token-auth/identity-token-auth-types";import { MAX_UA_CLIENT_SECRET_TTL_SECONDS } from "@app/services/identity-ua/identity-ua-types";export type TIdentityCredentialAlertDALFactory = ReturnType<typeof identityCredentialAlertDALFactory>;@@ -111,12 +111,12 @@ export const identityCredentialAlertDALFactory = (db: TDbClient) => {tx?: Knex): Promise<TExpiringTokenAuthToken[]> => {try {- const expiresAtSql = `${TableName.IdentityAccessToken}."createdAt" + make_interval(secs => LEAST(GREATEST(${TableName.IdentityAccessToken}."accessTokenMaxTTL", 0), ${MAX_TOKEN_AUTH_ACCESS_TOKEN_MAX_TTL_SECONDS}))`;+ const expiresAtSql = `${TableName.IdentityAccessToken}."createdAt" + make_interval(secs => LEAST(GREATEST(${TableName.IdentityAccessToken}."accessTokenTTL", 0), ${MAX_TOKEN_AUTH_ACCESS_TOKEN_TTL_SECONDS}))`;const query = (tx || db.replicaNode())(TableName.IdentityAccessToken).where(`${TableName.IdentityAccessToken}.authMethod`, IdentityAuthMethod.TOKEN_AUTH).where(`${TableName.IdentityAccessToken}.isAccessTokenRevoked`, false)- .where(`${TableName.IdentityAccessToken}.accessTokenMaxTTL`, ">", 0)+ .where(`${TableName.IdentityAccessToken}.accessTokenTTL`, ">", 0).whereRaw(`${expiresAtSql} > ?::timestamptz`, [asOf]).whereRaw(`${expiresAtSql} <= ?::timestamptz + ?::interval + ?::interval`, [asOf,diff --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 b829884a59..032aa14ba2 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@@ -56,4 +56,4 @@ export type TRevokeTokenAuthTokenDTO = {isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;-export const MAX_TOKEN_AUTH_ACCESS_TOKEN_MAX_TTL_SECONDS = 315_360_000;+export const MAX_TOKEN_AUTH_ACCESS_TOKEN_TTL_SECONDS = 315_360_000;diff --git a/docs/documentation/platform/identities/machine-identities.mdx b/docs/documentation/platform/identities/machine-identities.mdxindex b49e480421..8a53250b5d 100644--- a/docs/documentation/platform/identities/machine-identities.mdx+++ b/docs/documentation/platform/identities/machine-identities.mdx@@ -102,7 +102,7 @@ A machine identity whose credential expires unnoticed takes your workload down wA client secret is only monitored when its TTL is greater than `0`, since one created with the default TTL of `0` never expires and has nothing to alert on. Revoked client secrets are skipped.-A Token Auth token expires when its max TTL runs out, counted from the moment the token was created. Renewing the token extends the current session but can't push it past that point. A token with a max TTL of `0` can be renewed indefinitely, so it has no expiry to alert on and isn't monitored. Revoked tokens are skipped.+A Token Auth token is watched until its access token TTL runs out, counted from the moment the token was created. That's when the token stops working unless the workload renews it. Infisical doesn't track renewals, so a token that is renewed still triggers this alert on that first expiry. Revoked tokens are skipped.<Note>For Universal Auth, the alert watches the client secret, not the access tokens minted by loggingdiff --git a/docs/documentation/platform/identities/token-auth.mdx b/docs/documentation/platform/identities/token-auth.mdxindex 21118774a1..6a42906392 100644--- a/docs/documentation/platform/identities/token-auth.mdx+++ b/docs/documentation/platform/identities/token-auth.mdx@@ -64,8 +64,8 @@ using the Token Auth authentication method.Here's some more guidance on each field:- - Access Token TTL (default is `2592000` equivalent to 30 days): The lifetime for an access token in seconds. This value will be referenced at renewal time.- - Access Token Max TTL (default is `2592000` equivalent to 30 days): The maximum lifetime for an access token in seconds. This value will be referenced at renewal time. A [credential expiry alert](/documentation/platform/identities/machine-identities#credential-expiration) notifies your team before a token reaches it.+ - Access Token TTL (default is `2592000` equivalent to 30 days): The lifetime for an access token in seconds. This value will be referenced at renewal time. A [credential expiry alert](/documentation/platform/identities/machine-identities#credential-expiration) notifies your team before a token reaches it.+ - Access Token Max TTL (default is `2592000` equivalent to 30 days): The maximum lifetime for an access token in seconds. This value will be referenced at renewal time.- Access Token Max Number of Uses (default is `0`): The maximum number of times that an access token can be used; a value of `0` implies infinite number of uses.- Access Token Trusted IPs: The IPs or CIDR ranges that access tokens can be used from. By default, each token is given the `0.0.0.0/0`, allowing usage from any network address.diff --git a/frontend/src/views/IdentityAuthMethods/helpers/IdentityTokenAuthTokensTable.tsx b/frontend/src/views/IdentityAuthMethods/helpers/IdentityTokenAuthTokensTable.tsxindex f3655ea50e..970e8eca6b 100644--- a/frontend/src/views/IdentityAuthMethods/helpers/IdentityTokenAuthTokensTable.tsx+++ b/frontend/src/views/IdentityAuthMethods/helpers/IdentityTokenAuthTokensTable.tsx@@ -142,15 +142,15 @@ export const IdentityTokenAuthTokensTable = ({ tokens, identityId }: Props) => {createdAt,isAccessTokenRevoked,name,- accessTokenMaxTTL,+ accessTokenTTL,accessTokenNumUsesLimit,accessTokenNumUses,id} = token;let expiresAt: Date | undefined;- if (accessTokenMaxTTL > 0) {- expiresAt = new Date(new Date(createdAt).getTime() + accessTokenMaxTTL * 1000);+ if (accessTokenTTL > 0) {+ expiresAt = new Date(new Date(createdAt).getTime() + accessTokenTTL * 1000);}return (@@ -165,7 +165,7 @@ export const IdentityTokenAuthTokensTable = ({ tokens, identityId }: Props) => {? "Revoked": expiresAt? format(expiresAt, "yyyy-MM-dd")- : "Renewable indefinitely"}+ : "—"}</TableCell><TableCell><DropdownMenu>