加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 将成为iPhone应用程序后端的Rails3应用程序的

发布时间:2020-12-17 03:01:10 所属栏目:百科 来源:网络整理
导读:我想开始研究我对iPhone应用程序的想法,但是我有一些关于从哪里开始的问题.我希望该应用程序主要用于iPhone,但在网络应用程序上有一些功能,如登录和查看从iPhone应用程序创建的东西.我已经开始使用rails3应用程序,并希望将其用作api / app的后端. 我对如何使
我想开始研究我对iPhone应用程序的想法,但是我有一些关于从哪里开始的问题.我希望该应用程序主要用于iPhone,但在网络应用程序上有一些功能,如登录和查看从iPhone应用程序创建的东西.我已经开始使用rails3应用程序,并希望将其用作api / app的后端.

我对如何使用身份验证系统感到困惑,以便此应用程序可以作为Web应用程序和iphone应用程序的api工作.

我想在网络和iphone应用程序上使用omniauth登录,因为我只希望用户使用twitter和/或fb登录,但我不知道如何在用户登录iPhone应用程序后验证请求.我知道像设计这样的其他一些宝石允许像api key authenticatable这样的东西,这使得签名api调用变得更容易,但我认为它太过于使用了auth系统.

任何人都可以给我建议如何制作一个既可以作为webapp使用也可以使用iphone通过api进行身份验证的身份验证系统.

谢谢!

解决方法

一些想法……

我会假设iOS应用程序的行为类似于Web浏览器,并像正常一样发送持久性cookie以及每个请求.通过这种方式,您可以使用标准身份验证实践,并且可以让自己开放一天发布基于Web的应用程序版本,而无需对所有内容进行大修.

所以工作流程将是:

  • Get authentication information from user input and save securely in the Keychain to seamlessly log them in every time they open the app
  • Use something like Devise to do the Rails server-side authentication (i.e. don’t reinvent the wheel)
  • POST the data to the server to create a new session
  • Receive the session information back from the server in the form of a cookie
  • Store the cookie in the iOS app
  • Send the cookie information back to the server with every request
  • If they log out,destroy the cookie and the keychain data you stored to create the cookie every time they opened the app

NSURLConnection提供了一种方法来完成大部分工作,甚至可以发送任何存储的cookie以及请求,只要您不告诉它.这是一篇陈旧的帖子,谈论其中一些:Objective-C Asynchronous Web Request with Cookies

一些资源可以帮助您:

>获取/存储/发送cookie:http://www.calaresu.eu/2011/06/01/using-cookies-with-cocoa-nshttpcookie/
>关于带有Rails的iPhone的好幻灯片:http://www.slideshare.net/maximeguilbot/rails-as-ios-application-backend
>适用于在iOS上的Keychain中存储身份验证信息:https://github.com/ldandersen/scifihifi-iphone
>与Rails应用交谈:http://restkit.org/(和here’s a rails example)

希望有所帮助!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读