Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I authenticate user in REST web service?

How do I write the method for user authentication in REST web service? I am beginner with web services.

like image 431
sudo Avatar asked Apr 03 '11 07:04

sudo


People also ask

How do I set authentication on REST API?

To add the authentication credentials, click Next. Login—Enter basic authorization user name of the REST API web service. Password—Enter the password of the basic authorization protocol. (Optional) If the REST API web service requires custom headers to establish a connection, in Headers, add the headers and the values.

How do I authenticate a user?

In authentication, the user or computer has to prove its identity to the server or client. Usually, authentication by a server entails the use of a user name and password. Other ways to authenticate can be through cards, retina scans, voice recognition, and fingerprints.

How do I provide authentication in Web API?

Web API assumes that authentication happens in the host. For web-hosting, the host is IIS, which uses HTTP modules for authentication. You can configure your project to use any of the authentication modules built in to IIS or ASP.NET, or write your own HTTP module to perform custom authentication.

How do you pass credentials in REST API?

Application credential requirements The client must create a POST call and pass the user name, password, and authString in the Request headers using the /x-www-form-urlencoded content type. The AR System server then performs the normal authentication mechanisms to validate the credentials.


1 Answers

Authentication itself should be done in a stateless way, so that the REST paradigm is not broken. This means authentication has to occur on every request. this SO question might provide some further details

the esiest method is using HTTP-Basic AUTH (rfc2617) over SSL encrypted connections (https). here are some java examples:

  • ericonjava
  • my blog entry

another method is using nonces so that you dont have to resend the user/pass combo everytime, but they are a bit more challenging:

  • Nonce Usage

there are lots and lots of ways to authenticate users but these 2 are the most often used that dont hold session state on the server side.

hope that helped

like image 73
fasseg Avatar answered Sep 18 '22 05:09

fasseg