Skip to content

Conversation

@mjy9088
Copy link

@mjy9088 mjy9088 commented Feb 13, 2023

this change is required for KakaoProvider

NOTE:

  • It's a good idea to open an issue first to discuss potential changes.
  • Please make sure that you are NOT opening a PR to fix a potential security vulnerability. Instead, please follow the Security guidelines to disclose the issue to us confidentially.

☕️ Reasoning

  • It looks like Kakao is sending extra properties.
  • Prisma doesn't accept extra properties.
  • Fixed by filtering extra properties.

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

Please scout and link issues that might be solved by this PR.

Fixes: #6708

📌 Resources

etc

I even not sure this is right, I need help

this change is required for KakaoProvider
@mjy9088 mjy9088 requested a review from ndom91 as a code owner February 13, 2023 07:07
@vercel
Copy link

vercel bot commented Feb 13, 2023

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

Name Status Preview Comments Updated
auth-docs ❌ Failed (Inspect) Feb 13, 2023 at 7:07AM (UTC)
1 Ignored Deployment
Name Status Preview Comments Updated
next-auth-docs ⬜️ Ignored (Inspect) Feb 13, 2023 at 7:07AM (UTC)

@github-actions github-actions bot added adapters Changes related to the core code concerning database adapters prisma @auth/prisma-adapter labels Feb 13, 2023
@balazsorban44
Copy link
Member

Thanks, but it was a deliberate choice to forward all properties to the adapter as-is in next-auth@4. However this has gotten mixed feedback, so we would like to address this in the new @auth/core package, via an account() callback for providers. See #5461

For now, you can either extend the Prisma schema to include the extra properties or apply the filtering on the adapter methods in your app.

Tip, you can override individual methods fairly easily, since an Adapter is just an object. Example:

...
const p = PrismaClient()
const adapter: Adapter = {
  ...PrismaAdapter(p),
  linkAccount: ({filteredProp: _, ...data}) =>
    p.account.create({ data }) as unknown as AdapterAccount,
  }
}

export default NextAuth({
  adapter,
  ...
})

As for createUser, you can already control this via the profile() callback as mentioned here: https://next-auth.js.org/adapters/models#user

@mjy9088
Copy link
Author

mjy9088 commented Feb 13, 2023

Thanks, we decided to filter out extra properties.

my understanding:

  • all developers using that provider have to choose one of below at this point
    • filter out extra properties by extending adapter
    • save extra property too
  • plan to address this issue in next version of core

is it correct? :)

plus, by any chance, can I know whether something is deliberate choice or not?
I'm new to open source community, I'm afraid I'm only posting weird issues that aren't helpful ...

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

Labels

adapters Changes related to the core code concerning database adapters prisma @auth/prisma-adapter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prisma adapter is not working with the KakaoProvider due to additional properties

2 participants