Question

I've built a Rails app with a simple API. I'm using Devise for authentication. I'm trying to work out how to log a user into the rails app from my iOS app so they can retrieve and post data. I've been searching all day for the best way to do this but most info is outdated (using Devise's deprecated token_authenticable solution.

I've got my rails app. I've got my iOS app. I've written my API. How do I connect the pieces together?

Thanks

Details:

My app allows users to fill in a form and have that data sent to the server. In another section of the app the user can view the data they have previously submitted. When the app first launches the user should login to their account so that the data they post is associated with them and they can only view data they have previously posted. It's quite a simple app. How do I log them in so that I can tell the API to only return their data.

Was it helpful?

Solution

Set your server up to use SSL, then the communication to the server are secure. Post the userID and password to the server in an SSL. You can pass that information on each access to the server.

If you want to pass the UserID/Password only once then you can setup a session with a cookie but you will need server support for the session and timeouts.

What you need to define is how secure you want the authentication to be. That is who are you defending against? A friend, an enemy, a government? Define the value (in $) of a security breach. Defend to this level.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top