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

fix(oauth): correctly remove code_verifier cookie when used #2325

Merged
merged 1 commit into from
Jul 8, 2021
Merged

fix(oauth): correctly remove code_verifier cookie when used #2325

merged 1 commit into from
Jul 8, 2021

Conversation

pbr1111
Copy link
Contributor

@pbr1111 pbr1111 commented Jul 8, 2021

Reasoning 💡

Once the pkce code verifier is used, the cookie is cleared but the browser blocks the deletion of this cookie, keeping it in the browser until it expires.

image

This is because when using the cookie with the useSecureCookies option enabled (https environment), the cookie is prefixed with __Secure-. and it must use the cookies.pkceCodeVerifier.options options to be valid (the secure attribute must be set to true).

Checklist 🧢

  • Documentation
  • Tests
  • Ready to be merged

Affected issues 🎟

@vercel
Copy link

vercel bot commented Jul 8, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nextauthjs/next-auth/FUepxM5cSfTStySRwPg2Qco3SbMQ
✅ Preview: https://next-auth-git-fork-pbr1111-fix-pkce-code-verifier-nextauthjs.vercel.app

@vercel vercel bot temporarily deployed to Preview July 8, 2021 09:14 Inactive
@github-actions github-actions bot added the core Refers to `@auth/core` label Jul 8, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #2325 (1d3b8a6) into main (ac5b4db) will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #2325   +/-   ##
=====================================
  Coverage   9.96%   9.96%           
=====================================
  Files         82      82           
  Lines       1395    1395           
  Branches     395     395           
=====================================
  Hits         139     139           
  Misses      1030    1030           
  Partials     226     226           
Impacted Files Coverage Δ
src/server/lib/oauth/pkce-handler.js 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac5b4db...1d3b8a6. Read the comment docs.

@balazsorban44
Copy link
Member

Appreciate this PR, good catch! I'll try this out and merge if all is well! 🙏

@balazsorban44 balazsorban44 changed the title fix: add pkceCodeVerifier cookie options on pkce cookie removal fix(oauth): correctly remove code_verifier cookie when used Jul 8, 2021
@balazsorban44 balazsorban44 merged commit f546e55 into nextauthjs:main Jul 8, 2021
@pbr1111 pbr1111 deleted the fix/pkce-code-verifier branch July 8, 2021 21:23
mnphpexpert added a commit to mnphpexpert/next-auth that referenced this pull request Sep 2, 2024
…thjs#2325)

Co-authored-by: Pol Bonastre <pbonastre@plainconcepts.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants