Repository navigation
Conversation
…` to `true` Both options are documented as defaulting to `true`, but only `OAuth2Server#authenticate()` applied that default. The AuthenticateHandler itself threw `InvalidArgumentError: Missing parameter` when `scope` was set without them. As a result, `OAuth2Server#authorize()` threw synchronously for any server configured with a `scope` option (which the constructor docs say is used as the default for the other methods) and no custom `authenticateHandler`, because the default AuthenticateHandler it creates received the server's `scope` but not the header options. The AuthenticateHandler now applies the documented default, so `authorize()` works and sets both scopes headers, and explicit `false` values are still respected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
addAcceptedScopesHeaderandaddAuthorizedScopesHeaderare documented as defaulting totrue, both onOAuth2Serverand onAuthenticateHandler. OnlyOAuth2Server#authenticate()actually applied that default.AuthenticateHandleritself threwInvalidArgumentError: Missing parameter: addAcceptedScopesHeaderwheneverscopewas set without them.That breaks
OAuth2Server#authorize()for any server configured with ascopeoption and no customauthenticateHandler. The constructor docs say server options are used as defaults for every method, soscopereaches the defaultAuthenticateHandlerthatAuthorizeHandlercreates, but the header defaults don't.authorize()then throws synchronously, without even returning a rejected promise:This PR applies the documented default (
truewhenundefined) in theAuthenticateHandlerconstructor. That one change fixesauthorize(), makes directAuthenticateHandleruse match its JSDoc, and keeps explicitfalse(or other) values as passed. The docs already describe this behaviour, so no doc changes are needed.OAuth2Server#authenticate()keeps its own explicit defaults, which are now redundant but harmless.Linked issue(s)
None. Found while reviewing other open PRs.
Involved parts of the project
lib/handlers/authenticate-handler.js: constructor option defaultsOAuth2Server#authorize()→AuthorizeHandler→ defaultAuthenticateHandler)Added tests?
Yes. Each of these fails on
masterwithMissing parameter: …and passes here:Server integration › authorize() › should set the scopes headers by default if scope is set on the serverresolves with the code and setsX-Accepted-OAuth-Scopes/X-OAuth-Scopes.AuthenticateHandler integration › constructor()has two tests that each default one option totruewhile keeping the other's explicitfalse.The two tests that asserted the old
Missing parametererrors are replaced by those default tests.biome check .is clean and the full mocha suite passes (465).OAuth2 standard
Not affected.
X-Accepted-OAuth-Scopes/X-OAuth-Scopesare informational, non-standard headers.Reproduction
🤖 Generated with Claude Code