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

Upgrade to @auth/core 0.37.3 #119

Closed
wants to merge 5 commits into from
Closed

Conversation

dowski
Copy link
Collaborator

@dowski dowski commented Nov 12, 2024

This is a minimal approach to switching to @auth/core 0.37+. It pulls in a bit more code, but lets us run using the new 3.x version of oauth4webapi as well.

The test suites (test/ and test-nextjs/) succeed. I plan on trying out a few providers manually with this change, but thought I'd put the code up for review in the meantime.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

vercel bot commented Nov 12, 2024

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

Name Status Preview Comments Updated (UTC)
convex-auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 19, 2024 5:24pm

Copy link
Contributor

@sshader sshader left a comment

Choose a reason for hiding this comment

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

I'm down to try it (with a bunch of manual testing). It does make me nervous to patch in changes @auth/core that we perhaps don't fully understand

@@ -221,10 +260,6 @@ export async function handleOAuthCallback(
codeGrantResponse;
}

if (o.parseWwwAuthenticateChallenges(codeGrantResponse)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this move somewhere else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to the oauth4webapi 3.0.0 release notes, this function was removed.

removed parseWwwAuthenticateChallenges(), all functions verify process Response now reject with WWWAuthenticateChallengeError instead

https://github.com/panva/oauth4webapi/releases/tag/v3.0.0

nonce ?? o.expectNoNonce,
{
expectedNonce: nonce ?? o.expectNoNonce,
requireIdToken: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we understand what this does / why it's safe to change here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oauth4webapi 3.0.0 changed the API and replaced a couple functions with this one.

processAuthorizationCodeOpenIDResponse() method was removed in favour of processAuthorizationCodeResponse()
processAuthorizationCodeOAuth2Response() method was removed in favour of processAuthorizationCodeResponse()

https://github.com/panva/oauth4webapi/releases/tag/v3.0.0

These extra args passed here are for OIDC - Auth.js does it in a similar way:

https://github.com/nextauthjs/next-auth/blob/1c9bcdd0c4538a852f8d2b2b7c60eb962e3a50eb/packages/core/src/lib/actions/callback/oauth/callback.ts#L215-L223

@@ -71,7 +71,7 @@
"server-only": "^0.0.1"
},
"peerDependencies": {
"@auth/core": "^0.36.0",
"@auth/core": "^0.37.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

If we land this, we should also update the docs that tell you to install @auth/[email protected]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm guessing you mean 0.37.0.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should update the docs that tell you to install @auth/[email protected] to tell you to install @auth/[email protected]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep! Updated!

Copy link
Collaborator Author

@dowski dowski left a comment

Choose a reason for hiding this comment

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

So far I've manually tested this with Github, Google and Apple (the latter required a few tweaks to work, I think that was required whether we upgrade to @auth/core 0.37.0 or not).

@@ -221,10 +260,6 @@ export async function handleOAuthCallback(
codeGrantResponse;
}

if (o.parseWwwAuthenticateChallenges(codeGrantResponse)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to the oauth4webapi 3.0.0 release notes, this function was removed.

removed parseWwwAuthenticateChallenges(), all functions verify process Response now reject with WWWAuthenticateChallengeError instead

https://github.com/panva/oauth4webapi/releases/tag/v3.0.0

nonce ?? o.expectNoNonce,
{
expectedNonce: nonce ?? o.expectNoNonce,
requireIdToken: true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oauth4webapi 3.0.0 changed the API and replaced a couple functions with this one.

processAuthorizationCodeOpenIDResponse() method was removed in favour of processAuthorizationCodeResponse()
processAuthorizationCodeOAuth2Response() method was removed in favour of processAuthorizationCodeResponse()

https://github.com/panva/oauth4webapi/releases/tag/v3.0.0

These extra args passed here are for OIDC - Auth.js does it in a similar way:

https://github.com/nextauthjs/next-auth/blob/1c9bcdd0c4538a852f8d2b2b7c60eb962e3a50eb/packages/core/src/lib/actions/callback/oauth/callback.ts#L215-L223

@@ -71,7 +71,7 @@
"server-only": "^0.0.1"
},
"peerDependencies": {
"@auth/core": "^0.36.0",
"@auth/core": "^0.37.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm guessing you mean 0.37.0.

@dowski dowski changed the title Upgrade to @auth/core 3.7.3 Upgrade to @auth/core 0.37.3 Nov 19, 2024
@dowski
Copy link
Collaborator Author

dowski commented Dec 10, 2024

Closing this since we went with the approach in #121 instead.

@dowski dowski closed this Dec 10, 2024
@dowski dowski deleted the auth-core-upgrade branch December 10, 2024 15:12
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.

2 participants