Require your clients to perform some amount of computation to do a request.
Something like this: https://www.npmjs.com/package/work-token
Require your clients to perform some amount of computation to do a request.
Something like this: https://www.npmjs.com/package/work-token
* native code can almost certainly run faster than javascript code, even if you're using webassembly. in my experience js cryptominers operate at around half the speed compared to their native counterpart on the same machine
* the attacker can leverage GPUs to compute solutions hundreds of times faster than what your users can
* users have to wait 30 seconds before they can login. you can generate the key while the user's filling in the form to shave off a few perceived seconds, but that will result in a sluggish login form
* users with slow CPUs (ie. anything slower than what's in a c5.large) will take even longer to generate a solution. this is especially problematic for people on smartphones
* users might think that your site's high CPU usage is because you're running a cryptominer on your site!
What if you write it in Electron though?
If your attacker isn't even paying for the resources they use, such as from botnets or borrowed, then your attack value has gone out of the window. If the indivdual attack is free to the attacker, then you're left with time. PoW guarantees a time value. If a single PoW is too cheap, then ask for more values.
Someone who wishes just to abuse your API with no intention to actually log in will just flood you with reams of requests to obtain new work tokens without executing any of them.
So you're back to regular rate limiting, etc.
https://github.com/tinspin/rupy/blob/master/src/se/rupy/http...
It's secure and solves this problem too.
So it solves this problem AND it's secure! No brainer.
But you can keep using HTTPS if you want.