views:

23

answers:

1

I've got a web API that provides data to users without authentication (the website lets users post data, after they've logged in using traditional cookies & sessions). Someone wants to develop an iPhone app that adds things to my database, so I want a user to authenticate on the iPhone, and then the api will allow posting.

So, what should I look in to do this easily? The API as it stands is RESTful, it'd be nice to keep it that way. Obviously I'm new to this but there seem to be so many standards I don't know where to start. If I can code it up in less than an hour, that'd be ideal.

Much appreciated!

+1  A: 

A decent way to implement this would be to provide the app creator with a token as well as an app id, and have them use that token as salt for an agreed upon encryption method to send username and password (plus app id) to a new API call for a new session.

Upon receiving the request for a new session, you would look up their token based on the appid provided, and try and decrypt the user/pass using the token.

If the user/pass are accepted, then you create a new session and return the session id to them, which they can send along with any new requests.

This prevents the app from having to send authentication for every request, and allows you to expire sessions at a given time.

cmendoza
Quick question though, if someone got the encrypted user/pass with token, they could pretend to be the user, right?Is the only way to prevent this sort of info being sent in the clear, to use SSL?
Jasie
Generally, yes you would want to use SSL.
cmendoza