为Rails3中应用的起点将被后端识别的iPhone应用程序 [英] Starting place for Rails3 App that will be backend of an iphone app

查看:157
本文介绍了为Rails3中应用的起点将被后端识别的iPhone应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始一个想法,我有一个iPhone应用程序的工作,但我有在哪里开始的一些问题。我想应用多用于在iPhone上,但对web应用程序的某些功能,如登录和查看从iPhone应用程序创建的东西。我已经开始了一个Rails3中的应用程序,并想以此作为我的后端的API /应用程序。

I would like to start working on an idea I have for an iphone app, but I am having some issues on where to begin. I would like the app to be mostly used on the iphone but have some functionality on the web app such as logging in and viewing things created from the iphone app. I have started a rails3 app and would like to use this as my backend for the api/app.

我很困惑,我应该如何去与认证系统,使这个应用程序可以工作既作为一个Web应用程序和iPhone应用程序的API。

I am confused as to how I should go about with an authentication system so that this app can work both as a web app and an api for an iphone app.

我想用omniauth有关Web和iPhone应用的登录,因为我只希望用户与Twitter和/或FB登录,但我不知道如何进行身份验证,一旦用户的请求登录到iPhone应用程序。我知道一些其他的宝石一样色器件允许的东西就像一个API密钥可验证列,使签约API调用更容易,但我认为它太臃肿一个身份验证系统来使用。

I want to use omniauth for the login on the web and iphone app because I only want users to login with twitter and/or fb, but I don't know how to authenticate requests once the users is logged into the iPhone app. I know some other gems like devise allow for things like a api key authenticatable column that makes signing api calls easier, but I think its way too bloated of a auth system to use.

谁能给我如何着手做一个认证系统,将工作既作为一个Web应用程序,并与iPhone认证通过一个API时的建议。

Can anyone give me advice on how to go about making an authentication system that will work both as a webapp and when authenticating over an api with an iphone.

谢谢!

推荐答案

的几点思考...

我会假设只是有类似网页浏览器的iOS应用程序的行为,并像正常的每个请求一起发送一个永久性的Cookie。这样,您就可以使用标准认证的做法,也给自己开来释放你的应用程序有一天一个基于网络的版本,而无需大修一切。

I would assume to just have the iOS app act similar to a web browser and send a persistent cookie along with each request like normal. This way, you can use standard authentication practices and also leave yourself open to releasing a web-based version of your app one day without having to overhaul everything.

所以,工作流程将是:


      
  • 从用户输入获取认证信息和安全保存在Keychain无缝地记录他们在每次打开应用程序时

  •   
  • 使用类似设计做Rails的服务器端验证(即不重新发明轮子)

  •   
  • 把数据上传到服务器上创建一个新的会话

  •   
  • 接收会话信息从服务器返回一个cookie的形式

  •   
  • 存储cookie的iOS应用程式

  •   
  • 每个请求发送的cookie信息返回到服务器

  •   
  • 如果他们退出,破坏cookie,并已存储在每次打开应用程序时创建cookie中的数据钥匙扣

  •   

<一个href=\"http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html\">NSURLConnection提供做太多的这样一个手段,只要甚至发送任何存储的cookie与请求一起,你不告诉它不要。这里有一个老这么张贴在谈论一些这样的:<一href=\"http://stackoverflow.com/questions/704985/objective-c-asynchronous-web-request-with-cookies\">Objective-C异步Web请求与饼干

一些资源,以帮助你前进的道路:

A few resources to help you along the way:


  1. 获取/存储/发送的cookie:<一href=\"http://www.calaresu.eu/2011/06/01/using-cookies-with-cocoa-nshttpcookie/\">http://www.calaresu.eu/2011/06/01/using-cookies-with-cocoa-nshttpcookie/

  2. 有关iPhone使用Rails良好的幻灯片:<一href=\"http://www.slideshare.net/maximeguilbot/rails-as-ios-application-backend\">http://www.slideshare.net/maximeguilbot/rails-as-ios-application-backend

  3. 适合存储在Keychain在iOS上验证信息:<一href=\"https://github.com/ldandersen/scifihifi-iphone\">https://github.com/ldandersen/scifihifi-iphone

  4. 与Rails应用程序说到: http://restkit.org/ (和的这里有一个例子轨

  1. Getting / storing / sending cookies: http://www.calaresu.eu/2011/06/01/using-cookies-with-cocoa-nshttpcookie/
  2. Good slideshow about iPhone with Rails: http://www.slideshare.net/maximeguilbot/rails-as-ios-application-backend
  3. Good for storing auth info in the Keychain on iOS: https://github.com/ldandersen/scifihifi-iphone
  4. Talking with the Rails app: http://restkit.org/ (and here's a rails example)

希望帮助一些!

这篇关于为Rails3中应用的起点将被后端识别的iPhone应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆