fix(auth0-express-api): forward missing-ApiClient error via next() - #44
Open
frederikprijck wants to merge 1 commit into
Open
fix(auth0-express-api): forward missing-ApiClient error via next()#44frederikprijck wants to merge 1 commit into
frederikprijck wants to merge 1 commit into
Conversation
requiresAuth threw synchronously when req.auth0.client was absent. In an async Express 4 middleware that surfaces as an unhandled promise rejection rather than reaching the app's error middleware. Return next(err) instead so the error is handled the same way on Express 4 and 5. SECURITY: SDK-9 — fail-safe hardening (CWE-248).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
requiresAuththrew synchronously whenreq.auth0.clientwas absent (router not registered). In an async Express 4 middleware that surfaces as an unhandled promise rejection instead of reaching the app's error middleware. On Express 5 thrown errors in async middleware are caught, but Express 4 does not do this — so behaviour differed by version.This returns
next(err)instead, so the missing-ApiClient case reaches the app's error middleware consistently on both Express 4 and 5, with no response written by the middleware itself.Changes
require-auth.ts:throw new Error(...)→return next(new Error(...))require-auth.spec.ts: the existing "should throw" test now asserts thenext(err)contract and that no response is written.Context
Split out of #27 (
fix/sdk-9-fail-safe-nits). This half is independent of the SDK-4 backchannel work, so it targetsmaindirectly; #27 now carries only the backchannel-logout fail-safe fix.SECURITY: SDK-9 — fail-safe hardening (CWE-248).