News for hackers. Stuff that matters.
Re:Secure Your REST API by redblacktree on Wednesday April 17, 2013 @03:20PM (#5566471)
Even if you use HTTPS, aren't you vulnerable to lazy devs who put the password in the URL?

If I use https://username:[email protected]/, doesn't that URL show up in server logs all over the internet?

Re:Secure Your REST API by tptacek on Wednesday April 17, 2013 @03:21PM (#5566478)
Don't ever use passwords for API authentication. It's an API, not a browser. The users of an API are other programs, not people. Issue single-purpose random credentials.

I didn't think this was something I had to point out about API authentication, but apparently it is.

Re:Secure Your REST API by CodeMage on Wednesday April 17, 2013 @04:52PM (#5567144)
I have a stupid question: how do you do this with HTTP Basic auth?
Re:Secure Your REST API by tptacek on Wednesday April 17, 2013 @05:01PM (#5567225)
Generate random long passwords.
Re:Secure Your REST API by redblacktree on Thursday April 18, 2013 @12:55PM (#5571669)
By "don't ever use passwords" you mean, "don't let users set their own passwords," right?

Obviously, you're still using a password if you use HTTP Basic Auth.

Re:Secure Your REST API by lhazlewood on Wednesday April 17, 2013 @03:44PM (#5566631)
You shouldn't ever use username/password pairs for API authentication. If the user ever changed their password, then their API calls would immediately fail!

This is one of many benefits of using multiple (revokable) API Keys.

Re:Secure Your REST API by jimktrains2 on Wednesday April 17, 2013 @03:34PM (#5566568)
No. The UA strips those and puts them in an Auth header.
Re:Secure Your REST API by lhazlewood on Wednesday April 17, 2013 @03:40PM (#5566603)
Depends on the UA (curl?)
Re:Secure Your REST API by jimktrains2 on Wednesday April 17, 2013 @10:57PM (#5568697)
OK, so it'll either add an auth header or not know what to do and refuse to do anything. Either way the password is not sent in the request url
Re:Secure Your REST API by jimktrains2 on Thursday April 18, 2013 @09:12AM (#5570374)
Actually, I mused have screwed up last night. The version of curl I have does support it and does put it into the Auth header.

  % curl --trace-ascii /dev/stdout http://jimktrains:[email protected]
  == Info: About to connect() to news.ycombinator.com port 80 (#0)
  == Info:   Trying 184.172.10.74... == Info: connected
  == Info: Server auth using Basic with user 'jimktrains'
  => Send header, 223 bytes (0xdf)
  0000: GET / HTTP/1.1
  0010: Authorization: Basic amlta3RyYWluczpwYXNzd29yZA==
  .......
Some UAs however, do just drop it. Like IE (http://support.microsoft.com/kb/834489)
Re:Secure Your REST API by jes5199 on Wednesday April 17, 2013 @11:45PM (#5568811)
Even curl does the right thing for basic auth
Re:Secure Your REST API by olivier1664 on Wednesday April 17, 2013 @10:22PM (#5568609)
Please correct me if I'm wrong. HTTPS will encrypt the URL, but the DNS lookup is in clear. So the "username:[email protected]" part will be sniffable/loggable.

http://stackoverflow.com/questions/499591/are-https-urls-enc...

Re:Secure Your REST API by jewel on Wednesday April 17, 2013 @11:19PM (#5568748)
That's incorrect. The URI library will parse the URL into a hostname, username, and password. Only the hostname is sent to the DNS server.

The username and password are sent in the "Authorization" HTTP header, which will be encrypted.