AZURE ACS - Windows Live ID - 如何获取经过身份验证的用户的电子邮件和姓名?
以下是场景:
在 AZURE Dev 环境中运行的 MVC 3 应用程序 AZURE ACS 中的身份验证实现方式与此处相同:http://msdn.microsoft.com/en-us/ Library/hh127794.aspx
我正在尝试获取用户名和电子邮件,但我找不到配置“声明规则”的方法,以一种可以获得明文的方式值,相反,我得到了一个似乎已加密的字符串。 那么我可以以明文形式配置规则吗?或者我可以解密返回的值吗? 这有可能吗,还是我在这里看错了。
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
IIRC,将用户的姓名或电子邮件地址作为声明发布是违反 Windows Live 隐私政策的(与 Gmail 或 Yahoo! 不同)。因此,不可能从 Live 获得这些声明(除非您恰好是 Microsoft)。
您可以获得的唯一值称为名称标识符。它对于每个 RP 域都是唯一的(即它不是每个 LiveID 的单个值,而是因域而异)。这也是故意的,这样您就无法让不同的网站协作跟踪用户。通常,您会获取名称标识符(称为 PUID),然后将其粘贴到数据库中的某个位置,这样您就知道您以前见过它。然后,用户使用姓名、电子邮件等在您这边注册,然后您将其与 PUID 关联起来。
另一方面,LiveId 还支持 OAuth2,因此您可以从用户那里获取您需要的任何用户个人资料信息(在他/她同意的情况下)。请参阅此处。
IIRC, it is against Windows Live privacy policy to release the user's name or email address as claims (unlike Gmail or Yahoo!). As such, it is not possible to get those claims from Live (unless you happen to be Microsoft).
The only value you can get is called a name identifier. It is unique per RP domain (i.e. it is not a single value per LiveID, but differs by domain). This is also intentional so that you cannot have different websites collaborating to track a user. Typically, you would get the name identifier (called a PUID) and then stick that in your database somewhere so you know that you have seen it before. Then the user registers on your side with name, email, etc. and you correlate that with the PUID.
On the other hand, LiveId also supports OAuth2, so you can get whatever user profile information you need from the user (with his/her consent). See here.
这完全是 Microsoft 的#FAIL。用户在使用 Google 或其他提供商登录您的网站时,必须首先接受。然后他们只需将基本信息传递给网站,网站使用它,每个人都很高兴。
顺便说一句,您可以通过幕后代码页从用户那里获取它,但这对用户来说并不是无缝的,需要手动过程,但尽管如此,LiveID 系统执行此操作并不更安全,它只是被破坏了。
This is a total #FAIL on the part of Microsoft. The users, when logging into your site using Google or other providers, they have to accept first. Then they simply pass the basic information to the site, the site uses it, and everyone is happy.
BTW you can get it from the user with behind-the-scenes code pages but it's not seamless for the user, requires a manual process, but nonetheless the LiveID system is not more secure for doing this, it's simply broken.
可能,但它需要一些自定义 sts 的代码:
https://gist.github.com/1867792
代码不会构建,也不包含依赖项...但它很大程度上基于移植到 MVC4 的早期 thinktecture 入门站点,并进行了如上所示的更改。
Possible but it requires a bit of code for a custom sts:
https://gist.github.com/1867792
Code doesn't build and dependencies aren't included... but it's largely based off an early thinktecture starter site ported to MVC4 with changes shown above.
此博客讨论创建自定义 Windows Live STS 提供程序,然后将其合并为 SharePoint 中的可信身份提供程序。
http://blogs.technet.com/b/speschka/archive/2012/03/01/finally-a-useful-way-to-federate-with-windows-live-and-sharepoint- 2010-using-oauth-and-saml.aspx
不幸的是,Azure 团队似乎并不明白人们可能想从 windows live 中实际获得一些有用的东西 ID。
您还可以通过在身份提供程序中单击 Windows Live ID 作为登录选项,然后取消选中与您的依赖方的关联,将其删除。
(真的很奇怪,你不能选择删除它=P)
This blog discusses creating a custom windows live STS provider and then incorporating it as a trusted identity provider in SharePoint.
http://blogs.technet.com/b/speschka/archive/2012/03/01/finally-a-useful-way-to-federate-with-windows-live-and-sharepoint-2010-using-oauth-and-saml.aspx
Unfortunately it seems like the Azure team just don't seem to understand that people may want to actually get something useful back from windows live id.
You can also remove windows live Id as an option for sign on by clicking on it in the Identity providers, and then un-checking the association with your relying party.
(Really weird that you can't choose to delete it =P)
有几种技术可以查询实时服务器以获取有关经过身份验证的用户的附加信息(当然前提是他们已同意)。您可以使用一些客户端 JavaScript 对站点进行一些简单的自定义,以获取信息,如以下示例所示:http://msdn.microsoft.com/en-us/library/live/hh826534.aspx。
尽管涉及更多一些,也可以从服务器端代码查询实时服务器。 http://dominicbetts.github.io/waad-acs- 中描述的示例应用程序example/index.html 显示了 MVC4 应用程序中的一种可能方法。
There are a couple of techniques for querying the Live servers for additional information about authenticated users (provided of course that they have given consent). You can do some simple customization to your site using some client side javascript to fetch the information as shown in the example here: http://msdn.microsoft.com/en-us/library/live/hh826534.aspx.
It's also possible, although a bit more involved, to query the Live servers from your server side code. The example application described at http://dominicbetts.github.io/waad-acs-sample/index.html shows one possible approach in an MVC4 application.
似乎有一种方法,有点复杂,但是通过成为经纪人并使用实时连接 API,您可以实现此功能。
请参阅:http://code.msdn.microsoft。 com/windowsazure/Get-Azure-ACS-work-40d588cc#content
There seems to be a way, a bit convoluted, but by becoming the broker and using live connect API, you can achieve this functionality.
Please see: http://code.msdn.microsoft.com/windowsazure/Get-Azure-ACS-work-40d588cc#content
它可以通过 iFrame Trick 实现。
这不会将您重定向到 MSN 页面
Its possible by iFrame Trick.
this wont redirect you to MSN page