可以将OpenID与WCF一起使用而不使用浏览器,这可能吗? [英] Using OpenID with WCF and no browser, is it possible?

查看:89
本文介绍了可以将OpenID与WCF一起使用而不使用浏览器,这可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我对OpenID所做的大部分阅读中,看来可能需要使用浏览器.我正在编写WCF应用程序,并希望使用OpenID作为身份验证方法,但是我的应用程序不是Web应用程序.是否可以在不需要Web浏览器的情况下一起使用WCF和OpenID?

From most of the reading I've done on OpenID, it seems a browser may be required. I'm writing a WCF app and wanted to use OpenID as the authentication method, but my app is not a web app. Is it possible to use WCF and OpenID together without requiring a web browser?

推荐答案

虽然OpenID可以声称其规范与cookie无关,但是因为规范实际上并没有规定如何使用这些东西,实际上我从未见过一个很好的OpenID解决方案,除了登录网站(这实际上是其主要用例)之外,它还可以用于其他任何事情.

While OpenID can tout in its spec independence from cookies and such because the spec doesn't actually mandate how those things are used, in reality I've never seen a good OpenID solution for anything besides logging into a web site, which is really its primary use case.

但是,有一个好的方法仍然可以使用WCF和OpenID.将OAuth添加到组合中. DotNetOpenAuth 库中有一个示例,该示例显示WCF客户端如何通过OAuth获得授权以调用WCF服务.在服务端,用户使用OpenID登录作为授权过程的一部分.

However there is a good way to go and still use WCF and OpenID. Add OAuth to the mix. The DotNetOpenAuth library has a sample that shows how a WCF client can get authorized to call a WCF service via OAuth, where at the service-side the user uses OpenID to log in as part of the authorization process.

因此,基本上,如果您的WCF应用需要登录"以调用WCF服务(作为一次性设置的一部分):

So basically if you WCF app needs to "log in" in order to call the WCF service, as part of a one-time setup:

  1. 该应用程序弹出一个浏览器,用户可以在其中浏览WCF服务网站(OAuth服务提供商)
  2. 用户使用其OpenID登录(尽管用户可能已经登录,在这种情况下,他们可以跳过此步骤)
  3. OAuth SP询问用户您是否要授权此[wcf应用程序]访问该网站?"
  4. 用户说是,然后关闭浏览器.
  5. 借助OAuth协议,WCF应用现在可以访问WCF服务了.

之所以起作用,是因为在后台,当用户通过Web浏览器对服务说是"时,会为WCF应用程序分配一个特殊的机器友好凭据,该凭据将以类似的方式与每个WCF服务调用一起使用.用户名/密码就是这样.

This works because behind the scenes, when the user says "yes" to the service through the web browser, a special machine-friendly credential is assigned to the WCF app, which it uses with every WCF service call the a similar way a username/password would be.

检出DotNetOpenAuth库.它包含示例,以及完成此工作所需的一切.

Check out the DotNetOpenAuth library. It has the sample and everything you should need to get this working.

这篇关于可以将OpenID与WCF一起使用而不使用浏览器,这可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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