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
merge: resolve conflict with main in inject-identity.ts
bernie-g223da2bf9ea2
diff --cc .claude/worktrees/pam-ai-session-insights-v3index 0000000000,0000000000..2faf238120new file mode 160000--- /dev/null+++ b/.claude/worktrees/pam-ai-session-insights-v3@@@ -1,0 -1,0 +1,1 @@@++Subproject commit 2faf23812015e52a74d92c243b6758ac54e72e83diff --cc backend/src/server/plugins/auth/inject-identity.tsindex 41207aa932,5449dd700a..5ca55da997--- a/backend/src/server/plugins/auth/inject-identity.ts+++ b/backend/src/server/plugins/auth/inject-identity.ts@@@ -7,15 -7,9 +7,16 @@@ import { TServiceTokens, TUsers } fromimport { TScimTokenJwtPayload } from "@app/ee/services/scim/scim-types";import { getConfig } from "@app/lib/config/env";import { crypto } from "@app/lib/crypto";-import { BadRequestError } from "@app/lib/errors";+import { BadRequestError, UnauthorizedError } from "@app/lib/errors";+ import { RequestContextKey } from "@app/lib/request-context/request-context-keys";-import { ActorType, AuthMethod, AuthMode, AuthModeJwtTokenPayload, AuthTokenType } from "@app/services/auth/auth-type";+import {+ ActorType,+ AuthMethod,+ AuthMode,+ AuthModeJwtTokenPayload,+ AuthTokenType,+ TGatewayAccessTokenJwtPayload+} from "@app/services/auth/auth-type";import { TIdentityAccessTokenJwtPayload } from "@app/services/identity-access-token/identity-access-token-types";import { getServerCfg } from "@app/services/super-admin/super-admin-service";@@@ -335,30 -308,6 +336,30 @@@ export const injectIdentity = fp};break;}+ case AuthMode.GATEWAY_ACCESS_TOKEN: {+ const gateway = await server.services.gatewayV2.getGatewayById({ gatewayId: token.gatewayId });++ // Reject JWTs whose tokenVersion doesn't match the gateway's current version.+ // Tokens issued before the tokenVersion field existed lack the claim, so treat undefined as version 1.+ const jwtVersion = token.tokenVersion ?? 1;+ if (gateway.tokenVersion !== undefined && gateway.tokenVersion !== jwtVersion) {+ throw new UnauthorizedError({ message: "Gateway token has been revoked" });+ }+- requestContext.set("orgId", token.orgId);++ requestContext.set(RequestContextKey.OrgId, token.orgId);++ req.auth = {+ authMode: AuthMode.GATEWAY_ACCESS_TOKEN,+ actor,+ gatewayId: token.gatewayId,+ orgId: token.orgId,+ rootOrgId: token.orgId,+ parentOrgId: token.orgId,+ authMethod: null,+ token+ };+ break;+ }default:throw new BadRequestError({ message: "Invalid token strategy provided" });}