Earlier quoted context omitted.
Could you clarify why (or when) to use bearer tokens instead of Basic Authentication (i.e. sending username and password) with every request? Is it that if the server is compromised, only passwords from future logins can be stolen rather than those of everyone who performs a request? The cost of checking the hash? Other reasons?
The purpose of a password is to have an authenticator that is human-readable/writeable and, ideally, human-memorable. Ideally, a strong password is stored only in a person's head; in the very worst (and unfortunately common) case, it's also stored in a password manager. API authentication doesn't have the memorability problem, because the password has to be stored somewhere the client program can reach it. But, as yo…
Ask HN: What's the recommended method of adding authentication to a REST API?
231–240 of 254 posts
Re: Ask HN: What's the recommended method of adding authentication to a REST API?
#232Earlier quoted context omitted.
The AWS API runs over TLS, and uses signed requests.
Perhaps because it was originally designed for use without TLS? Request signing was pretty much ubiquitous 10 years ago.
Re: Ask HN: What's the recommended method of adding authentication to a REST API?
#233This question comes up all the time on HN. I'm one of a bunch of people on HN that do this kind of work professionally. Here's a recent comment on a recent story about it: https://news.ycombinator.com/item?id=16006394 The short answer is: don't overthink it. Do the simplest thing that will work: use 16+ byte random keys read from /dev/urandom and stored in a database. The cool-kid name for this is "bearer tokens". Yo…
I like your "keep it simple" approach here. Can you confirm re: your recommendation for random "bearer token" auth, are you talking about just short-lived tokens that are the response to a regular user auth flow (ie login in one request, get a token, use that for subsequent requests in this "session" ala a session cookie) or do you (also) intend it for long-lived tokens used eg for machine accounts?
Re: Ask HN: What's the recommended method of adding authentication to a REST API?
#234Earlier quoted context omitted.
The purpose of a password is to have an authenticator that is human-readable/writeable and, ideally, human-memorable. Ideally, a strong password is stored only in a person's head; in the very worst (and unfortunately common) case, it's also stored in a password manager. API authentication doesn't have the memorability problem, because the password has to be stored somewhere the client program can reach it. But, as yo…
It was my impression that the token is obtained by supplying username and password to a login API, through which it can also be replaced when it expires. Now it seems that I was wrong. How do you suggest the token be managed?
Re: Ask HN: What's the recommended method of adding authentication to a REST API?
#235Earlier quoted context omitted.
Well, you don’t, so if that’s a requirement you’ve got to do it some other way.
You can rotate the secret to invalidate all tokens.
Re: Ask HN: What's the recommended method of adding authentication to a REST API?
#236Earlier quoted context omitted.
Signed requests are not in general more secure: * The implementation of cryptographic "signing" (really, virtually never signing but rather message authentication) is susceptible to implementation errors. * The concept of signing is susceptible to an entire class of implementation errors falling under the category of "quoting and canonicalization". See: basically every well-known implementation of "signed URLs" for e…
A lot of text for your argument which is x isn't secure. Not very compelling. Signed rest requests ensure that auth tokens can not be leaked as each request is individually signed by a private key. Your extreme example btw is hyperbolic. Providing signing sample code to clients is pretty typical
Re: Ask HN: What's the recommended method of adding authentication to a REST API?
#237Earlier quoted context omitted.
I like your "keep it simple" approach here. Can you confirm re: your recommendation for random "bearer token" auth, are you talking about just short-lived tokens that are the response to a regular user auth flow (ie login in one request, get a token, use that for subsequent requests in this "session" ala a session cookie) or do you (also) intend it for long-lived tokens used eg for machine accounts?
You can use short-lived tokens, or you can use long-lived tokens. A long-lived 128 bit secret is superior to a username/password, for reasons explained elsewhere on the thread. So if your short-term token scheme requires programs to occasionally deploy the root account's password (or really any password that a user had to come up with), it's flawed.
I'm thinking more in terms of deviating from your described solution on storing keys (particularly long term ones), by storing them hashed (and thus require some kind of account identifier prefix in the Bearer token string).
Re: Ask HN: What's the recommended method of adding authentication to a REST API?
#238Earlier quoted context omitted.
> Wait for the email to arrive and follow the retrieval process to get the certificate Is there a reason why the server couldn't send the certificate back to the browser via HTTPS? > You then need a non-trivial amount of work to export the private key and certificate and install it on all of your devices, Would it not be better to just use a different key for each device? That is, repeat steps 1 and 2 for every devic…
A number of the undesirable factors described here (email, 12 month limit) are because that process isnt generating a client certificate for use on a private site, it's generating an S/MIME cert for handling encrypted/signed email.
1. Click on link to sign up for new account on news.ycombinator.com
2. Enter information for the account including a CSR that your browser generates for you
3. Submit the information to the server
4. Server servers another page that confirms account creation and includes the certificate
5. The browser provides a way to import that certificate to a client certificate store it maintains
6. Next time you visit the website, your browser knows to use that client certificate
Registering other browsers would require sending the CSR via the first registered browser and copying the certificate that the server returns to the second browser.
Of course, this would be for websites that don't have a need to verify your identity (like reddit or Hacker News). For banks, or credit cards, there would have to be a way to verify the identity of the person signing up for an account.
Re: Ask HN: What's the recommended method of adding authentication to a REST API?
#239Earlier quoted context omitted.
Cert renewal can be automated the same way letsencrypt does it for instance.
Let's Encrypt validates during each renewal if the server still controls the DNS and/or HTTP endpoint. The point of the limited duration is to ensure that an attacker who got a copy of the certificate, but who doesn't control the DNS or HTTP endpoint, can't keep using it for long. In this case, I don't see any automated check that can verify that the client trying to renew the cert is the original device, so there's…
Re: Ask HN: What's the recommended method of adding authentication to a REST API?
#240Earlier quoted context omitted.
I Found a somewhat interesting solution for this issue. I assume you know what an ssh public/private key is, correct? Well, apparently, there is a way to apply this concept of ssh public key authentication to the HTTP protocol. This technique is referred to as "Mutual Authentication": http://www.cafesoft.com/products/cams/ps/docs32/admin/SSLTLS... Basically, it's 2-way SSL. You use signed SSL certs to authenticate th…
SSL client certs are useful, but they don't fix the problem feared by LandR: like a password, they too can be copied and used by someone who controls the machine.