Skip to content

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

add token ttl to credential expiry alert

Thiago Araujo da Silva009539a8b1f3
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.ts
index c413340a39..3498039831 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
@@ -1,4 +1,4 @@
-import { TableName } from "@app/db/schemas";
+import { IdentityAuthMethod, TableName } from "@app/db/schemas";
import { identityCredentialAlertDALFactory } from "./identity-credential-alert-dal";
@@ -138,4 +138,46 @@ describe("identity credential alert dal", () => {
expect(calls.groupedOrWhere).toContainEqual([`${TableName.Identity}.projectId`, "proj-1"]);
expect(calls.whereNull).not.toContainEqual(`${TableName.Identity}.projectId`);
});
+
+ test("a Token Auth scan only considers live Token Auth tokens with a max TTL", 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]);
+ });
+
+ test("a Token Auth token expires at its creation time plus its clamped max TTL, not its first JWT's TTL", async () => {
+ const { dal, calls } = buildDAL();
+
+ await dal.findExpiringTokenAuthTokens(scanArgs);
+
+ const expirySql = calls.whereRaw.map(([sql]) => sql as string).filter((sql) => sql.includes("make_interval"));
+ 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("?::timestamptz");
+ });
+ });
+
+ test("a Token Auth scan applies the same identity visibility rules as the client secret scan", async () => {
+ const orgScan = buildDAL();
+ await orgScan.dal.findExpiringTokenAuthTokens(scanArgs);
+
+ expect(orgScan.calls.where).toContainEqual([`${TableName.Membership}.scopeOrgId`, "org-1"]);
+ expect(orgScan.calls.where).toContainEqual([`${TableName.Identity}.orgId`, "org-1"]);
+ expect(orgScan.calls.whereNull).toContainEqual(`${TableName.Identity}.projectId`);
+
+ const projectScan = buildDAL();
+ await projectScan.dal.findExpiringTokenAuthTokens({ ...scanArgs, projectId: "proj-1", identityId: "ident-1" });
+
+ expect(projectScan.calls.where).toContainEqual(["projectMembership.scopeProjectId", "proj-1"]);
+ expect(projectScan.calls.groupedOrWhere).toContainEqual([`${TableName.Identity}.projectId`, "proj-1"]);
+ expect(projectScan.calls.where).toContainEqual([`${TableName.IdentityAccessToken}.identityId`, "ident-1"]);
+ });
});
diff --git a/backend/src/services/alert/providers/identity-credential-alert-dal.ts b/backend/src/services/alert/providers/identity-credential-alert-dal.ts
index 8573e14712..cadb343c59 100644
--- a/backend/src/services/alert/providers/identity-credential-alert-dal.ts
+++ b/backend/src/services/alert/providers/identity-credential-alert-dal.ts
@@ -1,8 +1,9 @@
import { Knex } from "knex";
import { TDbClient } from "@app/db";
-import { AccessScope, TableName } from "@app/db/schemas";
+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_UA_CLIENT_SECRET_TTL_SECONDS } from "@app/services/identity-ua/identity-ua-types";
export type TIdentityCredentialAlertDALFactory = ReturnType<typeof identityCredentialAlertDALFactory>;
@@ -16,23 +17,56 @@ export type TExpiringUaClientSecret = {
expiresAt: Date;
};
+export type TExpiringTokenAuthToken = {
+ id: string;
+ name: string | null;
+ identityId: string;
+ identityName: string;
+ expiresAt: Date;
+};
+
+type TExpiringCredentialScanInput = {
+ orgId: string;
+ projectId?: string | null;
+ identityId?: string | null;
+ alertBeforeInterval: string;
+ leadInterval: string;
+ asOf: Date;
+};
+
+const scopeToVisibleIdentities = (
+ query: Knex.QueryBuilder,
+ identityIdColumn: string,
+ { orgId, projectId, identityId }: Pick<TExpiringCredentialScanInput, "orgId" | "projectId" | "identityId">
+) => {
+ void query
+ .join(TableName.Membership, identityIdColumn, `${TableName.Membership}.actorIdentityId`)
+ .join(TableName.Identity, identityIdColumn, `${TableName.Identity}.id`)
+ .where(`${TableName.Membership}.scope`, AccessScope.Organization)
+ .where(`${TableName.Membership}.scopeOrgId`, orgId)
+ .where(`${TableName.Identity}.orgId`, orgId);
+
+ if (projectId) {
+ void query
+ .join({ projectMembership: TableName.Membership }, identityIdColumn, "projectMembership.actorIdentityId")
+ .where("projectMembership.scope", AccessScope.Project)
+ .where("projectMembership.scopeProjectId", projectId)
+ .where(
+ (bd) =>
+ void bd.whereNull(`${TableName.Identity}.projectId`).orWhere(`${TableName.Identity}.projectId`, projectId)
+ );
+ } else {
+ void query.whereNull(`${TableName.Identity}.projectId`);
+ }
+
+ if (identityId) {
+ void query.where(identityIdColumn, identityId);
+ }
+};
+
export const identityCredentialAlertDALFactory = (db: TDbClient) => {
const findExpiringUaClientSecrets = async (
- {
- orgId,
- projectId,
- identityId,
- alertBeforeInterval,
- leadInterval,
- asOf
- }: {
- orgId: string;
- projectId?: string | null;
- identityId?: string | null;
- alertBeforeInterval: string;
- leadInterval: string;
- asOf: Date;
- },
+ { alertBeforeInterval, leadInterval, asOf, ...scope }: TExpiringCredentialScanInput,
tx?: Knex
): Promise<TExpiringUaClientSecret[]> => {
try {
@@ -45,15 +79,6 @@ export const identityCredentialAlertDALFactory = (db: TDbClient) => {
`${TableName.IdentityUaClientSecret}.identityUAId`,
`${TableName.IdentityUniversalAuth}.id`
)
- .join(
- TableName.Membership,
- `${TableName.IdentityUniversalAuth}.identityId`,
- `${TableName.Membership}.actorIdentityId`
- )
- .join(TableName.Identity, `${TableName.IdentityUniversalAuth}.identityId`, `${TableName.Identity}.id`)
- .where(`${TableName.Membership}.scope`, AccessScope.Organization)
- .where(`${TableName.Membership}.scopeOrgId`, orgId)
- .where(`${TableName.Identity}.orgId`, orgId)
.where(`${TableName.IdentityUaClientSecret}.isClientSecretRevoked`, false)
.where(`${TableName.IdentityUaClientSecret}.clientSecretTTL`, ">", 0)
.whereRaw(`${expiresAtSql} > ?::timestamptz`, [asOf])
@@ -64,26 +89,7 @@ export const identityCredentialAlertDALFactory = (db: TDbClient) => {
])
.orderByRaw(`${expiresAtSql} asc`);
- if (projectId) {
- void query
- .join(
- { projectMembership: TableName.Membership },
- `${TableName.IdentityUniversalAuth}.identityId`,
- "projectMembership.actorIdentityId"
- )
- .where("projectMembership.scope", AccessScope.Project)
- .where("projectMembership.scopeProjectId", projectId)
- .where(
- (bd) =>
- void bd.whereNull(`${TableName.Identity}.projectId`).orWhere(`${TableName.Identity}.projectId`, projectId)
- );
- } else {
- void query.whereNull(`${TableName.Identity}.projectId`);
- }
-
- if (identityId) {
- void query.where(`${TableName.IdentityUniversalAuth}.identityId`, identityId);
- }
+ scopeToVisibleIdentities(query, `${TableName.IdentityUniversalAuth}.identityId`, scope);
const rows = (await query.select(
db.ref("id").withSchema(TableName.IdentityUaClientSecret),
@@ -100,6 +106,41 @@ export const identityCredentialAlertDALFactory = (db: TDbClient) => {
}
};
+ const findExpiringTokenAuthTokens = async (
+ { alertBeforeInterval, leadInterval, asOf, ...scope }: TExpiringCredentialScanInput,
+ 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 query = (tx || db.replicaNode())(TableName.IdentityAccessToken)
+ .where(`${TableName.IdentityAccessToken}.authMethod`, IdentityAuthMethod.TOKEN_AUTH)
+ .where(`${TableName.IdentityAccessToken}.isAccessTokenRevoked`, false)
+ .where(`${TableName.IdentityAccessToken}.accessTokenMaxTTL`, ">", 0)
+ .whereRaw(`${expiresAtSql} > ?::timestamptz`, [asOf])
+ .whereRaw(`${expiresAtSql} <= ?::timestamptz + ?::interval + ?::interval`, [
+ asOf,
+ alertBeforeInterval,
+ leadInterval
+ ])
+ .orderByRaw(`${expiresAtSql} asc`);
+
+ scopeToVisibleIdentities(query, `${TableName.IdentityAccessToken}.identityId`, scope);
+
+ const rows = (await query.select(
+ db.ref("id").withSchema(TableName.IdentityAccessToken),
+ db.ref("name").withSchema(TableName.IdentityAccessToken),
+ db.ref("identityId").withSchema(TableName.IdentityAccessToken),
+ db.ref("name").withSchema(TableName.Identity).as("identityName"),
+ db.raw(`${expiresAtSql} as "expiresAt"`)
+ )) as TExpiringTokenAuthToken[];
+
+ return rows;
+ } catch (error) {
+ throw new DatabaseError({ error, name: "FindExpiringTokenAuthTokens" });
+ }
+ };
+
const findIdentityInOrg = async (
identityId: string,
orgId: string,
@@ -168,6 +209,7 @@ export const identityCredentialAlertDALFactory = (db: TDbClient) => {
return {
findExpiringUaClientSecrets,
+ findExpiringTokenAuthTokens,
findIdentityInOrg,
isIdentityInProject,
getProjectType,
diff --git a/backend/src/services/alert/providers/identity-credential-alert-provider.test.ts b/backend/src/services/alert/providers/identity-credential-alert-provider.test.ts
index 219a724f8a..f1633af676 100644
--- a/backend/src/services/alert/providers/identity-credential-alert-provider.test.ts
+++ b/backend/src/services/alert/providers/identity-credential-alert-provider.test.ts
@@ -15,7 +15,7 @@ import {
MAX_DEDUP_WINDOW_HOURS,
TAlertContext
} from "../alert-types";
-import { TExpiringUaClientSecret } from "./identity-credential-alert-dal";
+import { TExpiringTokenAuthToken, TExpiringUaClientSecret } from "./identity-credential-alert-dal";
import {
IDENTITY_AUTH_METHOD_CHANGED_EVENT,
IDENTITY_AUTHENTICATION_EXPIRY_EVENT,
@@ -40,6 +40,15 @@ const sampleSecret = (overrides: Partial<TExpiringUaClientSecret> = {}): TExpiri
...overrides
});
+const sampleToken = (overrides: Partial<TExpiringTokenAuthToken> = {}): TExpiringTokenAuthToken => ({
+ id: "tok-1",
+ name: "release-token",
+ identityId: "ident-1",
+ identityName: "ci-runner",
+ expiresAt: futureDate(5),
+ ...overrides
+});
+
const alertContext = (overrides: Partial<TAlertContext> = {}): TAlertContext => ({
id: "alert-1",
name: "ua-expiry",
@@ -51,8 +60,19 @@ const alertContext = (overrides: Partial<TAlertContext> = {}): TAlertContext =>
...overrides
});
+type TScanArgs = {
+ orgId: string;
+ projectId?: string | null;
+ identityId?: string | null;
+ alertBeforeInterval: string;
+ leadInterval: string;
+ asOf: Date;
+};
+
const buildProvider = (opts?: {
secrets?: TExpiringUaClientSecret[];
+ tokens?: TExpiringTokenAuthToken[];
+ onFindTokens?: (args: TScanArgs) => void;
onFind?: (args: {
orgId: string;
projectId?: string | null;
@@ -89,6 +109,17 @@ const buildProvider = (opts?: {
opts?.onFind?.(args);
return opts?.secrets ?? [];
},
+ findExpiringTokenAuthTokens: async (args: {
+ orgId: string;
+ projectId?: string | null;
+ identityId?: string | null;
+ alertBeforeInterval: string;
+ leadInterval: string;
+ asOf: Date;
+ }) => {
+ opts?.onFindTokens?.(args);
+ return opts?.tokens ?? [];
+ },
findIdentityInOrg: async () =>
(opts?.inOrg ?? true)
? { orgId: opts?.ownerOrgId ?? "org-1", projectId: opts?.ownerProjectId ?? null }
@@ -456,14 +487,92 @@ describe("identity credential alert provider", () => {
const item = payload.items[0];
expect(item.title).toBe("ci-runner");
expect(item.fields?.some((f) => f.label === "Days Until Expiry")).toBe(false);
- expect(item.fields?.find((f) => f.label === "Secret Name")?.value).toBe("ci-secret");
- expect(item.fields?.find((f) => f.label === "Secret Type")?.value).toBe("Universal Auth Client Secret");
+ expect(item.fields?.find((f) => f.label === "Credential Name")?.value).toBe("ci-secret");
+ expect(item.fields?.find((f) => f.label === "Credential Type")?.value).toBe("Universal Auth Client Secret");
const expires = item.fields?.find((f) => f.label === "Expires")?.value;
expect(expires).toContain(String(expiresAt.getUTCFullYear()));
expect(expires).toContain("UTC");
});
+ test("findDueTargets scans Token Auth tokens with the same window and scope as client secrets", async () => {
+ let secretArgs: TScanArgs | undefined;
+ let tokenArgs: TScanArgs | undefined;
+ const provider = buildProvider({
+ tokens: [sampleToken()],
+ onFind: (args) => {
+ secretArgs = args;
+ },
+ onFindTokens: (args) => {
+ tokenArgs = args;
+ }
+ });
+
+ const targets = await provider.findDueTargets({
+ orgId: "org-1",
+ projectId: "proj-1",
+ resourceId: "ident-1",
+ eventType: IDENTITY_AUTHENTICATION_EXPIRY_EVENT,
+ condition: { alertBefore: "14d" },
+ asOf: new Date("2026-07-24T00:00:00.000Z")
+ });
+
+ expect(tokenArgs).toEqual(secretArgs);
+ expect(tokenArgs?.alertBeforeInterval).toBe("14 days");
+ expect(tokenArgs?.projectId).toBe("proj-1");
+ expect(tokenArgs?.identityId).toBe("ident-1");
+ expect(targets).toHaveLength(1);
+ expect(provider.targetId(targets[0])).toBe("token-auth-token:tok-1");
+ });
+
+ test("findDueTargets merges client secrets and tokens ordered by soonest expiry", async () => {
+ const provider = buildProvider({
+ secrets: [sampleSecret({ id: "sec-late", expiresAt: futureDate(20) })],
+ tokens: [
+ sampleToken({ id: "tok-soon", expiresAt: futureDate(2) }),
+ sampleToken({ id: "tok-mid", expiresAt: futureDate(10) })
+ ]
+ });
+
+ const targets = await provider.findDueTargets({
+ orgId: "org-1",
+ resourceId: null,
+ eventType: IDENTITY_AUTHENTICATION_EXPIRY_EVENT,
+ condition: { alertBefore: "30d" },
+ asOf: new Date()
+ });
+
+ expect(targets.map((target) => provider.targetId(target))).toEqual([
+ "token-auth-token:tok-soon",
+ "token-auth-token:tok-mid",
+ "ua-client-secret:sec-late"
+ ]);
+ });
+
+ test("buildPayload names a Token Auth token by its name and falls back to its id", async () => {
+ const provider = buildProvider();
+ const viewUrl = await provider.buildViewUrl(alertContext());
+ const named = {
+ kind: "expiring-credential" as const,
+ credentialType: "token-auth-token" as const,
+ ...sampleToken({ expiresAt: futureDate(10) })
+ };
+ const unnamed = {
+ kind: "expiring-credential" as const,
+ credentialType: "token-auth-token" as const,
+ ...sampleToken({ id: "tok-2", name: null, expiresAt: futureDate(10) })
+ };
+
+ const payload = provider.buildPayload(alertContext(), [named, unnamed], viewUrl);
+
+ expect(payload.severity).toBe("error"); // 10 days out
+ expect(payload.summary).toBe("2 machine identity authentication(s) expiring within 30 days");
+ expect(payload.items[0].fields?.find((f) => f.label === "Credential Name")?.value).toBe("release-token");
+ expect(payload.items[0].fields?.find((f) => f.label === "Credential Type")?.value).toBe("Token Auth Access Token");
+ expect(payload.items[1].id).toBe("token-auth-token:tok-2");
+ expect(payload.items[1].fields?.find((f) => f.label === "Credential Name")?.value).toBe("tok-2");
+ });
+
test("buildViewUrl points to the org identities tab for an org-scoped alert", async () => {
const provider = buildProvider();
expect(await provider.buildViewUrl(alertContext())).toBe(
diff --git a/backend/src/services/alert/providers/identity-credential-alert-provider.ts b/backend/src/services/alert/providers/identity-credential-alert-provider.ts
index 2995e1c83a..713b4537f6 100644
--- a/backend/src/services/alert/providers/identity-credential-alert-provider.ts
+++ b/backend/src/services/alert/providers/identity-credential-alert-provider.ts
@@ -31,7 +31,11 @@ import {
TFindDueTargetsInput,
TFindTargetsByIdsInput
} from "../alert-types";
-import { TExpiringUaClientSecret, TIdentityCredentialAlertDALFactory } from "./identity-credential-alert-dal";
+import {
+ TExpiringTokenAuthToken,
+ TExpiringUaClientSecret,
+ TIdentityCredentialAlertDALFactory
+} from "./identity-credential-alert-dal";
export { IDENTITY_AUTH_METHOD_CHANGED_EVENT, IDENTITY_AUTHENTICATION_RESOURCE_TYPE };
@@ -121,10 +125,9 @@ const IdentityCredentialConditionSchema = z.object({
const DAILY_REPEAT_DEDUP_WINDOW_HOURS = 20;
-type TExpiringCredentialTarget = {
- kind: "expiring-credential";
- credentialType: "ua-client-secret";
-} & TExpiringUaClientSecret;
+type TExpiringCredentialTarget =
+ | ({ kind: "expiring-credential"; credentialType: "ua-client-secret" } & TExpiringUaClientSecret)
+ | ({ kind: "expiring-credential"; credentialType: "token-auth-token" } & TExpiringTokenAuthToken);
type TAuthMethodChangeTarget = {
kind: "auth-method-change";
@@ -168,9 +171,15 @@ const severityFor = (targets: TExpiringCredentialTarget[]): TAlertSeverity => {
};
const CREDENTIAL_TYPE_LABEL: Record<TExpiringCredentialTarget["credentialType"], string> = {
- "ua-client-secret": "Universal Auth Client Secret"
+ "ua-client-secret": "Universal Auth Client Secret",
+ "token-auth-token": "Token Auth Access Token"
};
+const credentialName = (target: TExpiringCredentialTarget): string =>
+ target.credentialType === "ua-client-secret"
+ ? target.description || target.clientSecretPrefix
+ : target.name || target.id;
+
export type TIdentityCredentialAlertProviderDep = {
identityCredentialAlertDAL: TIdentityCredentialAlertDALFactory;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission" | "getProjectPermission">;
@@ -232,20 +241,32 @@ export const identityCredentialAlertProviderFactory = ({
const findDueTargets = async (input: TFindDueTargetsInput): Promise<TIdentityCredentialTarget[]> => {
const { alertBefore } = IdentityCredentialConditionSchema.parse(input.condition);
- const uaSecrets = await identityCredentialAlertDAL.findExpiringUaClientSecrets({
+ const scan = {
orgId: input.orgId,
projectId: input.projectId,
identityId: input.resourceId,
alertBeforeInterval: `${alertBeforeDays(alertBefore)} days`,
leadInterval: ALERT_SCAN_LEAD_INTERVAL,
asOf: input.asOf
- });
+ };
- return uaSecrets.map((secret) => ({
- kind: "expiring-credential" as const,
- credentialType: "ua-client-secret" as const,
- ...secret
- }));
+ const uaSecrets = await identityCredentialAlertDAL.findExpiringUaClientSecrets(scan);
+ const tokenAuthTokens = await identityCredentialAlertDAL.findExpiringTokenAuthTokens(scan);
+
+ const targets: TExpiringCredentialTarget[] = [
+ ...uaSecrets.map((secret) => ({
+ kind: "expiring-credential" as const,
+ credentialType: "ua-client-secret" as const,
+ ...secret
+ })),
+ ...tokenAuthTokens.map((token) => ({
+ kind: "expiring-credential" as const,
+ credentialType: "token-auth-token" as const,
+ ...token
+ }))
+ ];
+
+ return targets.sort((a, b) => new Date(a.expiresAt).getTime() - new Date(b.expiresAt).getTime());
};
const resolveActorLabel = async (orgId: string, actorType: ActorType, actorId?: string): Promise<string> => {
@@ -360,8 +381,8 @@ export const identityCredentialAlertProviderFactory = ({
id: targetId(target),
title: target.identityName,
fields: [
- { label: "Secret Name", value: target.description || target.clientSecretPrefix },
- { label: "Secret Type", value: CREDENTIAL_TYPE_LABEL[target.credentialType] },
+ { label: "Credential Name", value: credentialName(target) },
+ { label: "Credential Type", value: CREDENTIAL_TYPE_LABEL[target.credentialType] },
{ label: "Expires", value: formatUtcDate(target.expiresAt) }
]
}))
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.ts
index f8ea304d29..b829884a59 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,3 +55,5 @@ export type TRevokeTokenAuthTokenDTO = {
tokenId: string;
isActorSuperAdmin?: boolean;
} & Omit<TProjectPermission, "projectId">;
+
+export const MAX_TOKEN_AUTH_ACCESS_TOKEN_MAX_TTL_SECONDS = 315_360_000;
diff --git a/backend/src/services/smtp/emails/AlertNotificationTemplate.tsx b/backend/src/services/smtp/emails/AlertNotificationTemplate.tsx
index b745195bec..2f503e4bf0 100644
--- a/backend/src/services/smtp/emails/AlertNotificationTemplate.tsx
+++ b/backend/src/services/smtp/emails/AlertNotificationTemplate.tsx
@@ -119,17 +119,17 @@ AlertNotificationTemplate.PreviewProps = {
id: "ua-client-secret:1f0c3a5e-1111-4c2a-9f10-8b7d6e5a4c31",
title: "ci-runner",
fields: [
- { label: "Secret Name", value: "ci-secret" },
- { label: "Secret Type", value: "Universal Auth Client Secret" },
+ { label: "Credential Name", value: "ci-secret" },
+ { label: "Credential Type", value: "Universal Auth Client Secret" },
{ label: "Expires", value: "November 12, 2025, 02:30 PM UTC" }
]
},
{
- id: "ua-client-secret:2b9d4f7c-2222-4e83-b6a1-5c4e3d2b1a09",
+ id: "token-auth-token:2b9d4f7c-2222-4e83-b6a1-5c4e3d2b1a09",
title: "deploy-bot",
fields: [
- { label: "Secret Name", value: "release-token" },
- { label: "Secret Type", value: "Universal Auth Client Secret" },
+ { label: "Credential Name", value: "release-token" },
+ { label: "Credential Type", value: "Token Auth Access Token" },
{ label: "Expires", value: "November 10, 2025, 09:00 AM UTC" }
]
}
diff --git a/docs/documentation/platform/identities/machine-identities.mdx b/docs/documentation/platform/identities/machine-identities.mdx
index 9cf5a2e873..b49e480421 100644
--- a/docs/documentation/platform/identities/machine-identities.mdx
+++ b/docs/documentation/platform/identities/machine-identities.mdx
@@ -93,18 +93,20 @@ An alert on a machine identity notifies your team through the channels you pick.
| Event | When it fires |
|-------|---------------|
-| **Client Secret Expiration** | A set number of days before a Universal Auth client secret expires, checked once a day |
+| **Credential Expiration** | A set number of days before a Universal Auth client secret or Token Auth access token expires, checked once a day |
| **Auth Method Change** | Right after an auth method is added, updated, or removed, or a Universal Auth client secret or Token Auth token is created, updated, or revoked |
-### Client secret expiration
+### Credential expiration
-A machine identity whose credential expires unnoticed takes your workload down with it. This alert watches the Universal Auth client secrets attached to the identity and notifies your team a configurable number of days before they expire, so the credential gets rotated before anything breaks.
+A machine identity whose credential expires unnoticed takes your workload down with it. This alert watches the Universal Auth client secrets and Token Auth access tokens attached to the identity and notifies your team a configurable number of days before they expire, so the credential gets rotated before anything breaks.
A 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.
+
<Note>
- The alert watches the **client secret**, not the access tokens minted from it. Access tokens are
- short-lived by design and are renewed programmatically. See
+ For Universal Auth, the alert watches the client secret, not the access tokens minted by logging
+ in with it. Those access tokens are short-lived by design and are renewed programmatically. See
[Universal Auth](/documentation/platform/identities/universal-auth) for the difference between
Client Secret TTL, Access Token TTL, and Access Token Max TTL.
</Note>
@@ -127,9 +129,9 @@ Open the machine identity you want to monitor and select **Alert** in the top-ri
|-------|-------------|
| **Name** | A name for the alert, e.g. `ua-secret-expiry` |
| **Description** | Optional context about this alert |
-| **Event** | **Client Secret Expiration** or **Auth Method or Credential Change**. The event can't be changed after the alert is created; remove the alert and create a new one instead. |
-| **Condition** | For **Client Secret Expiration** only: how many days before expiration to notify, as a whole number from `1` to `90` |
-| **Daily Reminder** | For **Client Secret Expiration** only: if enabled, repeats the alert every day from the threshold until the credential expires |
+| **Event** | **Credential Expiration** or **Auth Method or Credential Change**. The event can't be changed after the alert is created; remove the alert and create a new one instead. |
+| **Condition** | For **Credential Expiration** only: how many days before expiration to notify, as a whole number from `1` to `90` |
+| **Daily Reminder** | For **Credential Expiration** only: if enabled, repeats the alert every day from the threshold until the credential expires |
| **Enabled** | Turn the alert off without deleting it |
With **Daily Reminder** off, each credential triggers the expiration alert once. Turn it on for credentials you can't afford to miss, and you'll get one notification per day until the credential expires or is rotated.
@@ -147,7 +149,7 @@ An alert delivers through one or more channels, up to 10 per alert. Add at least
### Webhook payload
-Webhook deliveries are [CloudEvents](https://cloudevents.io/) 1.0 JSON documents. The `type` names the event: `com.infisical.identity.authentication.expiration` for a client secret expiration and `com.infisical.identity.authentication.auth-method-changed` for an auth method change. Every credential due for this run, or the change that fired, is listed in `data.items`:
+Webhook deliveries are [CloudEvents](https://cloudevents.io/) 1.0 JSON documents. The `type` names the event: `com.infisical.identity.authentication.expiration` for a credential expiration and `com.infisical.identity.authentication.auth-method-changed` for an auth method change. Every credential due for this run, or the change that fired, is listed in `data.items`:
```json
{
@@ -170,14 +172,23 @@ Webhook deliveries are [CloudEvents](https://cloudevents.io/) 1.0 JSON documents
"id": "ua-client-secret:cff39386-bbe5-44eb-aecf-e2445167b497",
"title": "ci-deploy-bot",
"fields": [
- { "label": "Secret Name", "value": "github-actions" },
- { "label": "Secret Type", "value": "Universal Auth Client Secret" },
+ { "label": "Credential Name", "value": "github-actions" },
+ { "label": "Credential Type", "value": "Universal Auth Client Secret" },
{ "label": "Expires", "value": "August 23, 2026 at 04:15 PM UTC" }
]
+ },
+ {
+ "id": "token-auth-token:9d4b2e7a-3c1f-4a8e-b5d6-2f7c8e9a1b3d",
+ "title": "release-runner",
+ "fields": [
+ { "label": "Credential Name", "value": "release-token" },
+ { "label": "Credential Type", "value": "Token Auth Access Token" },
+ { "label": "Expires", "value": "August 21, 2026 at 09:00 AM UTC" }
+ ]
}
],
"metadata": {
- "totalItems": 1,
+ "totalItems": 2,
"viewUrl": "https://app.infisical.com/organizations/18b65352-ad1e-43d5-830f-65c72245c3a3/identities/c6002a8c-4571-4660-b169-f891f4734851"
}
}
diff --git a/docs/documentation/platform/identities/token-auth.mdx b/docs/documentation/platform/identities/token-auth.mdx
index 880005cddf..21118774a1 100644
--- a/docs/documentation/platform/identities/token-auth.mdx
+++ b/docs/documentation/platform/identities/token-auth.mdx
@@ -65,7 +65,7 @@ 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.
+ - 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 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/docs/documentation/platform/identities/universal-auth.mdx b/docs/documentation/platform/identities/universal-auth.mdx
index 3aae88ce3c..2cbba4ccd5 100644
--- a/docs/documentation/platform/identities/universal-auth.mdx
+++ b/docs/documentation/platform/identities/universal-auth.mdx
@@ -112,7 +112,7 @@ using the Universal Auth authentication method.
Feel free to input any (optional) details for the **Client Secret** configuration:
- Description: A description for the **Client Secret**.
- - TTL (default is `0`): The time-to-live for the **Client Secret**. By default, the TTL will be set to 0 which implies that the **Client Secret** will never expire; a value of `0` implies an infinite lifetime. When you set a TTL, configure a [credential expiry alert](/documentation/platform/identities/machine-identities#client-secret-expiration) so your team is notified before the **Client Secret** expires.
+ - TTL (default is `0`): The time-to-live for the **Client Secret**. By default, the TTL will be set to 0 which implies that the **Client Secret** will never expire; a value of `0` implies an infinite lifetime. When you set a TTL, configure a [credential expiry alert](/documentation/platform/identities/machine-identities#credential-expiration) so your team is notified before the **Client Secret** expires.
- Max Number of Uses (default is `0`): The maximum number of times that the **Client Secret** can be used together with the **Client ID** to get back an access token; a value of `0` implies infinite number of uses.
<Info>
diff --git a/frontend/src/hooks/api/alerts/types.ts b/frontend/src/hooks/api/alerts/types.ts
index a7bb7318d0..182344fcab 100644
--- a/frontend/src/hooks/api/alerts/types.ts
+++ b/frontend/src/hooks/api/alerts/types.ts
@@ -29,13 +29,13 @@ export const ALERT_RESOURCE_TYPE_LABELS: Record<AlertResourceType, string> = {
};
export const ALERT_EVENT_TYPE_LABELS: Record<AlertEventType, string> = {
- [AlertEventType.IdentityAuthenticationExpiry]: "Client Secret Expiration",
+ [AlertEventType.IdentityAuthenticationExpiry]: "Credential Expiration",
[AlertEventType.IdentityAuthMethodChanged]: "Auth Method Change"
};
export const ALERT_EVENT_TYPE_DESCRIPTIONS: Record<AlertEventType, string> = {
[AlertEventType.IdentityAuthenticationExpiry]:
- "Notify a set number of days before a Universal Auth client secret expires.",
+ "Notify a set number of days before a Universal Auth client secret or Token Auth access token expires.",
[AlertEventType.IdentityAuthMethodChanged]:
"Notify whenever an auth method is added, updated, or removed, or one of its credentials is created, updated, or revoked."
};
diff --git a/frontend/src/views/Alerts/AlertAction.tsx b/frontend/src/views/Alerts/AlertAction.tsx
index 259f86e558..a710d72aa5 100644
--- a/frontend/src/views/Alerts/AlertAction.tsx
+++ b/frontend/src/views/Alerts/AlertAction.tsx
@@ -49,7 +49,7 @@ type Props = {
renderPermissionGate: (render: (isAllowed: boolean) => ReactNode) => ReactNode;
};
-// "7 days before client secret expiry"; falls back to the event label when the
+// "7 days before credential expiry"; falls back to the event label when the
// stored condition is missing or malformed.
const formatConditionSummary = (alert: TAlert): string => {
if (alert.eventType === AlertEventType.IdentityAuthMethodChanged) {
@@ -59,7 +59,7 @@ const formatConditionSummary = (alert: TAlert): string => {
if (days === null) {
return ALERT_EVENT_TYPE_LABELS[alert.eventType as AlertEventType] ?? alert.eventType;
}
- return `${days} day${days === 1 ? "" : "s"} before client secret expiry`;
+ return `${days} day${days === 1 ? "" : "s"} before credential expiry`;
};
const formatChannelSummary = (alert: TAlert): string =>
diff --git a/frontend/src/views/Alerts/AlertForm.tsx b/frontend/src/views/Alerts/AlertForm.tsx
index 913810ba08..d1fc668d53 100644
--- a/frontend/src/views/Alerts/AlertForm.tsx
+++ b/frontend/src/views/Alerts/AlertForm.tsx
@@ -54,11 +54,11 @@ type Props = {
const DEFAULT_ALERT_BEFORE_DAYS = 7;
const DEFAULT_ALERT_NAMES: Record<AlertEventType, string> = {
- [AlertEventType.IdentityAuthenticationExpiry]: "Secret expiration alert",
+ [AlertEventType.IdentityAuthenticationExpiry]: "Credential expiration alert",
[AlertEventType.IdentityAuthMethodChanged]: "Auth method change alert"
};
const AGENT_VAULT_ALERT_NAME_PLACEHOLDERS: Record<AlertEventType, string> = {
- [AlertEventType.IdentityAuthenticationExpiry]: "Client secret expiration alert",
+ [AlertEventType.IdentityAuthenticationExpiry]: "Credential expiration alert",
[AlertEventType.IdentityAuthMethodChanged]: "Auth method change alert"
};
const DEFAULT_EVENT_TYPE = AlertEventType.IdentityAuthenticationExpiry;
@@ -316,7 +316,7 @@ export const AlertForm = ({ projectId, resourceId, alert, onComplete, onCancel }
isError={Boolean(errors.alertBeforeDays)}
{...register("alertBeforeDays", { valueAsNumber: true })}
/>
- <span>days before a client secret expires</span>
+ <span>days before a credential expires</span>
</div>
<FieldError errors={[errors.alertBeforeDays]} />
<Controller
diff --git a/frontend/src/views/IdentityAuthMethods/helpers/IdentityTokenAuthTokensTable.tsx b/frontend/src/views/IdentityAuthMethods/helpers/IdentityTokenAuthTokensTable.tsx
index 970e8eca6b..f3655ea50e 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,
- accessTokenTTL,
+ accessTokenMaxTTL,
accessTokenNumUsesLimit,
accessTokenNumUses,
id
} = token;
let expiresAt: Date | undefined;
- if (accessTokenTTL > 0) {
- expiresAt = new Date(new Date(createdAt).getTime() + accessTokenTTL * 1000);
+ if (accessTokenMaxTTL > 0) {
+ expiresAt = new Date(new Date(createdAt).getTime() + accessTokenMaxTTL * 1000);
}
return (
@@ -165,7 +165,7 @@ export const IdentityTokenAuthTokensTable = ({ tokens, identityId }: Props) => {
? "Revoked"
: expiresAt
? format(expiresAt, "yyyy-MM-dd")
- : "—"}
+ : "Renewable indefinitely"}
</TableCell>
<TableCell>
<DropdownMenu>