blitz-js / blitz

⚡️ The Missing Fullstack Toolkit for Next.js
https://Blitzjs.com
MIT License
13.68k stars 798 forks source link

Simplify Social and 3rd Party Auth #1473

Closed ThePaulMcBride closed 1 year ago

ThePaulMcBride commented 3 years ago

What do you want and why?

Right now, it is possible to integrate with lot of 3rd party auth providers using passport strategies. This is super flexible and I don't think Blitz should ever move away from that approach. However, for the majority of cases, I suspect these strategies are identical.

Possible implementation(s)

NextAuth has a good approach for this. You can provide custom setup if you like, but for all of the more common cases, they provide pre-built integrations. In there case it looks something like this.

providers: [
  Providers.Twitter({
    clientId: process.env.TWITTER_ID,
    clientSecret: process.env.TWITTER_SECRET
  })
],

Would it be possible to do something like this for Blitz?

flybayer commented 3 years ago

Yep! We just need to figure out what the required db fields are to have and then our simple adapter can handle everything for you.

niklasgrewe commented 3 years ago

@flybayer any news on it? i also want to integrate social providers. I would be very happy if you would make the config similar to next-auth 👍 just out of interest... would it theoretically also be possible to use next-auth directly in blitz, or would that involve difficulties?

flybayer commented 3 years ago

@niklasgrewe I want to make sure you know we already support social auth with the passport adapter: https://blitzjs.com/docs/passportjs It's slightly more code than next-auth, but you have full control to customize as needed. This particular feature request is just an optimization for simple cases.

And there's no update on this particular issue but this is ready for anyone to work on and figure out how it would look and work.

And theoretically you could use next-auth, but it would take quite a bit for you to hook it up with queries/mutations, etc. Much better to use blitz built in auth.

puria commented 3 years ago

Does make sense to have it as a recipe to just blitz install passportjs?

flybayer commented 3 years ago

@puria I think we should add that regardless of the request in this issue