Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restful API authentication recommendation?

I am developing several RESTful API for 3rd party to call, and these API need authentication (apikey & secret based), and authorization (HTTP method & URI based).

Are there any existing software we can reuse that prevent me from rolling out our own implementation for the security layer?

like image 821
Howard Avatar asked Aug 20 '10 13:08

Howard


People also ask

How do you provide authentication for Restful web services?

Specifying Basic Authentication in a Web RequestThe string "Basic " is added to the Authorization header of the request. The username and password are combined into a string with the format "username:password", which is then base64 encoded and added to the Authorization header of the request.

Which three authentication mechanisms are used in rest APIs?

We'll highlight three major methods of adding security to an API — HTTP Basic Auth, API Keys, and OAuth.


1 Answers

HTTP gives you granted support for that, so you don't need to reinvent the wheel

Either use:

  • HTTP Auth Basic (with SSL to bypass plain-text password submit problem)
  • HTTP Auth Digest

Auth Digest has advantage, that it does not transmit the passowrd in cleartext and handles replay attacks (with nonces).

We use HTTP Auth Digest (Tomcat servlet container has direct support for it) and we are content with it.

EDIT: Some clients have problems with Digest (not so trivial), so these days I would opt for Basic and SSL. Advantage for Basic is also that you can you preemptive authentication (sending user:pwd in first request).

like image 116
manuel aldana Avatar answered Oct 14 '22 04:10

manuel aldana