OpenID +用于 Web 应用程序和桌面/移动应用程序身份验证和授权的 OAuth
我想使用 OpenID 对我的 web 应用程序上的用户进行身份验证 - 类似于 StackExchange 的做法。我还希望网站的用户能够使用同一帐户使用我的桌面和移动应用程序。我读过这需要 OAuth(OpenID 纯粹是网站)。
我不知道
- 这是正确的方法吗?
- 其工作流程是什么?
- 每个用户/OpenID 的数据库中需要哪些数据?我是否存储一个“帐户”,然后当他们使用 OpenID 进行身份验证时,我允许他们为移动应用程序生成 OAuth 令牌?
在理想的情况下,我将能够拥有类似于 https://stackoverflow.com/users/login 上的按钮我的 Web 应用程序以及我的桌面和移动应用程序都允许用户使用他们的 google 或 facebook 帐户登录,这可能吗?对用户而言,简单性至关重要,因为我的用户群无法接受任何复杂的东西。
我可以使用 DotNetOpenAuth 之类的东西来提供所有这些功能吗?
更好的解决方案是打破这种情况并允许用户使用 OpenID 对我的网站进行身份验证,然后我为我的桌面和移动客户端提供自己的 OAuth 方案吗?
I'd like to use OpenID to authenticate users on my webapp -- similar to how StackExchange does it. I'd also like to enable users of my website to use my Desktop and Mobile Apps using the same account. I've read this requires OAuth (OpenID is purely website only).
What I don't know is
- Is this the correct approach?
- What would the workflow for this be?
- What data do I need in my database per user/OpenID? Do I store an "account" and then when they've authenticated with OpenID, I allow them to generate an OAuth Token for the mobile app?
In an ideal world, I would be able to have buttons similar to those on https://stackoverflow.com/users/login for both my WebApp and also in my Desktop and Mobile Apps which would simply allow users to login with their google or facebook account, is that possible? Simplicity for users is paramount, because my userbase will not take well anything remotely complex.
Can I use something like DotNetOpenAuth to provide all of this functionality?
Would a better solution be to break this up and allow users to authenticate to my site with OpenID and then I provide my own OAuth scheme for my desktop and mobile clients?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最简单的机制可能是嵌入 Web 视图,然后简单地监视到特定回调页面的导航并以这种方式获取身份验证数据。您应该仍然可以使用 OpenID 来实现此目的。
Probably the simplest mechanism is to embed a web view, and simply watch for navigation to a specific callback page and grab the authentication data that way. You should still be able to use OpenID for this.
您应该关注的是 Windows 身份框架 (WIF),它对于使用基于声明的身份的 Web 或桌面应用程序的工作方式类似。您将为每个用户存储一个授权令牌(以及您需要的任何其他信息),并且您可以在经过身份验证的 HTTP 请求的授权标头中获取它。 oAuth 是用于传递授权请求和响应的协议。 WIF 是一个用于简化此交互的 .NET 工具包。
有关详细信息,请查看 WIF 主页和以下博客(不是我的):
http: //msdn.microsoft.com/en-us/security/aa570351
http://blogs.msdn.com/b/vbertocci/
What you should be looking into is Windows Identity Framework (WIF), it will work similarly for Web or Desktop applications using Claims-Based Identity. You would store an authorization token for each user (along with any other information you need) and you would get it in the Authorization Header of an authenticated HTTP Request. oAuth is the protocol for passing authorization requests and responses. WIF is a .NET toolkit to simplify this interaction.
For more info, check out the WIF home page and the following blog (not mine):
http://msdn.microsoft.com/en-us/security/aa570351
http://blogs.msdn.com/b/vbertocci/
这是我想出的工作流程,到目前为止我认为它运作良好。
用户需要通过第三方 OpenID/Facebook/等对网站进行身份验证(移动设备友好的网站可用)。然后,在他们的“配置文件”中,他们可以生成一个 API“密钥”,他们可以将其复制/粘贴到他们的客户端软件中。它对用户来说并不是 100% 透明,但它相当不错。
This is the workflow that I came up with, and so far I think its working well.
The user is required to authenticate to the website via third party OpenID/Facebook/etc (mobile friendly website is available). Then, in their "profile" they can generate an API "key" which they can copy/paste into their client software. It isn't 100% transparent to the user, but its pretty good.