Eric

Logins: Simple, Secure, Private - Pick One (If You’re Lucky)

Say you finally have a server for a little personal project. Maybe you can push a button on a webpage or app and the push will be recorded. It works so well that you want to share it with one other person.

What do you do?

We’re all familiar with login systems. There are usernames and passwords, sometimes auto-filled by a password manager. There are “email me a magic link” buttons. There are “Log in with Google/Facebook/GitHub” buttons. There are even secret links that you just have to hope nobody shares in the wrong place.

If you are exposing a database to the Internet (which you have to, if you want to be able to use the little tool you built from anywhere), you have a series of bad options. If you want to let additional people also interact with that database, your options get worse.

You might want to rely on “security through obscurity”: Nobody knows about your little website, so they won’t direct large amounts of effort into breaking in, right? Unfortunately, there are enough automated worms and viruses out there that you might get hit by an attack anyway, and in the best case all that will happen is a lot of junk data will be written into your system.

Here are all the possibilities I know of.

You could also add two-factor authentication to any of these, most likely passwords, but you’ll have to figure out how you deliver the two-factor codes, which usually is equivalent to the email, text, or authenticator app options, and so adds all of their cons, in addition to the added inconvenience to the user of needing to switch apps or devices.

Once you have finally made some decisions, you will still have a myriad of other considerations, such as:

My general advice:

Closing thoughts

It’s conceivable that one day, there could be a library that is relatively simple to drop into a website, with a few files implementing a login page, secure (likely key-based) account management system, and a simple file-based database, so that the rest of the site can just call a few library functions to query the database and check that a given Web request comes from a logged-in user. At the time of writing (December 2023), the closest things are probably OAuth2 libraries, which the author clearly dislikes after years of struggling with their complexity. Hopefully one or more projects will be completed so that by the end of the decade, aspiring Web developers will have a few good options with clear tradeoffs.