如何在iPhone原生应用上使用单点登录?

发布于 2024-09-28 12:47:14 字数 58 浏览 2 评论 0原文

我正在开发一个使用单点登录的网络应用程序的移动版本。如何在本机 iPhone 应用程序上使用单点登录?

I'm developing a mobile version of a web app that uses single signon. How do I use Single sign-on on native iPhone app?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等风来 2024-10-05 12:47:14

“单点登录”一词可能意味着很多不同的事情,但以下是我在我构建的应用程序上处理用户身份验证的方式。

首先,如果我以前从未见过他们,我会要求他们登录或注册(稍后会详细介绍)。一旦他们这样做了,我就会在网络应用程序上生成一个魔法令牌并将其与他们的用户记录一起存储。我将该令​​牌作为登录/注册请求的 HTTP 响应的一部分返回,并将其存储在 NSUserDefaults 中。

从那时起,我为每个请求提供该令牌,并使用它来对用户进行身份验证。如果他们在没有有效令牌的情况下向我提交任何内容,我会通过登录/注册将其退回。

不会在应用程序启动之间删除它。当你稍后回到我身边时,你仍然是你,除非你点击“退出”按钮。

我还可以让您通过这种方式从网络应用程序中注销手机,只需从用户数据库中删除身份验证令牌即可。

现在(稍后再说)我听说苹果拒绝应用程序,因为它们需要用户预先注册。这还没有成为一个普遍存在的事情,所以我怀疑这只是一个昙花一现,但它确实存在,这是一个风险。

The term "single sign-on" could mean a whole lot of different things, but here's how I handle user authentication on the apps I've been building.

First thing, if I've never seen them before, I require them to log in or register (more on that in a sec). Once they do that, on the web app, I generate a magic token and store it with their user record. I return that token as part of the HTTP response of the login/registration request, and I store it in NSUserDefaults.

From then on, I supply that token with every request, and use it to auth the user. If they ever submit anything to me without a valid token, I bounce them back through login/registration.

I don't delete it between launches of the app. When you come back to me later, you're still you unless you hit the "log out" button.

I can also let you log your phone out from the web app this way, just by zapping the auth token from the user database.

Now (this is the more later) I've been hearing about Apple rejecting apps because they require user registration up front. That hasn't become a big widespread thing, so I suspect it was just a blip, but there it is, it's a risk.

怪我鬧 2024-10-05 12:47:14

您基本上希望保存凭据,然后在任何身份验证质询需要时将它们提供给请求。

http://iosdevelopertips.com/networking/ Handling-url-authentication-challenges-accessing-password-protected-servers.html

我实际上编写了一个 PhoneGap 插件来包装大量登录/身份验证功能

http://blog.clearlyinnovative.com/post/1012434483/phonegap-and-iphone-development

You basically want to save the credentials and then provide them to the request when needed by any authentication challenge.

http://iosdevelopertips.com/networking/handling-url-authentication-challenges-accessing-password-protected-servers.html

I actually wrote a PhoneGap plugin to wrap abunch of login/authentication functionality

http://blog.clearlyinnovative.com/post/1012434483/phonegap-and-iphone-development

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文