User Avatar

I write about freelancing, solopreneurship, web dev and data science.

The most common authentication method for user-facing online services is the traditional username + password login. However, this approach is deeply flawed and puts users and their data at risk. I'll explain why this is the case and why I went with magic link authentication instead for my SaaS.

Lazy Users

If all of your users used strong passwords for your service and had a different password for each service they use, password-based authentication would be fine. But that's not the case. Most people use the same password everywhere. On top of this, many people use weak passwords like 123456. Hoping that the majority of your users will start using password managers is wishful thinking.

Due to the growing number of leaked credentials from hacked services, many of your app's user accounts are completely and utterly exposed. It's only a matter of time until a bad actor tries the right credentials on your login page and wreaks havoc to the detriment of your user.

What about MFA?

Multi-Factor Authentication is great. However, what you want when you add MFA to your app is to have TWO secure factors, not one. It is supposed to be additional security, not the sole security. With password-based authentication, the second factor is only a band-aid covering the insecure first factor.

What is magic link authentication?

Magic link auth works as follows. When logging in, your user enters only their email address (no password). Your server then generates a random token and stores it in the database. Then it sends the user an email with a link to your app containing the token. When the user clicks the link, your server validates the token and logs the user in.

That's it. No password is required and as there are no credentials stored in your database, there is nothing for hackers to steal and leak. The security of this authentication strategy lies in the fact that only your user has access to their email inbox.

But what if my user's email gets hacked?

Well, that's bad. If this happens, the hacker can log into your service, impersonating the hacked user. But your app probably has this problem already. In fact, your "reset password" flow probably looks very much like magic link authentication so this attack vector is present in your app already. Your user has to keep their email account secure no matter if you use password-based or magic link authentication.