hackathon-starter icon indicating copy to clipboard operation
hackathon-starter copied to clipboard

Refactoring config/passport.js

Open YasharF opened this issue 2 years ago • 8 comments

NOTE: Prior to any PRs the potential design and implementation needs to be discussed in this issue as this is not a minor code change. Please make sure you have a good understanding of oAuth 2.0 including refresh tokens, etc. prior to any work on this issue.

Background: At a higher level, the strategies in passport.js seem to be following similar patterns. Problem: Maintenance of the strategies when there is a change to the underlying libraries is cumbersome. We can also end up with bugs because a fix may have been applied to most of the strategies but one or two may have been missed. To provide an example, the passport,js mongoose 7 upgrade resulted in a ~900 line diff, but at the core of it, it was the same change getting repeated in each strategy: https://github.com/sahat/hackathon-starter/commit/55defd3dbaa2adb27486610b104d7a12f423a0a9#diff-fa60852f5a2e88327803171e7f8972c7799de05a17566b46e958f27c4c7b965e

Potential solution: We refactor the code so there is a core generic routine for handling oAuth, which uses configs for each oAuth provider. This potential solution can also allow us or users to easily add (or remove) oAuth providers without worrying about potential token handling bugs in specific implementations.

NOTE: Prior to any PRs the potential design and implementation needs to be discussed in this issue as this is not a minor code change. Please make sure you have a good understanding of oAuth 2.0 including refresh tokens, etc. prior to any work on this issue.

YasharF avatar Oct 11 '23 12:10 YasharF

I relatively need to open source and contributions, but if you can guide me how to make the required changes, i can work and deliver excellent results.

bhavuk2002 avatar Oct 12 '23 11:10 bhavuk2002

Hey @YasharF I have prior experience of working on OAuth projects. I am up for resolving this issue. You can assign this to me & we can have the further discussions around this.

Chirag77302 avatar Oct 13 '23 09:10 Chirag77302

No assignment at this point. Please discuss as you may see fit.

YasharF avatar Oct 13 '23 21:10 YasharF

We could improve Passport.js OAuth setup by organizing code into smaller parts, making it easier to manage multiple login options. Create a common function to handle different services and set up a way to easily add new logins. This will simplify the process and make it smoother to expand login choices.

Mano3009 avatar Dec 15 '23 12:12 Mano3009

Can someone check on the pr #1293 , i focused on importing the already defined "handleservice" function and utilizing it within Passport authentication strategies.

Mano3009 avatar Dec 24 '23 12:12 Mano3009