Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(gateway): do not 500 when the token review is rejected
bernie-g0cf04400356d
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.tsindex b6087a5cd2..8b1a3fb593 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@@ -272,9 +272,14 @@ export const reviewServiceAccountToken = async ({throw new UnauthorizedError({ message, detail: { reasonCode, ...errorContext } });}- if (!review?.status) {+ // A rejected review comes back as a Status object, where `status` is the string "Failure" rather+ // than the TokenReview result. Anything that is not an object fails the same way, and treating it+ // as one turns a denied login into a 500.+ if (!review?.status || typeof review.status !== "object") {+ const reason =+ (review as unknown as { message?: string })?.message ?? "the response did not contain a review result";throw new UnauthorizedError({- message: "The Kubernetes API server returned an unexpected token review response.",+ message: `The Kubernetes API server did not return a token review: ${reason}`,detail: { reasonCode: ResourceAuthLoginFailureReason.TokenReviewMalformedResponse, ...errorContext }});}