Show HN: Emauth.io – Free service for Slack-style passwordless login links
emauth.io
emauth.io
We store the user’s session ID at the time they request the email be sent, and then validate it’s still the same session ID when the token (which is a parameter on the URL) is consumed.
If you’re using something like Mailchimp or SendGrid to send emails, this design also protects against a scenario where the email service is compromised by an attacker. The attacker will be able to see the emails, but will be unable to use the links to login.
Not too rare of a thing.
Or segments their browsing in different browsers/containers.
If it happens to be on the same browser that requested the login, it will be the same session anyway, and will work as you'd expect.
If it's a different device/browser, then (using your example) the user will see a message on their phone like "Login validated, please check the original device where you initiated login" and their desktop session will now be validated. Ideally the site uses polling or a push mechanism to proactively show the right page, but the lazy way is just to show a message like "Refresh this page after clicking the login link from your email".
The naive implementation is to just say "Hey, a valid token... Ok, you're now logged in", but this suffers from the issue mentioned in a parent comment:
>>> Links can be opened by the controller of the email even if they didn't make the original request. Links can also be opened by something scanning the email before the user sees them. Neither of these potentially malicious use-cases are covered by emauth.io.
>> We store the user’s session ID at the time they request the email be sent, and then validate it’s still the same session ID when the token (which is a parameter on the URL) is consumed.
> This breaks the use-case where the user is on a desktop computer but checks mail on their phone.
So what I'm saying is:
* Store the sessionId with the token
* When you handle the validation request, mark the stored sessionId as "logged in"
This handles the "click on validation from a different device" use case, while also preventing someone who's able to intercept your email from being able to log in themselves.
1. Request magic link on desktop. 2. Click magic link on mobile. 3. Become logged in on desktop.
gregmac mentioned (correctly) the things you’d want to do in terms of UI/UX if you want to allow for this flow.
A reply based design leaves you open to attacks because you have no way of having strong security guarantees/validation on the email reply. You would have to rely on validating that the email has valid DKIM, but DKIM won’t be available 100% of the time. And without DKIM the reply could be spoofed.
I've run into this a lot for things like when I want to log in to a public computer, such as to print something. Having a logged-in device with you makes this much quicker.
> A reply based design leaves you open to attacks because you have no way of having strong security guarantees/validation on the email reply. You would have to rely on validating that the email has valid DKIM, but DKIM won’t be available 100% of the time. And without DKIM the reply could be spoofed.
It's just as strong as using a link, because you can verify against the message ID of the original email. And has the advantage that it's not going to be triggered by your email client without action on your part. Plus you can use DKIM when it's available as a bonus security layer.
Again, this flow is still very much possible with a design that verifies session ID. Please re-read my last comment and gregmac’s comment carefully!
To be really clear, you can design it so that you:
(1) start the login process on a public computer, (2) click the link on a mobile device, and (3) end up logged in on the public computer. And you can do this while ensuring that the session ID is the same in steps #1 and #3.
My initial plan was to require the user to reply to the email, which solves the scanner problem and has the benefit of not opening a new tab. This comes at the cost of being an unfamiliar flow, and requiring an extra click. What are your thoughts on that?
I ended up starting with links since it worked for me (apparently gmail and fastmail don't pre-open links) and was simpler to implement for the prototype. Also it's less dependent on the speed of the user's email server.
Hi Anders — see my comment above for how do to this.
(I've seen too many systems in the past where they shell out to the command-line for delivering email, I had to try it!)
In what language? Sometimes a service is nothing more than a library where HTTP is the ABI.
Would be great if the service returned something like a JWT or just a signed copy of the email address verified (potentially with an expiry date). That way you can use the token itself as authentication without making network calls on the backend to verify it on each call. Not saying this is necessarily production-grade security, but could suffice for small projects where ease-of-use is more important than token revocability.
emauth is intended to be very barebones. On it's own it really doesn't do much. You still need to have some sort of session management on your server. What emauth saves you from is having to worry about generating/storing passwords.
Returning a JWT is an interesting idea. Can you explain more what that would look like? Obviously anything that involves consulting emauth.io for every request isn't going to work. But maybe there would be a simple way for emauth to delegate token verification to your server.
Not sure why he wants you to implement another oauth server though, there are several quite good (i.e. keycloak) around at this point.
If it sounded like your service already exists as an open source solution with libraries for every language... I don't believe it does, it at least I don't know about it.
You could actually implement it with a module in keycloak, but you'd need to write the code yourself. Though it shouldn't be too hard
https://www.keycloak.org/downloads.html
There are community libraries for other languages as well.
And lots of code example for custom authentication flows like
https://github.com/stianst/keycloak-experimental/tree/master...
And an example implementing the auth flow with libraries for a webservice https://github.com/houmie/sso/blob/master/src/app.py
(I'm unrelated to all links, just got them from quick Google searches)
If you implement jwt, you will need sessions and all other features authentication servers have... It would be way easier to implement a custom authentication flows mimicking your email auth than recreating everything else.
I think your service is good as is and introducing jwt to it would be a net-negative
But I'm just a random person from the internet, do whatever you feel like doing ;)
But generally any authentication server that can generate JWTs for authenticated users.
And then with any JWT lib you check the validity (expiration, signature, ...) of the token. See https://jwt.io for a list of libs.
> Any given email address can only be verified a certain number of times each month.
How many times?
> If you subscribe to emauth pro for $4/month, you can make 512 verifications per month
512 verifications for $4/month is a big ask. Auth0 and Firebase have bigger free tiers, not 100% sure though.
> If you need more verifications than this (for example if you want to use emauth for a public app with many users), please contact sales at sales ...
Before you start enterprise sales, some options which are bigger than 512 would be great and I am also not sure if this type of smaller service would justify any enterprise sales. However, let us know if anyone contacted you for some enterprise-y deals.
> Also, in order to protect the email sender reputation for emauth, we aggressively blacklist ip addresses that repeatedly make requests to invalid email addresses.
Makes sense but how long are these IP blacklisted? How many requests are required to blacklist an IP? Btw, this won't help OPs email reputation, just few dozens of bounces are required to get your domain on many blacklists. How did other people solved this problem? How did Medium worked around this problem in its early days?
Biggest problem though:
Integrating something like your service is easy but building processes around creates a light lock-in and getting the stuff out again is some work. Looking at your landing page which I like because it's light and subtle, it still gives the feeling that it's hobby project and nobody knows if you are still on the market next month or next year.
Smaller problem:
No custom domain possible (or is it?), so customer might miss that your email belongs to my service.
>> Any given email address can only be verified a certain number of times each month.
> How many times?
Currently 10. It's a mostly arbitrary number intended to be enough for adding simple authentication to things like family photo albums, where infrequent logins and longlived tokens are more acceptable.
>> If you subscribe to emauth pro for $4/month, you can make 512 verifications per month
> 512 verifications for $4/month is a big ask. Auth0 and Firebase have bigger free tiers, not 100% sure though.
512 is a complete shot in the dark. The unfortunate truth is there's no way to get a feel for a good number until you measure usage and/or get feedback. And no one is going to give you feedback until you hit the front page so...
>> If you need more verifications than this (for example if you want to use emauth for a public app with many users), please contact sales at sales ...
> Before you start enterprise sales, some options which are bigger than 512 would be great and I am also not sure if this type of smaller service would justify any enterprise sales. However, let us know if anyone contacted you for some enterprise-y deals.
Don't disagree. But I have no data to make tiering decisions from and wanted to have at least some paid option right away.
>> Also, in order to protect the email sender reputation for emauth, we aggressively blacklist ip addresses that repeatedly make requests to invalid email addresses.
> Btw, this won't help OPs email reputation, just few dozens of bounces are required to get your domain on many blacklists.
That's good to know, thanks.
> Integrating something like your service is easy but building processes around creates a light lock-in and getting the stuff out again is some work. Looking at your landing page which I like because it's light and subtle, it still gives the feeling that it's hobby project and nobody knows if you are still on the market next month or next year.
I'm no fan of vendor lock-in, believe me. I never would have made this if I didn't need it for my other products and services. Worst case maybe the free tier is useful for a few people. The service is trivial enough that you can implement your own fairly easily. I'm sure it's already been implemented a million times. And if it comes down to me no longer being able to run the service for some reason, I'll open source it.
> No custom domain possible (or is it?), so customer might miss that your email belongs to my service.
Not currently. You can customize the email text a bit to make it clear where the email originated from.
We developed it for a website that needed (simple) authenticated access for a read-only website, but we didn’t want to store the (hashed) passwords.
Additional features:
- email addresses for the whitelist can be stored as keyed hashes with the key provided at run-time. This way the whitelist is not on on disk in plaintext.
- Adminstration of the whitelist is done by email: upon entry of an unknown email address, the administrator gets an email with a link with which the new entry can be approved or denied.
- Kiosk-mode: user enters e-mail address on laptop, receives link on mobile, clicks link on link in mobile browser. Server detects that it is a different browser, gives user the option to login on session on laptop (for one day) or for session in mobile browser. Useful for giving demos.
In general: links will get followed, javascript will be executed, buttons will get clicked, and subsequent links will be spidered too.