I know this is a popular type of question, but I haven't been able to find any other questions that address my specific needs.
! Skip to the end for the question if you are losing interest :) !
Idea 1:
*Idea 2: (single use API_Token)*
I believe there is no perfect UUID solution for iOS any longer. If the UUID can change over time (or if the user has multiple iOS devices), an authentication problem can occur.
If a hacker gets an API key, I don't want them to be able to access the data (hence the expiry or new token idea).
What suggestion do you have to create a secure API between Rails and iOS?
EDIT 1:
I'm still surprised this isn't something that comes up all the time. There must be a ton of apps out there that communicate to an API but do not force user's to sign up. If SSL or OAuth is the only proper solution, please defend. I'm all ears.
Aside from the problem of tracking users across devices, for which I wouldn't know how to provide a reasonably simple and reliable mechanism, other than a Game Center account, let's discuss a simple way of closing your API to other apps.
The handshake would involve your client submitting a URL request that could already include a device-specific token to identify your user. The response from your server will be a random one-time challenge in form of a string. Both the client and the server know a non-trivial function that generates a response string as a function of the challenge and possibly the user token, thus validating the client.
The mechanism is by no means secure but is trivial to implement and will provide some barrier to others. You should definitely validate the form of the user token for some additional protection. For example, if your token is a MAC address, the request must have the form of a MAC address.
I ended up rolling my own solution based on a few suggestions that I found on the web (see reference links at the end).
This GitHub Gist by @keighl is what started me off, by far the best example that I found: https://gist.github.com/4336694
Railscast: Securing an API: http://railscasts.com/episodes/352-securing-an-api
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With