We discussed it with my colleague two weeks ago and decided to invest some time in our next sprint for some POC tests.
Iâm right now in vacation and would give you a feedback as we went further.
We discussed it with my colleague two weeks ago and decided to invest some time in our next sprint for some POC tests.
Iâm right now in vacation and would give you a feedback as we went further.
Thank you for putting the work in on this. I had the exact same need - nice to see the workâs been done already!
Just a caution. You asked for suggestions on additional providers to include. Iâve seen similar libraries in other frameworks (not just login, but anything that adapts to 3p services). Iâve noticed that libraries that support a large number of 3p providers end up not being well maintained, itâs just too much work.
Iâd suggest just sticking to the providers you have and having a well-defined plugin architecture for your plugin, with good documentation on how to add custom providers. If youâd like any suggestions on the API for the extension point, Iâd be happy to chime in - I havenât looked through your implementation because itâs not a pressing need for me yet (fakinâ it till I make it).
Sounds great! Let me know if I can provide any further information or assistance.
Of course!
Totally hear what youâre saying - I did some research on other implementations, and found the same. Most OAuth libraries, IMO, try to do way too much, and end up being extremely provider specific with the exact issues you described. The other downside is that it then increases setup complexity.
For this reason, the approach I took here is to only focus on auth, with minimal user info retrieval from the providers (lowest common denominator is Apple, which only provides email).
Therefore, rather than provider specific solutions, this plugin focuses on using OIDC ID tokens (where possible), or OAuth2 user info endpoints (when OIDC isnât supported).
What this means is that adding a new provider ideally just means adding the provider specific endpoints.
Whenever you get around to giving the plugin a go, definitely donât hesitate to chime in with any suggestions or questions!
Awesome. Thank you!
Of course! Let me know if you have any thoughts!
This is great work. Thank you. I there a way to add easily another provider at the moment? Or could I make a PR? I want to integrate with Linear.app
Thanks!
Definitely feel free to open a PR! Let me know if you have any questions or run into any issues.
I took a quick look at the Linear.app docs - it doesnât look like it supports OIDC, just OAuth2, in which case you would follow the same pattern I took for GitHub.
Another note - I want to minimize dependencies, so use their REST endpoint instead of their client SDK.
Keep me posted!
Another thing - I use Yalc and Lerna to keep the working project in sync with my testing Redwood app, and the Yarn workspaces are already set up with scripts for running these. Let me know if you run into any issues with that as well.
Just published v2 of this plugin, which works with RedwoodJS v8!
The sample project has also been updated
@arimendelow Thank you for the plugin. I have a quick question.
I donât really understand the rational behind Sign up and Sign in differentiation using OAuth. I am thinking of just adding âSign-in with Googleâ and then detect on the backend if email already exists. If it exists, continue, otherwise create a new row in the user table. What am i missing here? Wouldnât it simplify the flow a lot?
I see that since you wrote the plugin, you had to target a wider audience and there would always be someone with a need that they need to differentiate it at the user level.
Just trying to steer away from future problems as early as I can.
(My question is nothing urgent. Hope you enjoy holidays.)
Adorn
Hi Adorn, and welcome to the community!
Thatâs a great question, and it was a deliberate design decision to avoid allowing users to accidentally create new accounts. A UX belief that I tend to adhere to is that all actions taken by the user should be deliberate ones â in this case, clicking âSign Upâ if one attempts to sign up, and âSign Inâ if one attempts to sign in. Bad things can happen if you try to âsimplifyâ a userâs experience by taking action on their behalf that they may not have intended.
For example, itâs not uncommon to have multiple emails, and quite common to not remember which log in method you used with a given platform.
Therefore, the library is designed to support two scenarios:
That said, if you do want to support a unified âSign Inâ button that will sign up any user without an account, I believe it would be pretty straightforward to add a configuration option. Let me know if opening a PR for this is something youâd be interested in working on, and I can give you some code pointers to help get you started!
@arimendelow Yes, I would be interested in contributing. Would need a lot of pointers though - I am new to full stack development.
I think I can get something working and create a PR, we can take it from there.
Sure! To start, take a look in the following places:
This is where we return an error message on login if the user has not yet signed up: https://github.com/spoonjoy/redwoodjs-dbauth-oauth/blob/43f13835c1e9fd63a688e3c8c63aba5b74e3a405/api/src/OAuthHandler.ts#L1106
Right below it is where we kick off the sign up flow: redwoodjs-dbauth-oauth/api/src/OAuthHandler.ts at 43f13835c1e9fd63a688e3c8c63aba5b74e3a405 ¡ spoonjoy/redwoodjs-dbauth-oauth ¡ GitHub
So I would add an option to OAuthHandlerOptions called something like signupOnFailedLogin
that calls that signup method instead of returning an error.
That said, if youâre focusing on building some type of app, I wouldnât worry about details like this just yet â the difference itâll make to any perspective users it not worth the effort.
However, if youâre just learning FSD and this interests you, then go for it!! Iâm here to help