Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP basic authentication over SSL for REST API

I am new to the concept of RESTful API's.

I am designing a RESTful API for an online store.

I have not properly understood the concept of basic HTTP authentication over SSL.

Does it mean that for every request the user will have to enter his/her username and password again?

Can somebody explain in detail how it functions and how it is meant to be used?

like image 221
Kanishk Dudeja Avatar asked Oct 12 '13 09:10

Kanishk Dudeja


People also ask

What type of authentication should I use for REST API?

OAuth (specifically, OAuth 2.0) is considered a gold standard when it comes to REST API authentication, especially in enterprise scenarios involving sophisticated web and mobile applications.

Does basic auth require SSL?

yes. if you're using https the conversation with the web server is entirely encrypted.

Is Basic Auth safe over HTTPS?

Note: The HTTP basic authentication scheme can be considered secure only when the connection between the web client and the server is secure. If the connection is insecure, the scheme does not provide sufficient security to prevent unauthorized users from discovering the authentication information for a server.


1 Answers

Basic authentification is just a standard HTTP header with the user and pass encoded in base64 :

Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

(http://en.wikipedia.org/wiki/Basic_access_authentication) .If you authenticate your rest API calls by this header over a non ssl conection, the problem is that any man in the middle can decode your username and password from your auth header.

To make sure that your password is sent securely , instead of a normal HTTP connection you must use HTTPS . The only difference between HTTP and HTTPS is that HTTPS is using the SSL/TSL security protocol over TCP/IP instead of plain TCP/IP.

Now this has the drawback that establishing a HTTPS connection is more expensive on the cpu than normal HTTP connection. It is very clear that If you want to authenticate your rest calls on every request with this header you should make your rest API only available to HTTPS connections.

like image 99
Ovidiu Buligan Avatar answered Sep 28 '22 13:09

Ovidiu Buligan