IOS认证与DB在线 [英] IOS Authentication with DB online

查看:126
本文介绍了IOS认证与DB在线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建立一个应用程序,需要在一个数据库(在线)的认证。
当应用程序负载,在第一次出现一个登录界面将用户凭据。
正确登录后因此,用户可以访问这个应用程序的每一个领域。

I have to build an App that need authentication over a DB (online). When application load, at first appear a login screen to insert user credentials. Thus after a correct login, user can access every areas of this app.

我觉得用这个步骤,你怎么想?

I think to use this steps, what do you think about?

1)建立接受用户名/密码(隐窝一个PHP(或其他LANG)web服务),并检查这些数据。当用户发现,创建一些奇怪的唯一的字符串并添加过期时间信息的令牌。发送令牌早在响应带有某种JS​​ON结构。

1) Build a PHP (or other lang) Webservice that accept username/password(crypt) and check this data. When user is found, create a token with some strange unique string and adding a expiration time information. Send token back as response with some sort of json structure.

2)的iOS应用程序调用该服务通过用户名/密码,如果web服务的反应是积极的,保存收到的令牌NSUserdefault并添加创建时间(这样我就可以当它过期计算。

2) The IOS APP call this service passing username/password, if the webservice response is positive, store the received token in NSUserdefault and add time of creation (so i can calculate when it expire.

3)从我的程序,我可以向Web服务发送我的令牌请求。 WS检查令牌的有效性,并发送回一个响应。

3) From my APP i can make request toward webservice sending my token. WS checks Token validity and send back a response.

这是一个很好的做法?

Is this a good practice ???

推荐答案

是,也不是。

我觉得你的方法将作为你写的。但请记住,你的用户需要连接互联网,使用您的应用。所以,我在设计它也有对用户使用的结构方式,如果他有没有互联网连接。

I think your approach will work as you wrote it. But keep in mind, that your users needs an internet connection to use your app. So I would design the structure in a way it has also a use for the user, if he has no internet connection.

我不知道你的expirience有多好与Web服务,并与他们沟通。如果你发送的数据,你也应该加密发送的数据,因为他们是用户的凭据。所以它不是保存到它们发送GET作为值例子,一个PHP脚本...

I also don't know how good your expirience is with Webservices and the communication with them. If you send the data, you should also encrypt the sent data, because they are the credentials of the user. So it's not save to send them as GET Values for examples in a PHP script...

我希望我的回答确实有点帮助。如果您对这种类型的web服务的具体问题,只问。我前几次这样做。 ; - )

I hope my answer did help a little bit. If you have specific questions on this type of webservice, just ask. I did this a few times before. ;-)

桑德罗·迈耶

这篇关于IOS认证与DB在线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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