News for hackers. Stuff that matters.
Re:Comparing Auth from Supabase, Firebase, Auth.js, Ory, Cle... by namanyayg on Wednesday October 23, 2024 @01:06PM (#41927049)
What I need is something that has first class support for "guest" or "anon" accounts, that can easily be then converted to social login. E.g. a guest user starts using the app without any login wall, after some usage is promoted to login using google/github/etc to continue.

I recently made a hacky solution for that using Next Auth (which is now called Authjs) because the requirements changed up on me and it's literally the ugliest and hackiest piece of code I've written in a long while.

I hate it and I doubt I'm going to ever recommend Authjs to anyone.

Any tips on what I should use instead?

Re:Comparing Auth from Supabase, Firebase, Auth.js, Ory, Cle... by beeboobaa3 on Wednesday October 23, 2024 @01:18PM (#41927176)
Each user gets a token associated with them. On each request you first check if they are authenticated via your auth of choice. If so, you take the token associated with this auth from your database. If not, you take the token sent via cookie. If no token is available, you generate one and set it.

Then when a user "signs up" you do the same thing. If they sent a token via cookie, you associate this token with their auth in your database. If they somehow didn't have a token yet they were probably blocking cookies, but you can just generate a new one at that point.

If a user logs in again later while they already had a token you can choose to migrate all data from that token to their login token, so no data that was created prior to login gets lost.

The point is that there's essentially no difference between regular profiles and shadow profiles. Both are just profiles. And a profile can be authenticated with using its token, or using an associated auth provider.

Re:Comparing Auth from Supabase, Firebase, Auth.js, Ory, Cle... by namanyayg on Wednesday October 23, 2024 @09:29PM (#41931022)
I know this, but do you think all of these parts should need to be coded by hand? It's just a complete waste of time. That's what I meant by writing hacky and ugly code to achieve this.

Plus, in Next, there was no way to associate a token to a social login during the new login in the backend. The only way is to do it via a separate request in the frontend and then relogin the user.

Re:Comparing Auth from Supabase, Firebase, Auth.js, Ory, Cle... by beeboobaa3 on Thursday October 24, 2024 @09:10AM (#41935153)
I mean in total it's like 10-30 lines of code put in the place where you load the user session, and a very small rearchitecture of the database.

So... Kind of, yeah.

Re:Comparing Auth from Supabase, Firebase, Auth.js, Ory, Cle... by Leftium on Wednesday October 23, 2024 @04:39PM (#41929081)
Re:Comparing Auth from Supabase, Firebase, Auth.js, Ory, Cle... by snagg on Friday October 25, 2024 @05:15PM (#41949855)
Hey,

Co-founder of SlashID here (one of the companies mentioned above). I think we have exactly what you are looking for:

https://www.slashid.dev/blog/anonymous-users/

https://developer.slashid.dev/docs/access/concepts/anonymous...

Hit me up if you want to chat more: [email protected]