OpenID身份验证和API访问 [英] OpenID authentication and API access

查看:239
本文介绍了OpenID身份验证和API访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenID身份验证本质上是基于浏览器的。如果我想允许一个OpenID用户对用于替代客户使用API​​认证,有没有一个公认的最佳实践是什么?

OpenID authentication is inherently browser based. If I wanted to allow an OpenID user to authenticate against an API for use in alternative clients, is there an accepted best practice for that?

因此​​,如果用户试图用自己的OpenID登录到一个iPhone应用程序,例如,如何将这项工作?我唯一​​能想到产生某种对他们的API令牌,并得到用户的地方手动输入。这种方法是不是用户友好的。

So if a user tried to log in with their OpenID into an iPhone app, for instance, how would that work? The only thing I can think of generating an API token of some sort for them and get the user to manually enter it somewhere. This approach is not user friendly.

这是该网站如的Basecamp 的工作方式,但它似乎仍然笨重给我。

This is the way sites like Basecamp work, but it still seems clunky to me.

推荐答案

您所看到的问题是不是唯一的OpenID。任何密码认证较少方案可以有这个问题。 OAuth的( http://oauth.net/ )是一种解决方案,它是一个开放的标准,迅速上了很多网站获得牵引力。它是完全独立的用户如何进行身份验证,所以他们的OpenID提供确实的的需要支持,甚至要知道,你的网站(以下简称服务提供商OAuth术语中)被使用OAuth。您的API客户端可以是基于Web的,甚至是本地应用程序!

The problem you're seeing is not unique to OpenID. Any password-less authentication scheme can have this problem. OAuth (http://oauth.net/) is a solution that is an open standard that is quickly gaining traction on a lot of web sites. It is totally independent of how the user authenticates, so their OpenID Provider does not need to support or even be aware that your site (the "service provider" in OAuth terms) is using OAuth. Your API client can be web based or even a local application!

这一过程将是这样的:

角色:


  • 用户:有人谁拥有你的网站的帐户

  • 服务提供商:您的网站,其中有一个需要一些凭据访问的编程API

  • 消费者:在客户端,无论是网络还是本地应用程序,需要访问服务提供商的API

流量:


  1. 的用户是在消费者。他表示,他希望在服务提供商来访问数据。

  2. 用户要么重定向(如果消费者是一个网站)或一个浏览器被弹出(如果消费者是本地应用)和用户看到服务提供商的网站。

  3. 的用户要么已经通过持久的cookie登录到服务提供商,还是用户必须先登录到服务提供商却是(你的情况的OpenID)来完成。

  4. 然后服务提供商要求用户:?消费者(一些消费)要访问您的数据(或我们的API,或其他)是否要批准这个(是/否)

  5. 用户确认,并在浏览器窗口关闭或重定向返回到消费者的网站。

  6. 通过某种OAuth协议魔法,消费者现在有一个秘密的凭证,它可以用于访问API和任何访问用户的私人信息,你只是授权。

显然,我不能在这里包括整个OAuth规范,但你可以从上面看到希望,这应该解决您的问题。 OAuth的图书馆存在,使加入对它的支持很容易。

Obviously I can't include the whole OAuth spec here, but you can see hopefully from the above that this should solve your problem. OAuth libraries exist to make adding support for it easy.

如果你碰巧使用ASP.NET,我建议 HTTP://dotnetopenid.google$c$c.com/ 因为它最近增加的OAuth支持(V3.0测试版1)。

If you happen to be using ASP.NET, I suggest http://dotnetopenid.googlecode.com/ as it recently added OAuth support (v3.0 beta 1).

这篇关于OpenID身份验证和API访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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