fix(auth): fall back to the verified access token for the tenant claim
CI (SIAX Cloud) / integration (push) Skipped
CI (SIAX Cloud) / sonar (push) Skipped
masterplan-lock / check (push) Successful in 4s
masterplan-lock / check (pull_request) Successful in 4s
Security Scan (SIAX Cloud) / security (push) Successful in 14s
CI (SIAX Cloud) / security (push) Successful in 15s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 19s
CI (SIAX Cloud) / quality (push) Successful in 1m8s
CI (SIAX Cloud) / sonar (pull_request) Skipped
CI (SIAX Cloud) / security (pull_request) Successful in 14s
CI (SIAX Cloud) / integration (pull_request) Successful in 27s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m3s

Zitadel does not always copy urn:zitadel:iam:org:id into the id_token; the
access token always carries it. Verify that token (issuer) before trusting its
tenant.
This commit is contained in:
2026-11-02 15:48:51 +01:00
parent 023406c9b6
commit 71391db132
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -50,8 +50,8 @@ export async function GET(request: NextRequest) {
}
try {
const { idToken } = await exchangeCode(config, code, stored.verifier);
const verified = await verifyIdToken(config, idToken, stored.nonce);
const { idToken, accessToken } = await exchangeCode(config, code, stored.verifier);
const verified = await verifyIdToken(config, idToken, stored.nonce, accessToken);
const session = await signSession({
sub: verified.sub,
tenantId: verified.tenantId,
+1
View File
@@ -128,6 +128,7 @@ export async function verifyIdToken(
config: OidcConfig,
idToken: string,
expectedNonce: string,
accessToken?: string,
): Promise<VerifiedIdToken> {
const { payload } = await jwtVerify(idToken, keySet(config.issuer), {
issuer: config.issuer,