Skip to content

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

fix(gateway): address review on the Kubernetes auth method

bernie-gffe9910a2dfe
diff --git a/backend/src/ee/routes/v3/gateway-router.ts b/backend/src/ee/routes/v3/gateway-router.ts
index e69642d281..8f1a8e1849 100644
--- a/backend/src/ee/routes/v3/gateway-router.ts
+++ b/backend/src/ee/routes/v3/gateway-router.ts
@@ -5,7 +5,8 @@ import { EventType, UserAgentType } from "@app/ee/services/audit-log/audit-log-t
import { validateAccountIds, validatePrincipalArns } from "@app/ee/services/resource-auth-method/aws-auth-validators";
import {
validateAllowedNames,
- validateAllowedNamespaces
+ validateAllowedNamespaces,
+ validateKubernetesHost
} from "@app/ee/services/resource-auth-method/kubernetes-auth-validators";
import { ResourceAuthMethodType } from "@app/ee/services/resource-auth-method/resource-auth-method-fns";
import { AuthMethodViewSchema } from "@app/ee/services/resource-auth-method/resource-auth-method-schemas";
@@ -60,21 +61,7 @@ const AwsAuthMethodInputSchema = z
const KubernetesAuthMethodInputSchema = z
.object({
method: z.literal(ResourceAuthMethodType.Kubernetes),
- kubernetesHost: z
- .string()
- .trim()
- .min(1)
- .max(255)
- .describe(GATEWAYS.AUTH_METHOD.kubernetesHost)
- .refine((host) => !host.startsWith("http://"), "Kubernetes host must use https")
- .refine(
- (host) =>
- z
- .string()
- .url()
- .safeParse(host.startsWith("https://") ? host : `https://${host}`).success,
- "Kubernetes host must be a valid URL"
- ),
+ kubernetesHost: validateKubernetesHost.describe(GATEWAYS.AUTH_METHOD.kubernetesHost),
caCertificate: z.string().trim().max(10240).optional().describe(GATEWAYS.AUTH_METHOD.caCertificate),
tokenReviewerJwt: z.string().trim().max(8192).optional().describe(GATEWAYS.AUTH_METHOD.tokenReviewerJwt),
allowedNamespaces: validateAllowedNamespaces.describe(GATEWAYS.AUTH_METHOD.allowedNamespaces),
@@ -522,7 +509,7 @@ export const registerGatewayV3Router = async (server: FastifyZodProvider) => {
metadata: {
resourceType: "gateway",
resourceId: result.resourceId,
- method: "kubernetes",
+ method: ResourceAuthMethodType.Kubernetes,
methodConfigId: result.configId,
kubernetesNamespace: result.namespace,
kubernetesServiceAccountName: result.serviceAccountName
@@ -543,7 +530,7 @@ export const registerGatewayV3Router = async (server: FastifyZodProvider) => {
resourceType: "gateway",
resourceId: result.resourceId,
orgId: result.orgId,
- method: "kubernetes"
+ method: ResourceAuthMethodType.Kubernetes
}
})
.catch((err) => {
@@ -566,7 +553,7 @@ export const registerGatewayV3Router = async (server: FastifyZodProvider) => {
metadata: {
resourceType: "gateway",
resourceId: error.detail.resourceId as string,
- method: "kubernetes",
+ method: ResourceAuthMethodType.Kubernetes,
reasonCode: error.detail.reasonCode as string,
message: error.message,
kubernetesNamespace: error.detail.namespace as string | undefined,
diff --git a/backend/src/ee/services/resource-auth-method/kubernetes-auth-fns.ts b/backend/src/ee/services/resource-auth-method/kubernetes-auth-fns.ts
index c0258d4bf9..a0353691cd 100644
--- a/backend/src/ee/services/resource-auth-method/kubernetes-auth-fns.ts
+++ b/backend/src/ee/services/resource-auth-method/kubernetes-auth-fns.ts
@@ -15,7 +15,13 @@ import {
import { extractK8sUsername } from "@app/services/identity-kubernetes-auth/identity-kubernetes-auth-fns";
import { TCreateTokenReviewResponse } from "@app/services/identity-kubernetes-auth/identity-kubernetes-auth-types";
+import { ResourceAuthLoginFailureReason } from "./resource-auth-method-fns";
+
const TOKEN_REVIEW_TIMEOUT_MS = 10_000;
+const TOKEN_REVIEW_API_VERSION = "authentication.k8s.io/v1";
+const TOKEN_REVIEW_KIND = "TokenReview";
+const TOKEN_REVIEW_PATH = "/apis/authentication.k8s.io/v1/tokenreviews";
+const TOKEN_REVIEW_PROBE_TOKEN = "test-token-for-permission-validation";
// A TokenReview response is a few KB; the largest part is the echoed token, itself capped at 8KB
// by the route schema. Bounded so an operator-supplied host cannot make us buffer an arbitrary body.
const TOKEN_REVIEW_MAX_RESPONSE_BYTES = 64 * 1024;
@@ -88,6 +94,13 @@ export const validateKubernetesConfigReachable = async ({
} catch (err) {
throw classify(err, KubernetesAuthErrorContext.KubernetesHost);
}
+ // 401/403 are fine: /version can require authentication. A 404 means the address does not serve
+ // the Kubernetes API at all, which is the common typo and used to save happily.
+ if (versionStatus === 404) {
+ throw new BadRequestError({
+ message: `${host} does not look like a Kubernetes API server: /version returned 404. Verify the host and port.`
+ });
+ }
if (versionStatus >= 500) {
throw new BadRequestError({
message: `Kubernetes API server at ${host} returned ${versionStatus}. Verify the host is correct and healthy.`
@@ -99,11 +112,11 @@ export const validateKubernetesConfigReachable = async ({
let review: { status: number; data: unknown };
try {
review = await safeRequest.post(
- `${host}/apis/authentication.k8s.io/v1/tokenreviews`,
+ `${host}${TOKEN_REVIEW_PATH}`,
{
- apiVersion: "authentication.k8s.io/v1",
- kind: "TokenReview",
- spec: { token: "test-token-for-permission-validation" }
+ apiVersion: TOKEN_REVIEW_API_VERSION,
+ kind: TOKEN_REVIEW_KIND,
+ spec: { token: TOKEN_REVIEW_PROBE_TOKEN }
},
{
...requestConfig(),
@@ -158,10 +171,10 @@ export const reviewServiceAccountToken = async ({
let review: TCreateTokenReviewResponse;
try {
const res = await safeRequest.post<TCreateTokenReviewResponse>(
- `${baseUrl}/apis/authentication.k8s.io/v1/tokenreviews`,
+ `${baseUrl}${TOKEN_REVIEW_PATH}`,
{
- apiVersion: "authentication.k8s.io/v1",
- kind: "TokenReview",
+ apiVersion: TOKEN_REVIEW_API_VERSION,
+ kind: TOKEN_REVIEW_KIND,
spec: {
token: jwt,
...(allowedAudience ? { audiences: [allowedAudience] } : {})
@@ -197,7 +210,10 @@ export const reviewServiceAccountToken = async ({
// Borrow the identity Kubernetes auth wording, but keep our own error type and reason code
// so the audit log still records why the login failed.
- const reasonCode = status === 401 || status === 403 ? "token_review_forbidden" : "token_review_request_failed";
+ const reasonCode =
+ status === 401 || status === 403
+ ? ResourceAuthLoginFailureReason.TokenReviewForbidden
+ : ResourceAuthLoginFailureReason.TokenReviewRequestFailed;
const message = isAxiosError
? handleAxiosError(err, { kubernetesHost }, KubernetesAuthErrorContext.KubernetesApiServer).message
: `Could not reach the Kubernetes API server at ${kubernetesHost} to review the service account token.`;
@@ -208,14 +224,14 @@ export const reviewServiceAccountToken = async ({
if (!review?.status) {
throw new UnauthorizedError({
message: "The Kubernetes API server returned an unexpected token review response.",
- detail: { reasonCode: "token_review_malformed_response", ...errorContext }
+ detail: { reasonCode: ResourceAuthLoginFailureReason.TokenReviewMalformedResponse, ...errorContext }
});
}
if ("error" in review.status) {
throw new UnauthorizedError({
message: `Kubernetes token review failed: ${review.status.error}`,
- detail: { reasonCode: "token_review_error", ...errorContext }
+ detail: { reasonCode: ResourceAuthLoginFailureReason.TokenReviewError, ...errorContext }
});
}
@@ -233,7 +249,7 @@ export const reviewServiceAccountToken = async ({
} catch {
throw new UnauthorizedError({
message: `Access denied: '${username}' is not a Kubernetes service account. The gateway must authenticate with a service account token.`,
- detail: { reasonCode: "not_a_service_account", ...errorContext }
+ detail: { reasonCode: ResourceAuthLoginFailureReason.NotAServiceAccount, ...errorContext }
});
}
@@ -275,28 +291,43 @@ export const validateKubernetesAllowlists = ({
if (!allowedNamespaces.trim() && !allowedNames.trim()) {
throw new UnauthorizedError({
message: "Access denied: Kubernetes auth method has no allowlist configured.",
- detail: { reasonCode: "no_allowlist_configured", ...errorContext }
+ detail: { reasonCode: ResourceAuthLoginFailureReason.NoAllowlistConfigured, ...errorContext }
});
}
if (allowedNamespaces.trim() && !matchesAnyPattern(namespace, allowedNamespaces)) {
throw new UnauthorizedError({
message: `Access denied: Kubernetes namespace '${namespace}' is not allowed.`,
- detail: { reasonCode: "namespace_not_allowed", namespace, serviceAccountName, ...errorContext }
+ detail: {
+ reasonCode: ResourceAuthLoginFailureReason.NamespaceNotAllowed,
+ namespace,
+ serviceAccountName,
+ ...errorContext
+ }
});
}
if (allowedNames.trim() && !matchesAnyPattern(serviceAccountName, allowedNames)) {
throw new UnauthorizedError({
message: `Access denied: Kubernetes service account '${serviceAccountName}' is not allowed.`,
- detail: { reasonCode: "name_not_allowed", namespace, serviceAccountName, ...errorContext }
+ detail: {
+ reasonCode: ResourceAuthLoginFailureReason.NameNotAllowed,
+ namespace,
+ serviceAccountName,
+ ...errorContext
+ }
});
}
if (allowedAudience.trim() && !audiences.includes(allowedAudience)) {
throw new UnauthorizedError({
message: `Access denied: the service account token does not carry the required audience '${allowedAudience}'.`,
- detail: { reasonCode: "audience_not_allowed", namespace, serviceAccountName, ...errorContext }
+ detail: {
+ reasonCode: ResourceAuthLoginFailureReason.AudienceNotAllowed,
+ namespace,
+ serviceAccountName,
+ ...errorContext
+ }
});
}
};
diff --git a/backend/src/ee/services/resource-auth-method/kubernetes-auth-validators.ts b/backend/src/ee/services/resource-auth-method/kubernetes-auth-validators.ts
index a1970a7174..d6fa60f4e1 100644
--- a/backend/src/ee/services/resource-auth-method/kubernetes-auth-validators.ts
+++ b/backend/src/ee/services/resource-auth-method/kubernetes-auth-validators.ts
@@ -35,3 +35,47 @@ export const validateAllowedNames = csvOf(
1024,
"lowercase Kubernetes service account names"
);
+
+// Normalises the host to a canonical `https://host[:port]` and rejects anything that is not a bare
+// API server address. The scheme is matched case-insensitively: "HTTPS://x" used to be accepted and
+// then mangled into "https://HTTPS://x", and "HTTP://x" slipped past an https-only check.
+export const validateKubernetesHost = z
+ .string()
+ .trim()
+ .min(1)
+ .max(255)
+ .transform((raw, ctx) => {
+ const reject = (message: string) => {
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message });
+ return z.NEVER;
+ };
+
+ const lowered = raw.toLowerCase();
+ // Any scheme other than https is reported as such, rather than falling through and being
+ // reported as a path problem once https:// is prepended to it.
+ if (lowered.includes("://") && !lowered.startsWith("https://")) {
+ return reject("Kubernetes host must use https");
+ }
+ const hasScheme = lowered.startsWith("https://");
+
+ let url: URL;
+ try {
+ url = new URL(hasScheme ? raw : `https://${raw}`);
+ } catch {
+ return reject("Kubernetes host must be a valid URL, for example https://my-cluster.example.com:6443");
+ }
+
+ if (url.protocol.toLowerCase() !== "https:") {
+ return reject("Kubernetes host must use https");
+ }
+ if (url.username || url.password) {
+ return reject("Kubernetes host must not include credentials");
+ }
+ if (url.pathname !== "/" || url.search || url.hash) {
+ return reject(
+ "Kubernetes host must be the API server address only, with no path, for example https://my-cluster.example.com:6443"
+ );
+ }
+
+ return `https://${url.host}`;
+ });
diff --git a/backend/src/ee/services/resource-auth-method/resource-auth-method-fns.ts b/backend/src/ee/services/resource-auth-method/resource-auth-method-fns.ts
index b2f727be8f..48da3778b2 100644
--- a/backend/src/ee/services/resource-auth-method/resource-auth-method-fns.ts
+++ b/backend/src/ee/services/resource-auth-method/resource-auth-method-fns.ts
@@ -122,6 +122,22 @@ export const assertKmipServerResource = (resource: { type: string }, methodName:
// operations. The "settable" subset is enforced by the discriminated
// TSetAuthMethodInput type (which only accepts aws/kubernetes/token), not by this
// enum-like const.
+// Reason codes attached to a failed login and recorded on the audit log. Produced here and read
+// back in the gateway router, so they need a single definition.
+export const ResourceAuthLoginFailureReason = {
+ MethodMismatch: "method_mismatch",
+ ConfigMissing: "config_missing",
+ TokenReviewForbidden: "token_review_forbidden",
+ TokenReviewRequestFailed: "token_review_request_failed",
+ TokenReviewMalformedResponse: "token_review_malformed_response",
+ TokenReviewError: "token_review_error",
+ NotAServiceAccount: "not_a_service_account",
+ NoAllowlistConfigured: "no_allowlist_configured",
+ NamespaceNotAllowed: "namespace_not_allowed",
+ NameNotAllowed: "name_not_allowed",
+ AudienceNotAllowed: "audience_not_allowed"
+} as const;
+
export const ResourceAuthMethodType = {
Aws: "aws",
Kubernetes: "kubernetes",
diff --git a/backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts b/backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts
index 72f79a4a6a..4d5129f0c2 100644
--- a/backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts
+++ b/backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts
@@ -38,6 +38,7 @@ import {
RESOURCE_TYPE_GATEWAY,
RESOURCE_TYPE_KMIP,
RESOURCE_TYPE_RELAY,
+ ResourceAuthLoginFailureReason,
ResourceAuthMethodType,
type ResourceRef
} from "./resource-auth-method-fns";
@@ -690,7 +691,11 @@ export const resourceAuthMethodServiceFactory = ({
if (!registry || registry.method !== ResourceAuthMethodType.Aws) {
throw new UnauthorizedError({
message: `${resourceLabel} is not configured for AWS authentication`,
- detail: { reasonCode: "method_mismatch", resourceId: resource.id, orgId: resourceOrgId }
+ detail: {
+ reasonCode: ResourceAuthLoginFailureReason.MethodMismatch,
+ resourceId: resource.id,
+ orgId: resourceOrgId
+ }
});
}
@@ -698,7 +703,11 @@ export const resourceAuthMethodServiceFactory = ({
if (!config) {
throw new UnauthorizedError({
message: `${resourceLabel} is not configured for AWS authentication`,
- detail: { reasonCode: "config_missing", resourceId: resource.id, orgId: resourceOrgId }
+ detail: {
+ reasonCode: ResourceAuthLoginFailureReason.ConfigMissing,
+ resourceId: resource.id,
+ orgId: resourceOrgId
+ }
});
}
@@ -748,7 +757,11 @@ export const resourceAuthMethodServiceFactory = ({
if (!registry || registry.method !== ResourceAuthMethodType.Kubernetes) {
throw new UnauthorizedError({
message: `${resourceLabel} is not configured for Kubernetes authentication`,
- detail: { reasonCode: "method_mismatch", resourceId: resource.id, orgId: resourceOrgId }
+ detail: {
+ reasonCode: ResourceAuthLoginFailureReason.MethodMismatch,
+ resourceId: resource.id,
+ orgId: resourceOrgId
+ }
});
}
@@ -756,7 +769,11 @@ export const resourceAuthMethodServiceFactory = ({
if (!config) {
throw new UnauthorizedError({
message: `${resourceLabel} is not configured for Kubernetes authentication`,
- detail: { reasonCode: "config_missing", resourceId: resource.id, orgId: resourceOrgId }
+ detail: {
+ reasonCode: ResourceAuthLoginFailureReason.ConfigMissing,
+ resourceId: resource.id,
+ orgId: resourceOrgId
+ }
});
}
diff --git a/docs/self-hosting/helm-charts/gateway.mdx b/docs/self-hosting/helm-charts/gateway.mdx
index 67acc078ae..3e72a88821 100644
--- a/docs/self-hosting/helm-charts/gateway.mdx
+++ b/docs/self-hosting/helm-charts/gateway.mdx
@@ -100,6 +100,7 @@ helm uninstall infisical-gateway --namespace infisical-gateway
| `gateway.enrollment.aws.gatewayId` | `""` | Gateway ID from the Infisical UI. Required for AWS auth. |
| `gateway.enrollment.kubernetes.gatewayId` | `""` | Gateway ID from the Infisical UI. Required for Kubernetes auth. |
| `gateway.enrollment.kubernetes.serviceAccountTokenPath` | `""` | Override the projected service account token path. Defaults to `/var/run/secrets/kubernetes.io/serviceaccount/token`. |
+| `gateway.enrollment.kubernetes.externalTokenReview` | `false` | Set true when TokenReview permission comes from outside this chart, either a token reviewer JWT configured in Infisical or a binding you manage. Required to install with `serviceAccount.createAsAuthDelegator` disabled. |
| `gateway.enrollment.credentialsSecretRef` | `""` | Kubernetes secret with credentials injected as env vars. |
| `gateway.relayName` | `""` | Specific relay to connect to. Empty for automatic selection. |
| `persistence.enabled` | `true` | Enable persistent storage. Required for token auth, optional for AWS and Kubernetes auth. |
@@ -166,6 +167,10 @@ gateway:
gatewayId: ""
# Path to the projected service account token. Only override for a non-default mount.
serviceAccountTokenPath: ""
+ # Set true only if TokenReview permission comes from somewhere other than this chart: a token
+ # reviewer JWT configured on the gateway in Infisical, or a binding you manage yourself.
+ # Required to install with serviceAccount.createAsAuthDelegator disabled.
+ externalTokenReview: false
# Name of a K8s Secret whose key-value pairs are injected as env vars.
# Use this to provide credentials for the enrollment method (e.g. AWS keys, GCP credentials).
diff --git a/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx b/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx
index ded6ec7b7e..a95a203cd5 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx
@@ -39,7 +39,10 @@ const schema = z
allowedNamespaces: z.string(),
allowedNames: z.string(),
allowedAudience: z.string(),
- verifyTlsCertificate: z.boolean()
+ verifyTlsCertificate: z.boolean(),
+ // The reviewer token is never returned, so a blank field cannot mean "delete". This is the
+ // only way to remove one, and clearing it is required to change the host.
+ removeTokenReviewerJwt: z.boolean()
})
.superRefine((data, ctx) => {
if (
@@ -104,8 +107,13 @@ export const toNetworkingAuthMethodInput = (form: FormData) => {
method: "kubernetes" as const,
kubernetesHost: form.kubernetesHost,
caCertificate: form.caCertificate,
- // Write-only, so a blank field means "leave the stored value alone".
- tokenReviewerJwt: form.tokenReviewerJwt.trim() ? form.tokenReviewerJwt : undefined,
+ // Write-only: blank means "leave the stored value alone", empty string means "remove it".
+ // eslint-disable-next-line no-nested-ternary
+ tokenReviewerJwt: form.removeTokenReviewerJwt
+ ? ""
+ : form.tokenReviewerJwt.trim()
+ ? form.tokenReviewerJwt
+ : undefined,
allowedNamespaces: form.allowedNamespaces,
allowedNames: form.allowedNames,
allowedAudience: form.allowedAudience,
@@ -177,7 +185,8 @@ export const NetworkingAuthMethodForm = ({
allowedNamespaces: initialKubernetes?.allowedNamespaces ?? "",
allowedNames: initialKubernetes?.allowedNames ?? "",
allowedAudience: initialKubernetes?.allowedAudience ?? "",
- verifyTlsCertificate: initialKubernetes?.verifyTlsCertificate ?? true
+ verifyTlsCertificate: initialKubernetes?.verifyTlsCertificate ?? true,
+ removeTokenReviewerJwt: false
};
const {
@@ -555,6 +564,41 @@ export const NetworkingAuthMethodForm = ({
</Field>
)}
/>
+ {initialKubernetes?.hasTokenReviewerJwt && (
+ <Controller
+ control={control}
+ name="removeTokenReviewerJwt"
+ render={({ field }) => (
+ <Field>
+ <div className="flex items-center gap-2">
+ <Switch
+ id="gateway-k8s-remove-reviewer"
+ variant="org"
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ disabled={isDisabled || isSaving}
+ />
+ <FieldLabel
+ htmlFor="gateway-k8s-remove-reviewer"
+ className="mb-0 inline-flex items-center gap-1.5"
+ >
+ Remove the stored token reviewer JWT
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <HelpCircleIcon className="size-3.5 text-muted" />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-md">
+ The stored token is never shown, so this is the only way to remove it. It
+ is also required to change the Kubernetes host, since a stored reviewer
+ token is never sent to a different host.
+ </TooltipContent>
+ </Tooltip>
+ </FieldLabel>
+ </div>
+ </Field>
+ )}
+ />
+ )}
<Controller
control={control}
name="verifyTlsCertificate"
@@ -584,10 +628,9 @@ export const NetworkingAuthMethodForm = ({
certificate against the CA certificate provided above.
</p>
<p>
- This only takes effect while a CA certificate is configured. Without one
- there is nothing to verify against, so the API server&apos;s identity is
- not checked even when this is enabled. The connection is still over
- HTTPS.
+ With a CA certificate above, the server is verified against it. Without
+ one the system trust store is used, which a cluster CA will not be in,
+ so verification fails. Turn this off only for testing.
</p>
</div>
</TooltipContent>
diff --git a/helm-charts/infisical-gateway/CHANGELOG.md b/helm-charts/infisical-gateway/CHANGELOG.md
index a6142e65e7..070827b153 100644
--- a/helm-charts/infisical-gateway/CHANGELOG.md
+++ b/helm-charts/infisical-gateway/CHANGELOG.md
@@ -2,6 +2,7 @@
* Added Kubernetes auth enrollment (`gateway.enrollment.method: kubernetes`). The gateway authenticates with the projected service account token of its own pod, so no enrollment token or cloud credential needs to be distributed to the cluster.
* Added `gateway.enrollment.kubernetes.gatewayId` and `gateway.enrollment.kubernetes.serviceAccountTokenPath`.
* Bumped the default CLI image from `0.43.84` to `0.43.118`, the first release containing `--enroll-method=kubernetes`.
+* Added `gateway.enrollment.kubernetes.externalTokenReview`. Installing with `serviceAccount.createAsAuthDelegator` disabled now fails unless this is set, since the gateway would otherwise start but never be able to have its token reviewed.
## 1.2.0 (July 17, 2026)
* Added `extraEnv` for injecting additional environment variables into the gateway container.
diff --git a/helm-charts/infisical-gateway/templates/deployment.yaml b/helm-charts/infisical-gateway/templates/deployment.yaml
index ed99fc3822..b6628d3429 100644
--- a/helm-charts/infisical-gateway/templates/deployment.yaml
+++ b/helm-charts/infisical-gateway/templates/deployment.yaml
@@ -4,6 +4,11 @@
{{- if not .Values.serviceAccount.automount }}
{{- fail "serviceAccount.automount must be true when gateway.enrollment.method is 'kubernetes'. The gateway authenticates with the projected service account token of its own pod." }}
{{- end }}
+ {{- if not .Values.gateway.enrollment.kubernetes.externalTokenReview }}
+ {{- if not (and .Values.serviceAccount.create .Values.serviceAccount.createAsAuthDelegator) }}
+ {{- fail "The gateway's service account needs the system:auth-delegator ClusterRole to have its own token reviewed. Keep serviceAccount.create and serviceAccount.createAsAuthDelegator enabled, or set gateway.enrollment.kubernetes.externalTokenReview=true if a token reviewer JWT is configured in Infisical or you manage the binding yourself." }}
+ {{- end }}
+ {{- end }}
{{- end }}
{{- if eq .Values.gateway.enrollment.method "token" }}
{{- if not .Values.persistence.enabled }}
diff --git a/helm-charts/infisical-gateway/values.yaml b/helm-charts/infisical-gateway/values.yaml
index e29ba226cf..9d2c13d65d 100644
--- a/helm-charts/infisical-gateway/values.yaml
+++ b/helm-charts/infisical-gateway/values.yaml
@@ -40,6 +40,10 @@ gateway:
gatewayId: ""
# Path to the projected service account token. Only override for a non-default mount.
serviceAccountTokenPath: ""
+ # Set true only if TokenReview permission comes from somewhere other than this chart: a token
+ # reviewer JWT configured on the gateway in Infisical, or a binding you manage yourself.
+ # Required to install with serviceAccount.createAsAuthDelegator disabled.
+ externalTokenReview: false
# Name of a K8s Secret whose key-value pairs are injected as env vars.
# Use this to provide credentials for the enrollment method (e.g. AWS keys, GCP credentials).