Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(next-auth): add legacy flag for v4 compatibility #12825

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ThangHuuVu
Copy link
Member

☕️ Reasoning

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

📌 Resources

@ThangHuuVu ThangHuuVu requested a review from ndom91 as a code owner March 28, 2025 15:02
Copy link

vercel bot commented Mar 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ❌ Failed (Inspect) Apr 5, 2025 8:32am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Apr 5, 2025 8:32am
proxy ⬜️ Ignored (Inspect) Visit Preview Apr 5, 2025 8:32am

@github-actions github-actions bot added the core Refers to `@auth/core` label Mar 28, 2025
@ThangHuuVu ThangHuuVu requested review from balazsorban44 and Copilot and removed request for ndom91 March 28, 2025 15:04
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a legacy flag to maintain compatibility with v4 behavior alongside the upcoming v5 release. The changes adjust cookie naming, update OAuth callback behavior, and extend configuration types to support the legacy mode.

  • Remove duplicate import statements and restructure type declarations.
  • Update cookie naming conventions based on legacy mode.
  • Amend OAuth handler to conditionally bypass state and PKCE checks when legacy mode is enabled.

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/core/src/types.ts Reorders type imports and adds an optional legacy flag to internal options
packages/core/src/lib/utils/cookie.ts Introduces a legacy flag to modify cookie name prefixes accordingly
packages/core/src/lib/init.ts Passes the legacy configuration to defaultCookies and opts in legacy behavior
packages/core/src/lib/actions/callback/oauth/callback.ts Updates OAuth callback to adjust state validation and PKCE handling for legacy mode
packages/core/src/index.ts Adds a legacy flag to AuthConfig to enable legacy mode
Files not reviewed (1)
  • docs/pages/getting-started/migrating-to-v5.mdx: Language not supported
Comments suppressed due to low confidence (1)

packages/core/src/lib/actions/callback/oauth/callback.ts:134

  • [nitpick] Consider refactoring the nested ternary logic for 'stateCheck' into a clearer if/else structure or extracting it into a helper function to improve readability and maintainability.
const stateCheck = legacy && !provider.checks.includes("state") ? o.skipStateCheck : provider.checks.includes("state") ? state : o.skipStateCheck

Copy link
Member

@ndom91 ndom91 left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link

socket-security bot commented Mar 30, 2025

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@inkeep/[email protected] Transitive: environment, filesystem, network, shell, unsafe +30 23 MB sarah-inkeep
npm/@mikro-orm/[email protected] environment, eval, filesystem, unsafe 0 888 kB b4nan
npm/@mikro-orm/[email protected] filesystem +1 354 kB b4nan
npm/@miniflare/[email protected] filesystem, unsafe Transitive: environment, eval, network, shell +6 470 kB wrangler-publisher
npm/@neondatabase/[email protected] network +1 366 kB pffigueiredo
npm/@next/[email protected] None 0 14.2 kB vercel-release-bot
npm/@playwright/[email protected] None 0 25.3 kB dgozman-ms
npm/@preact/[email protected] Transitive: environment, filesystem, unsafe +36 8.07 MB rschristian
npm/@prettier/[email protected] environment 0 349 kB shinigami92
npm/@prisma/[email protected] environment, filesystem, shell 0 8.43 MB prismabot
npm/@prisma/[email protected] None 0 62.8 kB prismabot
npm/@radix-ui/[email protected] None +14 349 kB chancestrickland
npm/@radix-ui/[email protected] None +14 332 kB chancestrickland
npm/@simplewebauthn/[email protected] None 0 42 kB iamkale
npm/@solidjs/[email protected] None 0 20.4 kB ryansolid
npm/@supabase/[email protected] network +6 2.23 MB kiwicopple
npm/@sveltejs/[email protected] environment, filesystem, shell 0 7.03 kB svelte-admin
npm/@sveltejs/[email protected] environment 0 7.41 kB svelte-admin
npm/@sveltejs/[email protected] environment, eval 0 737 kB svelte-admin
npm/@sveltejs/[email protected] None 0 29.1 kB svelte-admin
npm/@sveltejs/[email protected] None +2 171 kB svelte-admin
npm/@types/[email protected] None +2 250 kB types
npm/@types/[email protected] None 0 13.8 kB types
npm/@types/[email protected]18.11.10 None 0 3.56 MB types
npm/@types/[email protected]20.12.7 None 0 2.03 MB types
npm/@types/[email protected] None 0 88.9 kB types
npm/@types/[email protected] None 0 14.2 kB types
npm/[email protected] environment, eval, filesystem, network, shell, unsafe 0 3.26 MB vitebot

🚮 Removed packages: npm/@auth/[email protected], npm/@auth/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@vercel/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core` next-auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants