Skip to content

fix: default cookie path to / and send tokenRequestParams on refresh - #343

Open
Tony133 wants to merge 3 commits into
mainfrom
fix/cookie-path-and-refresh-params
Open

Tony133 wants to merge 3 commits into
mainfrom
fix/cookie-path-and-refresh-params

Conversation

@Tony133

@Tony133 Tony133 commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

Proposal:

Two small fixes, both with tests.

  • Default cookie path to / (Invalid state with Github provider (err 500) #255)
    The state and PKCE verifier cookies were set without a path, so browsers applied the default-path rule (RFC 6265 §5.1.4): with startRedirectPath: '/login/github' the cookie got Path=/login and was never sent to a callback like /api/auth/github/callback, ending in Invalid state. With /github it happened to get Path=/ and worked, which is exactly what the reporter observed. Now path: '/' is part of the defaults, still overridable through options.cookie; __Host- handling is unchanged. This was very likely also behind "Invalid State" Error in GitHub OAuth2 #295.

  • tokenRequestParams on refresh (tokenRequestParams should be passed into OAuth2Token#refresh #292)
    They were only merged into the authorization code exchange. Providers that need client_id/client_secret in the body (Twitch, LinkedIn) failed on getNewAccessTokenUsingRefreshToken unless the caller passed them again by hand. They're now merged into the refresh request too, with explicit params taking precedence.

README updated for both changes.

Upgrade note: cookies set by previous versions may still carry a narrower Path. A user who left a login flow half-way before the upgrade may hit Invalid state until that session cookie expires.

Fixes #255
Fixes #292

@Tony133
Tony133 force-pushed the fix/cookie-path-and-refresh-params branch from 98503b2 to d0fc2d9 Compare September 7, 2026 20:46
@Tony133
Tony133 marked this pull request as ready for review September 7, 2026 20:54
@Tony133
Tony133 force-pushed the fix/cookie-path-and-refresh-params branch from d0fc2d9 to 43a9ce0 Compare September 8, 2026 08:16
@Tony133
Tony133 requested a review from mcollina September 13, 2026 21:54
@Tony133
Tony133 requested a review from Fdawgs September 21, 2026 09:55
Comment thread index.js Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Direct OAuth2Token.refresh() calls still omit configured tokenRequestParams, leaving part of issue #292 unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Defaults OAuth cookies to Path=/ and applies configured token parameters during helper-based refreshes.

Changes:

  • Adds root-path cookie defaults and documentation.
  • Merges tokenRequestParams into refresh helper requests.
  • Adds regression tests.
File Description
index.js Updates cookie defaults and refresh parameters.
test/​index.test.js Adds regression coverage.
README.md Documents the cookie path default.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread index.js Outdated
@Tony133
Tony133 force-pushed the fix/cookie-path-and-refresh-params branch from 43a9ce0 to e50291f Compare September 22, 2026 13:39
@Tony133
Tony133 requested a review from Fdawgs September 22, 2026 13:40
Comment thread index.js
@Tony133
Tony133 requested a review from Fdawgs September 23, 2026 13:40
@Tony133
Tony133 force-pushed the fix/cookie-path-and-refresh-params branch from e50291f to f70194e Compare October 1, 2026 08:56
@Tony133
Tony133 removed the request for review from Fdawgs October 1, 2026 08:56
@Tony133
Tony133 requested a review from a team October 11, 2026 10:18
@Tony133
Tony133 requested a review from Eomm October 24, 2026 09:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tokenRequestParams should be passed into OAuth2Token#refresh Invalid state with Github provider (err 500)

3 participants