I just read this article that is a few years old but describes a clever way of securing your REST APIs. Essentially:
- Each client has a unique public/private key pair
- Only the client and the server know the private key; it is never sent over the wire
- With each request, the client takes several inputs (the entire request itself, the current timestamp, and the private key) and runs them through an HMAC function to produce a hash of the request
- The client then sends the normal request (which contains the public key) and the hash to the server
- The server looks up the client's private key (based on the provided public key) and does some timestamp check (that admittedly I don't understand) that verifies the request is not a victim of a replay attack
- If all is well, then the server uses the private key and the same HMAC function to generate its own hash of the request
- The server then compares both hashes (the one sent by the client as well as the one it generated); if they match, the request is authenticated and allowed to proceed
I then stumbled across JWT, which sounds very similar. However the first article does not mention JWT at all, and so I am wondering if JWT is different than the above auth solution, and if so, how.