Skip to content

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

feat(tls-cert-auth): certificate-bound access tokens

bernie-g6affe957be51
diff --git a/backend/src/db/migrations/20261029005342_add-bind-access-token-to-certificate-to-identity-tls-cert-auth.ts b/backend/src/db/migrations/20261029005342_add-bind-access-token-to-certificate-to-identity-tls-cert-auth.ts
new file mode 100644
index 0000000000..773c8c6d45
--- /dev/null
+++ b/backend/src/db/migrations/20261029005342_add-bind-access-token-to-certificate-to-identity-tls-cert-auth.ts
@@ -0,0 +1,21 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+export async function up(knex: Knex): Promise<void> {
+ const hasColumn = await knex.schema.hasColumn(TableName.IdentityTlsCertAuth, "bindAccessTokenToCertificate");
+ if (!hasColumn) {
+ await knex.schema.alterTable(TableName.IdentityTlsCertAuth, (t) => {
+ t.boolean("bindAccessTokenToCertificate").notNullable().defaultTo(false);
+ });
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ const hasColumn = await knex.schema.hasColumn(TableName.IdentityTlsCertAuth, "bindAccessTokenToCertificate");
+ if (hasColumn) {
+ await knex.schema.alterTable(TableName.IdentityTlsCertAuth, (t) => {
+ t.dropColumn("bindAccessTokenToCertificate");
+ });
+ }
+}
diff --git a/backend/src/db/schemas/identity-tls-cert-auths.ts b/backend/src/db/schemas/identity-tls-cert-auths.ts
index 8c27263f98..7ba3885d51 100644
--- a/backend/src/db/schemas/identity-tls-cert-auths.ts
+++ b/backend/src/db/schemas/identity-tls-cert-auths.ts
@@ -21,7 +21,8 @@ export const IdentityTlsCertAuthsSchema = z.object({
allowedCommonNames: z.string().nullable().optional(),
encryptedCaCertificate: zodBuffer,
allowedSubjectAltNames: z.string().nullable().optional(),
- verifyClientCertificateChain: z.boolean().default(false)
+ verifyClientCertificateChain: z.boolean().default(false),
+ bindAccessTokenToCertificate: z.boolean().default(false)
});
export type TIdentityTlsCertAuths = z.infer<typeof IdentityTlsCertAuthsSchema>;
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 785a2f83f3..2f566d5899 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -2037,6 +2037,7 @@ interface AddIdentityTlsCertAuthEvent {
allowedCommonNames: string | null | undefined;
allowedSubjectAltNames: string[] | null | undefined;
verifyClientCertificateChain: boolean;
+ bindAccessTokenToCertificate: boolean;
accessTokenTTL: number;
accessTokenMaxTTL: number;
accessTokenNumUsesLimit: number;
@@ -2058,6 +2059,7 @@ interface UpdateIdentityTlsCertAuthEvent {
allowedCommonNames: string | null | undefined;
allowedSubjectAltNames: string[] | null | undefined;
verifyClientCertificateChain?: boolean;
+ bindAccessTokenToCertificate?: boolean;
accessTokenTTL?: number;
accessTokenMaxTTL?: number;
accessTokenNumUsesLimit?: number;
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index aae6ff5b7e..a999ce4705 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -442,6 +442,8 @@ export const TLS_CERT_AUTH = {
caCertificate: "The PEM-encoded CA certificate to validate client certificates.",
verifyClientCertificateChain:
"When false (default), the CA certificate must be the direct issuer of the client's leaf certificate. When true, the CA certificate is treated as a trust anchor and the client-presented chain (leaf plus intermediates) is validated up to it, supporting issuers that rotate beneath a stable root such as SPIRE X.509-SVIDs.",
+ bindAccessTokenToCertificate:
+ "When true, access tokens issued by this auth method are bound to the SHA-256 thumbprint of the client certificate used to log in (RFC 8705). Every request and renewal made with the token must present the same client certificate through the TLS-terminating proxy.",
accessTokenTTL: "The lifetime for an access token in seconds.",
accessTokenMaxTTL: "The maximum lifetime for an access token in seconds.",
accessTokenNumUsesLimit: "The maximum number of times that an access token can be used.",
@@ -456,6 +458,8 @@ export const TLS_CERT_AUTH = {
caCertificate: "The PEM-encoded CA certificate to validate client certificates.",
verifyClientCertificateChain:
"When false (default), the CA certificate must be the direct issuer of the client's leaf certificate. When true, the CA certificate is treated as a trust anchor and the client-presented chain (leaf plus intermediates) is validated up to it, supporting issuers that rotate beneath a stable root such as SPIRE X.509-SVIDs.",
+ bindAccessTokenToCertificate:
+ "When true, access tokens issued by this auth method are bound to the SHA-256 thumbprint of the client certificate used to log in (RFC 8705). Every request and renewal made with the token must present the same client certificate through the TLS-terminating proxy.",
accessTokenTTL: "The new lifetime for an access token in seconds.",
accessTokenMaxTTL: "The new maximum lifetime for an access token in seconds.",
accessTokenNumUsesLimit: "The new maximum number of times that an access token can be used.",
diff --git a/backend/src/server/plugins/auth/inject-identity.ts b/backend/src/server/plugins/auth/inject-identity.ts
index d39caaebaa..3f9523ebc9 100644
--- a/backend/src/server/plugins/auth/inject-identity.ts
+++ b/backend/src/server/plugins/auth/inject-identity.ts
@@ -21,6 +21,7 @@ import {
TKmipServerAccessTokenJwtPayload,
TRelayAccessTokenJwtPayload
} from "@app/services/auth/auth-type";
+import { readClientCertificateHeader } from "@app/services/identity-access-token/identity-access-token-fns";
import { TIdentityAccessTokenJwtPayload } from "@app/services/identity-access-token/identity-access-token-types";
import { OauthDelegationMode } from "@app/services/oauth-client/oauth-client-types";
import { getServerCfg } from "@app/services/super-admin/super-admin-service";
@@ -368,7 +369,8 @@ export const injectIdentity = fp(
case AuthMode.IDENTITY_ACCESS_TOKEN: {
const identity = await server.services.identityAccessToken.fnValidateIdentityAccessTokenFast(
token,
- req.realIp
+ req.realIp,
+ readClientCertificateHeader(req.headers)
);
const serverCfg = await getServerCfg();
requestContext.set(RequestContextKey.OrgId, identity.orgId);
diff --git a/backend/src/server/routes/v1/identity-access-token-router.ts b/backend/src/server/routes/v1/identity-access-token-router.ts
index 22d16db528..5ad9061c6c 100644
--- a/backend/src/server/routes/v1/identity-access-token-router.ts
+++ b/backend/src/server/routes/v1/identity-access-token-router.ts
@@ -2,6 +2,7 @@ import { z } from "zod";
import { ApiDocsTags, UNIVERSAL_AUTH } from "@app/lib/api-docs";
import { writeLimit } from "@app/server/config/rateLimiter";
+import { readClientCertificateHeader } from "@app/services/identity-access-token/identity-access-token-fns";
export const registerIdentityAccessTokenRouter = async (server: FastifyZodProvider) => {
server.route({
@@ -29,7 +30,8 @@ export const registerIdentityAccessTokenRouter = async (server: FastifyZodProvid
},
handler: async (req) => {
const { accessToken, expiresIn, accessTokenMaxTTL } = await server.services.identityAccessToken.renewAccessToken({
- accessToken: req.body.accessToken
+ accessToken: req.body.accessToken,
+ clientCertificate: readClientCertificateHeader(req.headers)
});
return {
accessToken,
diff --git a/backend/src/server/routes/v1/identity-tls-cert-auth-router.ts b/backend/src/server/routes/v1/identity-tls-cert-auth-router.ts
index ca062d1d36..ffc69bfbf3 100644
--- a/backend/src/server/routes/v1/identity-tls-cert-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-tls-cert-auth-router.ts
@@ -230,6 +230,10 @@ export const registerIdentityTlsCertAuthRouter = async (server: FastifyZodProvid
.boolean()
.default(false)
.describe(TLS_CERT_AUTH.ATTACH.verifyClientCertificateChain),
+ bindAccessTokenToCertificate: z
+ .boolean()
+ .default(false)
+ .describe(TLS_CERT_AUTH.ATTACH.bindAccessTokenToCertificate),
accessTokenTrustedIps: z
.object({
ipAddress: z.string().trim()
@@ -292,6 +296,7 @@ export const registerIdentityTlsCertAuthRouter = async (server: FastifyZodProvid
allowedCommonNames: identityTlsCertAuth.allowedCommonNames,
allowedSubjectAltNames: tlsCertAuthResponse.allowedSubjectAltNames,
verifyClientCertificateChain: identityTlsCertAuth.verifyClientCertificateChain,
+ bindAccessTokenToCertificate: identityTlsCertAuth.bindAccessTokenToCertificate,
accessTokenTTL: identityTlsCertAuth.accessTokenTTL,
accessTokenMaxTTL: identityTlsCertAuth.accessTokenMaxTTL,
accessTokenTrustedIps: identityTlsCertAuth.accessTokenTrustedIps as TIdentityTrustedIp[],
@@ -352,6 +357,10 @@ export const registerIdentityTlsCertAuthRouter = async (server: FastifyZodProvid
.boolean()
.optional()
.describe(TLS_CERT_AUTH.UPDATE.verifyClientCertificateChain),
+ bindAccessTokenToCertificate: z
+ .boolean()
+ .optional()
+ .describe(TLS_CERT_AUTH.UPDATE.bindAccessTokenToCertificate),
allowedCommonNames: validateCommonNames
.optional()
.nullable()
@@ -422,6 +431,7 @@ export const registerIdentityTlsCertAuthRouter = async (server: FastifyZodProvid
allowedCommonNames: identityTlsCertAuth.allowedCommonNames,
allowedSubjectAltNames: tlsCertAuthResponse.allowedSubjectAltNames,
verifyClientCertificateChain: identityTlsCertAuth.verifyClientCertificateChain,
+ bindAccessTokenToCertificate: identityTlsCertAuth.bindAccessTokenToCertificate,
accessTokenTTL: identityTlsCertAuth.accessTokenTTL,
accessTokenMaxTTL: identityTlsCertAuth.accessTokenMaxTTL,
accessTokenTrustedIps: identityTlsCertAuth.accessTokenTrustedIps as TIdentityTrustedIp[],
diff --git a/backend/src/services/identity-access-token/identity-access-token-fns.ts b/backend/src/services/identity-access-token/identity-access-token-fns.ts
index 2aa9ba4872..f7fb30dd1f 100644
--- a/backend/src/services/identity-access-token/identity-access-token-fns.ts
+++ b/backend/src/services/identity-access-token/identity-access-token-fns.ts
@@ -1,5 +1,8 @@
+import { IncomingHttpHeaders } from "node:http";
+
import jwt from "jsonwebtoken";
+import { extractX509CertFromChain } from "@app/lib/certificates/extract-certificate";
import { getConfig } from "@app/lib/config/env";
import { crypto } from "@app/lib/crypto";
import { generateCacheKeyFromData } from "@app/lib/crypto/cache";
@@ -8,6 +11,8 @@ import { TIp } from "@app/lib/ip";
import { AuthTokenType } from "../auth/auth-type";
import {
+ CERTIFICATE_THUMBPRINT_CLAIM,
+ TCertificateConfirmation,
TComputeIssuedTtlInput,
TCoreTokenClaims,
TIdentityAccessTokenJwtPayload,
@@ -404,6 +409,10 @@ export const signIdentityAccessToken = (input: TSignIdentityAccessTokenInput): T
payload.numUsesLimit = input.numUsesLimit;
}
+ if (input.cnf) {
+ payload.cnf = input.cnf;
+ }
+
const accessToken = crypto.jwt().sign(payload, appCfg.AUTH_SECRET, {
jwtid: jti,
expiresIn: input.ttlSeconds
@@ -411,3 +420,53 @@ export const signIdentityAccessToken = (input: TSignIdentityAccessTokenInput): T
return { accessToken, jti, expiresIn: input.ttlSeconds };
};
+
+export const computeCertificateThumbprint = (certificateDer: Buffer): string =>
+ crypto.nativeCrypto.createHash("sha256").update(certificateDer).digest("base64url");
+
+const parsePresentedLeafCertificate = (clientCertificate: string): Buffer | null => {
+ try {
+ const [leaf] = extractX509CertFromChain(decodeURIComponent(clientCertificate));
+ return new crypto.nativeCrypto.X509Certificate(leaf).raw;
+ } catch {
+ return null;
+ }
+};
+
+export const assertCertificateBinding = ({
+ cnf,
+ clientCertificate,
+ messagePrefix
+}: {
+ cnf?: TCertificateConfirmation;
+ clientCertificate?: string;
+ messagePrefix: "Failed to authorize" | "Cannot renew";
+}) => {
+ if (!cnf) return;
+
+ if (!clientCertificate) {
+ throw new UnauthorizedError({
+ message: `${messagePrefix}: access token is bound to a client certificate, but no client certificate was presented`
+ });
+ }
+
+ const leafDer = parsePresentedLeafCertificate(clientCertificate);
+ if (!leafDer) {
+ throw new UnauthorizedError({
+ message: `${messagePrefix}: the presented client certificate could not be parsed`
+ });
+ }
+
+ const presented = Buffer.from(computeCertificateThumbprint(leafDer));
+ const expected = Buffer.from(cnf[CERTIFICATE_THUMBPRINT_CLAIM] ?? "");
+ if (presented.length !== expected.length || !crypto.nativeCrypto.timingSafeEqual(presented, expected)) {
+ throw new UnauthorizedError({
+ message: `${messagePrefix}: the presented client certificate does not match the certificate the access token is bound to`
+ });
+ }
+};
+
+export const readClientCertificateHeader = (headers: IncomingHttpHeaders): string | undefined => {
+ const value = headers[getConfig().IDENTITY_TLS_CERT_AUTH_CLIENT_CERTIFICATE_HEADER_KEY];
+ return typeof value === "string" ? value : undefined;
+};
diff --git a/backend/src/services/identity-access-token/identity-access-token-service.test.ts b/backend/src/services/identity-access-token/identity-access-token-service.test.ts
index b002b77fed..f95597a0da 100644
--- a/backend/src/services/identity-access-token/identity-access-token-service.test.ts
+++ b/backend/src/services/identity-access-token/identity-access-token-service.test.ts
@@ -1,3 +1,4 @@
+import * as x509 from "@peculiar/x509";
import jwt from "jsonwebtoken";
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
@@ -6,9 +7,13 @@ import { crypto } from "@app/lib/crypto";
import { IPType, TIp } from "@app/lib/ip";
import { AuthTokenType } from "../auth/auth-type";
-import { signIdentityAccessToken, verifyAccessTokenJwt } from "./identity-access-token-fns";
+import {
+ computeCertificateThumbprint,
+ signIdentityAccessToken,
+ verifyAccessTokenJwt
+} from "./identity-access-token-fns";
import { identityAccessTokenServiceFactory } from "./identity-access-token-service";
-import { TIdentityAccessTokenJwtPayload } from "./identity-access-token-types";
+import { CERTIFICATE_THUMBPRINT_CLAIM, TIdentityAccessTokenJwtPayload } from "./identity-access-token-types";
const MAX_AGE = 7_776_000;
const AUTH_SECRET = "test-auth-secret";
@@ -1146,3 +1151,166 @@ describe("identityAccessTokenServiceFactory", () => {
expect(identityAccessTokenRevocationDAL.findActiveRevocationsForToken).toHaveBeenCalled();
});
});
+
+describe("certificate-bound access tokens", () => {
+ let previousFipsEnabled: string | undefined;
+ let boundPem: string;
+ let otherPem: string;
+ let boundThumbprint: string;
+
+ const makeCertificatePem = async (commonName: string) => {
+ const alg = { name: "ECDSA", namedCurve: "P-256", hash: "SHA-256" };
+ const keys = await globalThis.crypto.subtle.generateKey(alg, true, ["sign", "verify"]);
+ const cert = await x509.X509CertificateGenerator.createSelfSigned({
+ serialNumber: "01",
+ name: `CN=${commonName}`,
+ notBefore: new Date("2020-01-01T00:00:00Z"),
+ notAfter: new Date("2040-01-01T00:00:00Z"),
+ signingAlgorithm: alg,
+ keys
+ });
+ return cert.toString("pem");
+ };
+
+ const asHeader = (pem: string) => encodeURIComponent(pem);
+
+ const signBoundToken = (overrides: { numUsesLimit?: number } = {}) =>
+ signIdentityAccessToken({
+ identityAccessTokenId: "token-id",
+ identityId: "identity-id",
+ identityName: "identity-name",
+ authMethod: IdentityAuthMethod.TLS_CERT_AUTH,
+ orgId: "org-id",
+ rootOrgId: "root-org-id",
+ parentOrgId: "parent-org-id",
+ clientSecretId: "",
+ numUsesLimit: overrides.numUsesLimit ?? 0,
+ ipRestrictionEnabled: false,
+ ttlSeconds: 3600,
+ accessTokenTTL: 3600,
+ accessTokenMaxTTL: 7200,
+ accessTokenPeriod: 0,
+ creationEpoch: NOW_SECONDS,
+ identityAuth: {},
+ cnf: { [CERTIFICATE_THUMBPRINT_CLAIM]: boundThumbprint }
+ }).accessToken;
+
+ beforeAll(async () => {
+ previousFipsEnabled = process.env.FIPS_ENABLED;
+ process.env.FIPS_ENABLED = "false";
+ await crypto.initialize({} as never, {} as never, {} as never);
+ x509.cryptoProvider.set(globalThis.crypto);
+ boundPem = await makeCertificatePem("bound-client");
+ otherPem = await makeCertificatePem("other-client");
+ boundThumbprint = computeCertificateThumbprint(new crypto.nativeCrypto.X509Certificate(boundPem).raw);
+ });
+
+ afterAll(() => {
+ if (previousFipsEnabled === undefined) {
+ delete process.env.FIPS_ENABLED;
+ } else {
+ process.env.FIPS_ENABLED = previousFipsEnabled;
+ }
+ });
+
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date(NOW_SECONDS * 1000));
+ });
+
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+
+ test("thumbprint is the base64url SHA-256 of the certificate DER", () => {
+ const der = new crypto.nativeCrypto.X509Certificate(boundPem).raw;
+ expect(boundThumbprint).toBe(crypto.nativeCrypto.createHash("sha256").update(der).digest("base64url"));
+ for (const char of ["+", "/", "="]) expect(boundThumbprint).not.toContain(char);
+ });
+
+ test("accepts a bound token when the matching certificate is presented", async () => {
+ const { service } = createService();
+ const claims = verifyAccessTokenJwt(signBoundToken());
+
+ await expect(
+ service.fnValidateIdentityAccessTokenFast(claims, "10.0.0.1", asHeader(boundPem))
+ ).resolves.toMatchObject({ identityId: "identity-id" });
+ });
+
+ test("uses the leaf when the proxy forwards a full chain", async () => {
+ const { service } = createService();
+ const claims = verifyAccessTokenJwt(signBoundToken());
+
+ await expect(
+ service.fnValidateIdentityAccessTokenFast(claims, "10.0.0.1", asHeader(`${boundPem}\n${otherPem}`))
+ ).resolves.toMatchObject({ identityId: "identity-id" });
+ });
+
+ test("rejects a bound token when no certificate is presented", async () => {
+ const { service } = createService();
+ const claims = verifyAccessTokenJwt(signBoundToken());
+
+ await expect(service.fnValidateIdentityAccessTokenFast(claims, "10.0.0.1")).rejects.toThrow(
+ "no client certificate was presented"
+ );
+ });
+
+ test("rejects a bound token when a different certificate is presented", async () => {
+ const { service } = createService();
+ const claims = verifyAccessTokenJwt(signBoundToken());
+
+ await expect(service.fnValidateIdentityAccessTokenFast(claims, "10.0.0.1", asHeader(otherPem))).rejects.toThrow(
+ "does not match the certificate the access token is bound to"
+ );
+ });
+
+ test("rejects a bound token when the certificate header cannot be parsed", async () => {
+ const { service } = createService();
+ const claims = verifyAccessTokenJwt(signBoundToken());
+
+ await expect(service.fnValidateIdentityAccessTokenFast(claims, "10.0.0.1", "%E0%A4%A")).rejects.toThrow(
+ "could not be parsed"
+ );
+ });
+
+ test("does not spend a token use when the certificate does not match", async () => {
+ const { service, keyStore } = createService();
+ keyStore.getItem.mockResolvedValue("3");
+ const claims = verifyAccessTokenJwt(signBoundToken({ numUsesLimit: 3 }));
+
+ await expect(service.fnValidateIdentityAccessTokenFast(claims, "10.0.0.1", asHeader(otherPem))).rejects.toThrow();
+ expect(keyStore.decrementIfExists).not.toHaveBeenCalled();
+ });
+
+ test("ignores the certificate header for unbound tokens", async () => {
+ const { service } = createService();
+
+ await expect(
+ service.fnValidateIdentityAccessTokenFast(createTokenClaims(), "10.0.0.1", asHeader(otherPem))
+ ).resolves.toMatchObject({ identityId: "identity-id" });
+ });
+
+ test("renewal keeps the binding when the matching certificate is presented", async () => {
+ const { service } = createService();
+
+ const renewed = await service.renewAccessToken({
+ accessToken: signBoundToken(),
+ clientCertificate: asHeader(boundPem)
+ });
+
+ expect(verifyAccessTokenJwt(renewed.accessToken).cnf).toEqual({
+ [CERTIFICATE_THUMBPRINT_CLAIM]: boundThumbprint
+ });
+ });
+
+ test("renewal requires the bound certificate", async () => {
+ const { service } = createService();
+
+ await expect(service.renewAccessToken({ accessToken: signBoundToken() })).rejects.toThrow(
+ "Cannot renew: access token is bound to a client certificate, but no client certificate was presented"
+ );
+ await expect(
+ service.renewAccessToken({ accessToken: signBoundToken(), clientCertificate: asHeader(otherPem) })
+ ).rejects.toThrow("Cannot renew: the presented client certificate does not match");
+ });
+});
diff --git a/backend/src/services/identity-access-token/identity-access-token-service.ts b/backend/src/services/identity-access-token/identity-access-token-service.ts
index c3053222e0..1552851cf5 100644
--- a/backend/src/services/identity-access-token/identity-access-token-service.ts
+++ b/backend/src/services/identity-access-token/identity-access-token-service.ts
@@ -17,6 +17,7 @@ import { TIdentityDALFactory } from "../identity/identity-dal";
import { TOrgDALFactory } from "../org/org-dal";
import { TIdentityAccessTokenDALFactory } from "./identity-access-token-dal";
import {
+ assertCertificateBinding,
assertJwtNotExpired,
assertMinimalRenewClaims,
assertRevocableClaims,
@@ -39,6 +40,7 @@ import {
import { TIdentityAccessTokenRevocationDALFactory } from "./identity-access-token-revocation-dal";
import {
TAWSAuthDetails,
+ TCertificateConfirmation,
TIdentityAccessTokenJwtPayload,
TKubernetesAuthDetails,
TMinimalRenewClaims,
@@ -68,6 +70,7 @@ export type TIssueIdentityAccessTokenInput = {
kubernetes?: TKubernetesAuthDetails;
aws?: TAWSAuthDetails;
};
+ cnf?: TCertificateConfirmation;
// Set by Token Auth to insert a real PG row in its transaction; every other
// auth method omits this and gets a fresh in-memory UUID.
persistToPg?: { tx: Knex; name?: string | null };
@@ -388,7 +391,8 @@ export const identityAccessTokenServiceFactory = ({
accessTokenMaxTTL: requestedMaxTTL,
accessTokenPeriod: period,
creationEpoch,
- identityAuth: input.identityAuth
+ identityAuth: input.identityAuth,
+ cnf: input.cnf
});
if (numUsesLimit > 0) {
@@ -435,9 +439,14 @@ export const identityAccessTokenServiceFactory = ({
};
};
- const fnValidateIdentityAccessTokenFast = async (rawToken: TIdentityAccessTokenJwtPayload, ipAddress?: string) => {
+ const fnValidateIdentityAccessTokenFast = async (
+ rawToken: TIdentityAccessTokenJwtPayload,
+ ipAddress?: string,
+ clientCertificate?: string
+ ) => {
const appCfg = getConfig();
const token = assertMinimalRenewClaims(rawToken);
+ assertCertificateBinding({ cnf: token.cnf, clientCertificate, messagePrefix: "Failed to authorize" });
const tokenId = token.jti ?? token.identityAccessTokenId;
const source: TRenewSource = hasFullRenewClaims(token)
? {
@@ -557,9 +566,10 @@ export const identityAccessTokenServiceFactory = ({
};
};
- const renewAccessTokenInner = async ({ accessToken }: TRenewAccessTokenDTO) => {
+ const renewAccessTokenInner = async ({ accessToken, clientCertificate }: TRenewAccessTokenDTO) => {
const appCfg = getConfig();
const decodedToken = assertMinimalRenewClaims(verifyAccessTokenJwt(accessToken));
+ assertCertificateBinding({ cnf: decodedToken.cnf, clientCertificate, messagePrefix: "Cannot renew" });
// Single-JWT max age for legacy tokens without exp. New-format validation
// uses JWT exp; no-exp legacy tokens get a deployment-anchored grace window.
@@ -648,7 +658,8 @@ export const identityAccessTokenServiceFactory = ({
accessTokenTTL: source.accessTokenTTL,
accessTokenMaxTTL: source.accessTokenMaxTTL,
accessTokenPeriod: source.accessTokenPeriod,
- creationEpoch: source.creationEpoch
+ creationEpoch: source.creationEpoch,
+ cnf: decodedToken.cnf
});
// Renewed JWT keeps the same token id; PG revocation already applies. Reseed
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.ts
index 7d8134a58d..c2ae5c6bec 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
@@ -2,6 +2,13 @@ import { IdentityAuthMethod } from "@app/db/schemas";
export type TRenewAccessTokenDTO = {
accessToken: string;
+ clientCertificate?: string;
+};
+
+export const CERTIFICATE_THUMBPRINT_CLAIM = "x5t#S256";
+
+export type TCertificateConfirmation = {
+ [CERTIFICATE_THUMBPRINT_CLAIM]: string;
};
export type TOidcAuthDetails = {
@@ -61,6 +68,7 @@ export type TIdentityAccessTokenJwtPayload = {
kubernetes?: TKubernetesAuthDetails;
aws?: TAWSAuthDetails;
};
+ cnf?: TCertificateConfirmation;
};
// Claims present on every JWT we accept (legacy + new format). Pre-redesign
@@ -137,6 +145,7 @@ export type TSignIdentityAccessTokenInput = {
kubernetes?: TKubernetesAuthDetails;
aws?: TAWSAuthDetails;
};
+ cnf?: TCertificateConfirmation;
};
export type TSignIdentityAccessTokenOutput = {
diff --git a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
index c46f678f7f..740cbb9ace 100644
--- a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
+++ b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
@@ -30,7 +30,9 @@ import {
import { ActorType } from "../auth/auth-type";
import { TIdentityAccessTokenDALFactory } from "../identity-access-token/identity-access-token-dal";
+import { computeCertificateThumbprint } from "../identity-access-token/identity-access-token-fns";
import { TIdentityAccessTokenServiceFactory } from "../identity-access-token/identity-access-token-service";
+import { CERTIFICATE_THUMBPRINT_CLAIM } from "../identity-access-token/identity-access-token-types";
import { assertIdentityAuthAccessAllowed } from "../identity/identity-auth-permission-fns";
import { TIdentityDALFactory } from "../identity/identity-dal";
import { TKmsServiceFactory } from "../kms/kms-service";
@@ -421,7 +423,10 @@ export const identityTlsCertAuthServiceFactory = ({
accessTokenNumUsesLimit: Number(identityTlsCertAuth.accessTokenNumUsesLimit),
// TLS Cert auth schema has no accessTokenPeriod column.
accessTokenPeriod: 0,
- accessTokenTrustedIps: identityTlsCertAuth.accessTokenTrustedIps as TIp[]
+ accessTokenTrustedIps: identityTlsCertAuth.accessTokenTrustedIps as TIp[],
+ cnf: identityTlsCertAuth.bindAccessTokenToCertificate
+ ? { [CERTIFICATE_THUMBPRINT_CLAIM]: computeCertificateThumbprint(clientCertificateX509.raw) }
+ : undefined
});
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
@@ -489,7 +494,8 @@ export const identityTlsCertAuthServiceFactory = ({
caCertificate,
allowedCommonNames,
allowedSubjectAltNames,
- verifyClientCertificateChain: verifyClientCertificateChainOpt
+ verifyClientCertificateChain: verifyClientCertificateChainOpt,
+ bindAccessTokenToCertificate
}) => {
const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({
scopeData: {
@@ -565,6 +571,7 @@ export const identityTlsCertAuthServiceFactory = ({
accessTokenTTL,
encryptedCaCertificate: encryptor({ plainText: Buffer.from(caCertificate) }).cipherTextBlob,
verifyClientCertificateChain: verifyClientCertificateChainOpt ?? false,
+ bindAccessTokenToCertificate: bindAccessTokenToCertificate ?? false,
accessTokenNumUsesLimit,
accessTokenTrustedIps: JSON.stringify(reformattedAccessTokenTrustedIps)
},
@@ -593,6 +600,7 @@ export const identityTlsCertAuthServiceFactory = ({
allowedCommonNames,
allowedSubjectAltNames,
verifyClientCertificateChain: verifyClientCertificateChainOpt,
+ bindAccessTokenToCertificate,
accessTokenTTL,
accessTokenMaxTTL,
accessTokenNumUsesLimit,
@@ -687,6 +695,7 @@ export const identityTlsCertAuthServiceFactory = ({
? encryptor({ plainText: Buffer.from(caCertificate) }).cipherTextBlob
: undefined,
verifyClientCertificateChain: verifyClientCertificateChainOpt,
+ bindAccessTokenToCertificate,
accessTokenMaxTTL,
accessTokenTTL,
accessTokenNumUsesLimit,
diff --git a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-types.ts b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-types.ts
index 48a7d83739..55b9e9fc0c 100644
--- a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-types.ts
+++ b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-types.ts
@@ -13,6 +13,7 @@ export type TAttachTlsCertAuthDTO = {
allowedCommonNames?: string | null;
allowedSubjectAltNames?: string[] | null;
verifyClientCertificateChain?: boolean;
+ bindAccessTokenToCertificate?: boolean;
accessTokenTTL: number;
accessTokenMaxTTL: number;
accessTokenNumUsesLimit: number;
@@ -26,6 +27,7 @@ export type TUpdateTlsCertAuthDTO = {
allowedCommonNames?: string | null;
allowedSubjectAltNames?: string[] | null;
verifyClientCertificateChain?: boolean;
+ bindAccessTokenToCertificate?: boolean;
accessTokenTTL?: number;
accessTokenMaxTTL?: number;
accessTokenNumUsesLimit?: number;
diff --git a/docs/documentation/platform/identities/tls-cert-auth.mdx b/docs/documentation/platform/identities/tls-cert-auth.mdx
index 818592aee7..a4cc3cc9fa 100644
--- a/docs/documentation/platform/identities/tls-cert-auth.mdx
+++ b/docs/documentation/platform/identities/tls-cert-auth.mdx
@@ -95,6 +95,7 @@ Here's some information about each field:
- **CA Certificate:** A PEM encoded CA Certificate used to validate incoming TLS request client certificate. Any name constraints it asserts are honored, so a client certificate whose name falls outside the namespace the CA may certify is rejected. Both the CA Certificate and the client certificate must permit client authentication: a certificate that lists an Extended Key Usage without `clientAuth` (or `anyExtendedKeyUsage`) is rejected, since a CA's key usages also limit what the certificates beneath it may be used for. A certificate that lists no Extended Key Usage is unrestricted and is accepted.
- **Verify Client Certificate Chain (default is disabled):** By default, the CA Certificate must be the **direct issuer** of the client's leaf certificate. Enable this to instead treat the CA Certificate as a **trust anchor** and accept any client whose presented chain (leaf followed by intermediates) builds a valid path up to it. This is helpful when the issuing intermediate rotates beneath a long-lived root, such as a **SPIRE X.509-SVID**: you can pin the stable root here once and let the workload present its current intermediate alongside its leaf, rather than updating the CA Certificate on every rotation. Either way the trust anchor is the only certificate trusted, the client certificate must still be an end-entity certificate, and the Common Name and Subject Alternative Name checks below still apply to the leaf. Restrictions that the CAs on the path place on their subordinates are honored: a client certificate whose name falls outside an issuing CA's name constraints is rejected, as is a chain with more intermediates than a CA's path length permits, or one that passes through a CA whose Extended Key Usage doesn't permit client authentication.
+- **Bind Access Tokens to Client Certificate (default is disabled):** Binds each issued access token to the client certificate used to log in. See [Certificate-bound access tokens](#certificate-bound-access-tokens).
- **Allowed Common Names:** A comma separated list of client certificate common names allowed.
- **Allowed Subject Alternative Names:** A comma separated list of client certificate subject alternative names (SANs) allowed. This is useful when the client certificate carries its identity in a SAN rather than the Subject Common Name, such as a SPIFFE X.509-SVID whose identity is a URI SAN (`spiffe://trust-domain/path`) with an empty Subject. Matching is type-aware, so an entry only matches a SAN of the same type:
- **Type-prefixed entries** are matched against the corresponding SAN type, e.g. `URI:spiffe://example.org/svc`, `IP:10.0.0.1`, `EMAIL:[email protected]`.
@@ -181,14 +182,48 @@ try {
</Note>
+## Certificate-bound access tokens
+
+By default, an access token from TLS Certificate Auth is a bearer token: anyone holding it can use it. With **Bind Access Tokens to Client Certificate** enabled, the token also records the SHA-256 thumbprint of the client certificate used to log in, following [RFC 8705](https://www.rfc-editor.org/rfc/rfc8705) (the `cnf` claim with `x5t#S256`). A stolen token is then unusable without the certificate's private key.
+
+With binding enabled:
+
+- Every API request made with the token, including [token renewal](/api-reference/endpoints/universal-auth/renew-access-token), must present the same client certificate through the TLS-terminating proxy.
+- A request with no client certificate, or a different one, is rejected with `401 Unauthorized` and a message stating which.
+- Renewing the token keeps the binding.
+- After the client certificate rotates, the client must log in again to get a token bound to the new certificate.
+
+The client must present its certificate on every API call, not only on login. A custom client using the login example below must reuse the same HTTPS agent for its later API calls. The [Infisical Issuer for cert-manager](/documentation/platform/pki/guides/applications/k8s-cert-manager-issuer) supports this through the `tlsCert` method.
+
+On Infisical Cloud, send every API request made with a bound token to port `8443`, for example `https://app.infisical.com:8443`. Requests on port `443` carry no client certificate and are rejected.
+
+Turning the setting on or off applies to tokens issued afterwards. Tokens issued earlier keep the behavior they were issued with until they expire.
+
## Security requirements for self-hosted deployments
ALL TLS cert [login](/api-reference/endpoints/tls-cert-auth/login) requests **MUST** go through a load balancer/proxy that verifies certificate ownership:
- **REQUIRED:** Configure your load balancer/proxy to **require a proper TLS handshake with client certificate presentation**
- **REQUIRED:** Ensure the load balancer **verifies the client possesses the private key** corresponding to the certificate (standard TLS behavior)
-- **NEVER** allow direct connections to Infisical for TLS cert auth - this enables header injection attacks
+- **NEVER** allow direct connections to Infisical for TLS cert auth, since this enables header injection attacks
- **NEVER** forward certificate headers without requiring proper TLS certificate presentation
+- **REQUIRED:** Always overwrite the client certificate header with the certificate from the TLS handshake, or with an empty value when none was presented. Never pass through a value sent by the client: certificates are public, so a client-supplied header lets anyone claim any certificate.
+
+When **Bind Access Tokens to Client Certificate** is enabled on any identity, the proxy must set the header on **every** API request, not only on the login endpoint. Otherwise bound tokens are rejected on every request after login.
+
+```nginx
+server {
+ listen 443 ssl;
+ ssl_verify_client optional_no_ca;
+
+ location /api {
+ proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert $ssl_client_escaped_cert;
+ proxy_pass http://infisical:8080;
+ }
+}
+```
+
+`$ssl_client_escaped_cert` is empty when the client presents no certificate, so the header is cleared rather than passed through. Apply the same `proxy_set_header` in every `location` that proxies to the Infisical API.
### Load balancer configuration examples
diff --git a/docs/documentation/platform/pki/guides/applications/k8s-cert-manager-issuer.mdx b/docs/documentation/platform/pki/guides/applications/k8s-cert-manager-issuer.mdx
index f9a37eee8f..b1bc625229 100644
--- a/docs/documentation/platform/pki/guides/applications/k8s-cert-manager-issuer.mdx
+++ b/docs/documentation/platform/pki/guides/applications/k8s-cert-manager-issuer.mdx
@@ -14,7 +14,7 @@ Issue TLS certificates to your Kubernetes workloads using [cert-manager](https:/
## When to use the Infisical Issuer instead of ACME
-- You want to authenticate with a [machine identity](/documentation/platform/identities/machine-identities) ([Universal Auth](/documentation/platform/identities/universal-auth) or [Kubernetes Auth](/documentation/platform/identities/kubernetes-auth)) rather than ACME/EAB credentials.
+- You want to authenticate with a [machine identity](/documentation/platform/identities/machine-identities) ([Universal Auth](/documentation/platform/identities/universal-auth), [Kubernetes Auth](/documentation/platform/identities/kubernetes-auth) or [TLS Certificate Auth](/documentation/platform/identities/tls-cert-auth)) rather than ACME/EAB credentials.
- You want the **CA chain populated** in the Secret's `ca.crt` automatically (with the ACME issuer this isn't automatic and needs extra setup such as [trust-manager](https://cert-manager.io/docs/trust/trust-manager/)).
- You don't want ACME domain-ownership challenges (HTTP-01/DNS-01).
- You're issuing workload identity certificates (for example `spiffe://` URIs for service meshes).
@@ -42,6 +42,7 @@ Throughout this guide, replace `<namespace>` with the namespace where your workl
- **Universal Auth**: use the identity's **Client ID** and **Client Secret**.
- **Kubernetes Auth**: the controller mints a short-lived token for a Kubernetes service account and presents it to Infisical. Configure it on the identity first, and note its **Identity ID**.
+ - **TLS Certificate Auth**: the controller logs in with a client certificate and presents it on every API call. Configure it on the identity first, and note its **Identity ID**. Enable **Bind Access Tokens to Client Certificate** on the identity to make a leaked token unusable without the certificate's private key.
</Step>
<Step title="Install cert-manager">
@@ -137,6 +138,24 @@ Throughout this guide, replace `<namespace>` with the namespace where your workl
The service account's name and namespace must be allowed by the identity's [Kubernetes Auth](/documentation/platform/identities/kubernetes-auth) configuration in Infisical (and the audience there must match), otherwise issuance fails authentication.
</Tab>
+ <Tab title="TLS Certificate Auth">
+ Store the machine identity's **Identity ID**, and the client certificate and private key in a `kubernetes.io/tls` Secret:
+
+ ```bash
+ kubectl create secret generic infisical-identity \
+ --namespace <namespace> \
+ --from-literal=identityId=<machine_identity_id>
+
+ kubectl create secret tls infisical-client-cert \
+ --namespace <namespace> \
+ --cert=client.crt \
+ --key=client.key
+ ```
+
+ The certificate must be accepted by the identity's [TLS Certificate Auth](/documentation/platform/identities/tls-cert-auth) configuration in Infisical. `tls.crt` can also hold intermediates after the leaf.
+
+ The certificate Secret can be managed by cert-manager itself. When the certificate in the Secret changes, the controller logs in again with the new certificate before its next API call.
+ </Tab>
</Tabs>
</Step>
@@ -198,6 +217,38 @@ Throughout this guide, replace `<namespace>` with the namespace where your workl
namespace: <namespace>
```
</Tab>
+ <Tab title="TLS Certificate Auth">
+ ```yaml issuer-infisical.yaml
+ apiVersion: infisical-issuer.infisical.com/v1alpha1
+ kind: Issuer
+ metadata:
+ name: infisical-issuer
+ namespace: <namespace>
+ spec:
+ url: https://infisical.example.com
+ application: <application_name>
+ profile: <profile_name>
+ authentication:
+ method: tlsCert
+ tlsCert:
+ # Secret holding the machine identity ID
+ identityIdRef:
+ name: infisical-identity
+ namespace: <namespace>
+ key: identityId
+ # Client certificate and private key presented to Infisical
+ clientCertificateRef:
+ name: infisical-client-cert
+ namespace: <namespace>
+ key: tls.crt
+ clientKeyRef:
+ name: infisical-client-cert
+ namespace: <namespace>
+ key: tls.key
+ ```
+
+ On Infisical Cloud, set `url` to port `8443`, for example `https://app.infisical.com:8443`. On a self-hosted instance, the proxy in front of Infisical must forward the client certificate on every API request. See [Security requirements for self-hosted deployments](/documentation/platform/identities/tls-cert-auth#security-requirements-for-self-hosted-deployments).
+ </Tab>
</Tabs>
```bash
@@ -312,10 +363,11 @@ Throughout this guide, replace `<namespace>` with the namespace where your workl
<AccordionGroup>
<Accordion title="Which authentication method should I use?">
- Both authenticate as an Infisical machine identity:
+ All three authenticate as an Infisical machine identity:
- **Universal Auth** is the simplest: store a Client ID and Client Secret in a Secret. Good for any cluster.
- **Kubernetes Auth** avoids storing a long-lived secret: the controller mints a short-lived token for a Kubernetes service account, and Infisical validates it against your cluster. Prefer this when you want to bind issuance to a service account rather than a static secret. It requires configuring [Kubernetes Auth](/documentation/platform/identities/kubernetes-auth) on the identity first.
+ - **TLS Certificate Auth** authenticates with a client certificate. With **Bind Access Tokens to Client Certificate** enabled on the identity, a leaked access token is unusable without the certificate's private key. It requires configuring [TLS Certificate Auth](/documentation/platform/identities/tls-cert-auth) on the identity, and a proxy in front of Infisical that forwards the client certificate on every API request.
</Accordion>
<Accordion title="Why is my certificate duration different from what I requested?">
diff --git a/frontend/src/hooks/api/identities/mutations.tsx b/frontend/src/hooks/api/identities/mutations.tsx
index 6c19715bdd..4a8a8dfb4e 100644
--- a/frontend/src/hooks/api/identities/mutations.tsx
+++ b/frontend/src/hooks/api/identities/mutations.tsx
@@ -803,6 +803,7 @@ export const useAddIdentityTlsCertAuth = () => {
allowedCommonNames,
allowedSubjectAltNames,
verifyClientCertificateChain,
+ bindAccessTokenToCertificate,
caCertificate,
accessTokenTTL,
accessTokenMaxTTL,
@@ -817,6 +818,7 @@ export const useAddIdentityTlsCertAuth = () => {
allowedCommonNames,
allowedSubjectAltNames,
verifyClientCertificateChain,
+ bindAccessTokenToCertificate,
caCertificate,
accessTokenTTL,
accessTokenMaxTTL,
@@ -857,6 +859,7 @@ export const useUpdateIdentityTlsCertAuth = () => {
allowedCommonNames,
allowedSubjectAltNames,
verifyClientCertificateChain,
+ bindAccessTokenToCertificate,
caCertificate,
accessTokenTTL,
accessTokenMaxTTL,
@@ -872,6 +875,7 @@ export const useUpdateIdentityTlsCertAuth = () => {
allowedCommonNames,
allowedSubjectAltNames,
verifyClientCertificateChain,
+ bindAccessTokenToCertificate,
accessTokenTTL,
accessTokenMaxTTL,
accessTokenNumUsesLimit,
diff --git a/frontend/src/hooks/api/identities/types.ts b/frontend/src/hooks/api/identities/types.ts
index e678705002..2a553e68db 100644
--- a/frontend/src/hooks/api/identities/types.ts
+++ b/frontend/src/hooks/api/identities/types.ts
@@ -584,6 +584,7 @@ export type IdentityTlsCertAuth = {
allowedCommonNames: string;
allowedSubjectAltNames: string[] | null;
verifyClientCertificateChain: boolean;
+ bindAccessTokenToCertificate: boolean;
accessTokenTTL: number;
accessTokenMaxTTL: number;
accessTokenNumUsesLimit: number;
@@ -598,6 +599,7 @@ export type AddIdentityTlsCertAuthDTO = {
allowedCommonNames?: string;
allowedSubjectAltNames?: string[];
verifyClientCertificateChain?: boolean;
+ bindAccessTokenToCertificate?: boolean;
accessTokenTTL: number;
accessTokenMaxTTL: number;
accessTokenNumUsesLimit: number;
@@ -614,6 +616,7 @@ export type UpdateIdentityTlsCertAuthDTO = {
allowedCommonNames?: string | null;
allowedSubjectAltNames?: string[] | null;
verifyClientCertificateChain?: boolean;
+ bindAccessTokenToCertificate?: boolean;
accessTokenTTL?: number;
accessTokenMaxTTL?: number;
accessTokenNumUsesLimit?: number;
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTlsCertAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTlsCertAuthForm.tsx
index 83a3833ae7..1496af45f4 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTlsCertAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTlsCertAuthForm.tsx
@@ -49,6 +49,7 @@ const buildSchema = (maxAccessTokenTTL: number) =>
allowedSubjectAltNames: z.string().optional(),
caCertificate: z.string().min(1),
verifyClientCertificateChain: z.boolean().default(false),
+ bindAccessTokenToCertificate: z.boolean().default(false),
accessTokenTTL: accessTokenTtlSchema(maxAccessTokenTTL, "Access Token TTL"),
accessTokenMaxTTL: accessTokenTtlSchema(maxAccessTokenTTL, "Access Token Max TTL"),
accessTokenNumUsesLimit: z.string(),
@@ -106,6 +107,7 @@ export const IdentityTlsCertAuthForm = ({
defaultValues: {
caCertificate: "",
verifyClientCertificateChain: false,
+ bindAccessTokenToCertificate: false,
accessTokenTTL: "2592000",
accessTokenMaxTTL: "2592000",
accessTokenNumUsesLimit: "",
@@ -120,6 +122,7 @@ export const IdentityTlsCertAuthForm = ({
allowedCommonNames: data.allowedCommonNames || undefined,
allowedSubjectAltNames: data.allowedSubjectAltNames?.join("\n") || undefined,
verifyClientCertificateChain: data.verifyClientCertificateChain ?? false,
+ bindAccessTokenToCertificate: data.bindAccessTokenToCertificate ?? false,
accessTokenTTL: String(data.accessTokenTTL),
accessTokenMaxTTL: String(data.accessTokenMaxTTL),
accessTokenNumUsesLimit: data.accessTokenNumUsesLimit
@@ -131,6 +134,7 @@ export const IdentityTlsCertAuthForm = ({
reset({
caCertificate: "",
verifyClientCertificateChain: false,
+ bindAccessTokenToCertificate: false,
accessTokenTTL: "2592000",
accessTokenMaxTTL: "2592000",
accessTokenNumUsesLimit: "",
@@ -148,6 +152,7 @@ export const IdentityTlsCertAuthForm = ({
allowedCommonNames,
allowedSubjectAltNames,
verifyClientCertificateChain,
+ bindAccessTokenToCertificate,
accessTokenTTL,
accessTokenMaxTTL,
accessTokenNumUsesLimit,
@@ -171,6 +176,7 @@ export const IdentityTlsCertAuthForm = ({
? allowedSubjectAltNamesList
: null,
verifyClientCertificateChain,
+ bindAccessTokenToCertificate,
identityId,
accessTokenTTL: Number(accessTokenTTL),
accessTokenMaxTTL: Number(accessTokenMaxTTL),
@@ -187,6 +193,7 @@ export const IdentityTlsCertAuthForm = ({
? allowedSubjectAltNamesList
: undefined,
verifyClientCertificateChain,
+ bindAccessTokenToCertificate,
accessTokenTTL: Number(accessTokenTTL),
accessTokenMaxTTL: Number(accessTokenMaxTTL),
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit || "0"),
@@ -338,6 +345,37 @@ export const IdentityTlsCertAuthForm = ({
</Field>
)}
/>
+ <Controller
+ control={control}
+ name="bindAccessTokenToCertificate"
+ render={({ field }) => (
+ <Field>
+ <div className="flex items-center justify-between gap-3">
+ <FieldLabel
+ htmlFor="bindAccessTokenToCertificate"
+ className="inline-flex items-center gap-1.5"
+ >
+ Bind Access Tokens to Client Certificate
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <InfoIcon className="size-3.5 text-muted" />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-md">
+ Issued access tokens only work when the request presents the same client
+ certificate used to log in (RFC 8705). Your TLS-terminating proxy must
+ forward the client certificate on every API request, not only on login.
+ </TooltipContent>
+ </Tooltip>
+ </FieldLabel>
+ <Toggle
+ id="bindAccessTokenToCertificate"
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
+ </div>
+ </Field>
+ )}
+ />
<TrustedIpsField
control={control}
name="accessTokenTrustedIps"
diff --git a/frontend/src/views/IdentityAuthMethods/content/IdentityTlsCertAuthContent.tsx b/frontend/src/views/IdentityAuthMethods/content/IdentityTlsCertAuthContent.tsx
index f70a603c75..8c0f10aea1 100644
--- a/frontend/src/views/IdentityAuthMethods/content/IdentityTlsCertAuthContent.tsx
+++ b/frontend/src/views/IdentityAuthMethods/content/IdentityTlsCertAuthContent.tsx
@@ -72,6 +72,12 @@ export const IdentityTlsCertAuthContent = ({ identityId }: ViewAuthMethodProps)
<IdentityAuthFieldDisplay className="col-span-2" label="Verify Client Certificate Chain">
{data.verifyClientCertificateChain ? "Enabled" : "Disabled"}
</IdentityAuthFieldDisplay>
+ <IdentityAuthFieldDisplay
+ className="col-span-2"
+ label="Bind Access Tokens to Client Certificate"
+ >
+ {data.bindAccessTokenToCertificate ? "Enabled" : "Disabled"}
+ </IdentityAuthFieldDisplay>
</DetailGroup>
);
};
diff --git a/nginx/default.conf b/nginx/default.conf
index b4d61b570a..ccf35a831b 100644
--- a/nginx/default.conf
+++ b/nginx/default.conf
@@ -8,6 +8,7 @@ server {
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
+ proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert $http_x_amzn_mtls_clientcert;
# WebSocket support
proxy_http_version 1.1;
@@ -38,31 +39,12 @@ server {
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
-
- proxy_pass http://backend:4000;
- proxy_redirect off;
-
- # proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";
- proxy_cookie_path / "/; HttpOnly; SameSite=strict";
- }
-
- # Identity TLS-cert auth: the client certificate is provided by the TLS-terminating upstream.
- # Regex (matched before the /api block below) covers the optional trailing slash, since the
- # backend treats /login and /login/ as the same route.
- location ~ ^/api/v1/auth/tls-cert-auth/login/?$ {
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
- proxy_set_header Host $http_host;
- proxy_set_header X-NginX-Proxy true;
-
- # Cloud terminates mTLS at the upstream LB; for self-hosted nginx mTLS termination use
- # $ssl_client_escaped_cert instead.
proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert $http_x_amzn_mtls_clientcert;
proxy_pass http://backend:4000;
proxy_redirect off;
+ # proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";
proxy_cookie_path / "/; HttpOnly; SameSite=strict";
}
@@ -72,9 +54,7 @@ server {
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
-
- # This header is populated only by the dedicated TLS-cert-auth location above.
- proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert "";
+ proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert $http_x_amzn_mtls_clientcert;
proxy_pass http://backend:4000;
proxy_redirect off;
@@ -91,6 +71,7 @@ server {
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
+ proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert $http_x_amzn_mtls_clientcert;
proxy_pass http://backend:4000;
proxy_redirect off;
diff --git a/nginx/default.dev.conf b/nginx/default.dev.conf
index c9cdc51ae1..1d0ef55b48 100644
--- a/nginx/default.dev.conf
+++ b/nginx/default.dev.conf
@@ -15,6 +15,7 @@ server {
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
+ proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert $ssl_client_escaped_cert;
# WebSocket support
proxy_http_version 1.1;
@@ -45,23 +46,6 @@ server {
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
-
- proxy_pass http://api;
- proxy_redirect off;
-
- proxy_cookie_path / "/; SameSite=strict";
- }
-
- # Identity TLS-cert auth: the client certificate is provided by the TLS-terminating proxy.
- # Regex (matched before the /api block below) covers the optional trailing slash, since the
- # backend treats /login and /login/ as the same route.
- location ~ ^/api/v1/auth/tls-cert-auth/login/?$ {
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
- proxy_set_header Host $http_host;
- proxy_set_header X-NginX-Proxy true;
-
proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert $ssl_client_escaped_cert;
proxy_pass http://api;
@@ -76,9 +60,7 @@ server {
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
-
- # This header is populated only by the dedicated TLS-cert-auth location above.
- proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert "";
+ proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert $ssl_client_escaped_cert;
proxy_pass http://api;
proxy_redirect off;
@@ -107,6 +89,7 @@ server {
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
+ proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert $ssl_client_escaped_cert;
proxy_pass http://api;
proxy_redirect off;