如何在MVC 4中实现自定义OpenID依赖方 [英] How to implement custom OpenID Relying Party in MVC 4
问题描述
我喜欢新的MVC OpenID/OAuth登录功能,但是我想知道如何添加一个新的登录按钮,例如,我希望我的用户使用他们的StackExchange帐户或使用他们的OpenID url(与stackoverflow中的相同)进行登录 http://puu.sh/13rm0
I like the new MVC OpenID/OAuth login feature, but I want to know how to add a new login button, for example I want my users to login using their StackExchange account or using their OpenID url the same as in stackoverflow http://puu.sh/13rm0
该怎么做?有没有逐步显示此示例的示例?
How to do that? Are there any samples showing this in steps?
推荐答案
不幸的是,Microsoft公开的API仅限于硬编码到特定URL的登录提供程序,而不是可以在登录之前接受用户输入的登录提供程序.用户,这是OpenID所需的.
Unfortunately the API Microsoft exposes is limited to login providers that are hard-coded to a specific URL -- not one that can accept input from the user before logging the user in, which OpenID requires.
您可以通过创建实现DotNetOpenAuth.AspNet.IAuthenticationClient
并被硬编码为使用StackExchange的类来添加对特定OpenID提供程序(例如StackExchange)的支持.一个很好的例子是 Microsoft自己的提供程序的源代码雅虎!.进行检查,看看它有多简单,然后创建简单地硬编码为https://openid.stackexchange.com/
而不是https://me.yahoo.com/
的自己的文件,并且您已获得StackExchange登录支持.
You can add support for specific OpenID providers such as StackExchange by creating a class that implements DotNetOpenAuth.AspNet.IAuthenticationClient
and is hard-coded to use StackExchange. A great example of this is the source code for Microsoft's own provider for Yahoo!. Check it out, see how simple it is, then create your own that is simply hard-coded to https://openid.stackexchange.com/
instead of https://me.yahoo.com/
and you've got StackExchange login support.
这篇关于如何在MVC 4中实现自定义OpenID依赖方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!