标签: dotnetopenauth

我可以将OpenId与ASP MembershipProvider一起使用吗?

我有一个ASP.Net 2.0网站,目前正在使用自定义MembershipProvider和标准登录控件.我想用DotNetOpenId替换登录控件.

我重写了验证用户名和密码的ValidateUser,但是在使用OpenId时我不需要实现它.

是否可以使用OpenId并且仍然可以使用成员资格提供程序,以便我仍然可以使用它来访问当前登录的用户?

或者是否需要使用提供者模型?

asp.net openid asp.net-membership membership-provider dotnetopenauth

11
推荐指数
1
解决办法
2001
查看次数

DotNetOpenAuth:邮件签名不正确

尝试使用MyOpenID和Yahoo进行身份验证时,我收到"消息签名不正确"异常.

我几乎使用了DotNetOpenAuth 3.4.2附带的ASP.NET MVC示例代码

public ActionResult Authenticate(string openid)
{
    var openIdRelyingParty = new OpenIdRelyingParty();
    var authenticationResponse = openIdRelyingParty.GetResponse();

    if (authenticationResponse == null)
    {
        // Stage 2: User submitting identifier
        Identifier identifier;

        if (Identifier.TryParse(openid, out identifier))
        {
            var realm = new Realm(Request.Url.Root() + "openid");
            var authenticationRequest = openIdRelyingParty.CreateRequest(openid, realm);
            authenticationRequest.RedirectToProvider();
        }
        else
        {
            return RedirectToAction("login", "home");
        }
    }
    else
    {
        // Stage 3: OpenID provider sending assertion response
        switch (authenticationResponse.Status)
        {
            case AuthenticationStatus.Authenticated:
            {
                // TODO
            }
            case AuthenticationStatus.Failed:
            {
                throw …
Run Code Online (Sandbox Code Playgroud)

openid yahoo asp.net-mvc dotnetopenauth

10
推荐指数
2
解决办法
3374
查看次数

DotNetOpenAuth CTP - Facebook错误请求

我正在尝试使用CTP通过OAuth 2.0与Facebook连接.

我可以得到Facebook的初始请求工作正常,但当它回来时我们打电话:

// Where null will become an HttpRequestInfo object
client.ProcessUserAuthorization(null);
Run Code Online (Sandbox Code Playgroud)

我明白了:

远程服务器返回错误:(400)错误请求.

我对初始代码库没有太多帮助; 只是将可选值设置为null(我们仍然在.NET 3.5上).任何线索将非常感激.

此外,我想这对安德鲁来说更具问题; 是否存在任何此类内容的论坛/博客,或任何可定期更新的内容?了解一些事情会很棒:

  1. 使用OAuth 2.0计划发布DotNetOpenAuth的日期
  2. .NET 4.0是否是先决条件

无论如何,任何建议都是最受欢迎的.

.net facebook dotnetopenauth

10
推荐指数
1
解决办法
6532
查看次数

DotNetOpenAuth获取Facebook电子邮件地址

我有以下代码,其中抓取名/姓.我意识到电子邮件是一个扩展权限,但是我需要修改哪些来请求扩展权限?

如何通过DotNetOpenAuth?获取经过身份验证的Facebook用户的电子邮件?

        fbClient = new FacebookClient
        {
            ClientIdentifier = ConfigurationManager.AppSettings["facebookAppID"],
            ClientSecret = ConfigurationManager.AppSettings["facebookAppSecret"],
        };

        IAuthorizationState authorization = fbClient.ProcessUserAuthorization();
        if (authorization == null)
        {
            // Kick off authorization request
            fbClient.RequestUserAuthorization();

        }
        else
        {
            var request = WebRequest.Create("https://graph.facebook.com/me?access_token=" + Uri.EscapeDataString(authorization.AccessToken));
            using (var response = request.GetResponse())
            {
                using (var responseStream = response.GetResponseStream())
                {
                    var graph = FacebookGraph.Deserialize(responseStream);

                    // unique id for facebook based on their ID
                    FormsAuthentication.SetAuthCookie("fb-" + graph.Id, true);

                    return RedirectToAction("Index", "Admin");
                }
            }
        }

        return View("LogOn");
Run Code Online (Sandbox Code Playgroud)

facebook dotnetopenauth

10
推荐指数
1
解决办法
2912
查看次数

存储必要的OpenID信息

我正在尝试为我的网站实施OpenID身份验证.这是场景:
我希望用户能够

  • 使用openId登录(用户可以通过访问openid提供商进行验证.无需使用电子邮件密码创建自定义帐户),
  • 通过电子邮件/密码(用户通过填写​​表格在网站上注册)
  • 将开放的ID附加到他/她的帐户(openids +一个帐户的电子邮件).

现在我不知道我应该为open id存储什么凭据.并且不确定数据库架构.这是数据库模式:

Table: Users
UserId => PK
... => Custom info. Not related to authentication.

Table: Authentication  
AuthenticationId => PK
LoginId => (when custom site membership => email address) (when openId => openid unique address)

UserId  => FK to Users.
Provider =>(when custom site membership => "CUSTOM") (when openId => openid provider address)  
Password => filled when using custom membership. empty when using open id.
Run Code Online (Sandbox Code Playgroud)

现在,当用户登录时,无论是使用openid /自定义成员身份,我只需查看身份验证表并查找凭据并获取相应的用户.如果没有用户,我创建一个新用户并在身份验证表中添加一个条目.

  • 主要问题:存储ProviderLoginId(请参阅上面的注释以查看存储在这些字段中的内容)是否足以存储openid身份验证?我应该存储任何其他数据,以便在用户返回时我可以根据我保存的数据对他/她进行身份验证吗?

  • 您是否建议采用其他(更有效)方法来实现此目的?
    谢谢.

architecture openid authentication dotnetopenauth asp.net-mvc-3

10
推荐指数
1
解决办法
754
查看次数

在.NET WCF Web API上处理身份验证的最佳方法

我对DotNetOpenAuth和OAuth很熟悉,但就Web API开发而言,根据以下标准锁定Web服务的最佳方法是什么:

  • 易于实施
  • 与面向最终用户的平台(iOS,Android,Win Phone,Flex ......)的互操作性/兼容性
  • 它是否明显是基于标准的(例如OAuth)

谢谢!

oauth dotnetopenauth asp.net-web-api

10
推荐指数
1
解决办法
8377
查看次数

在ASP.Net MVC3中使用OpenID,我在哪里获取用户数据?

我发现OpenID有点像一个庞大的,或者比典型的注册形式更复杂,但我觉得我在这里缺少一些东西.

根据这个问题,我应该保存我的提供商给出的唯一标识符密钥.

提供商将为每个用户提供一个唯一的ID - 您需要保存.这是您将刚刚登录的用户与数据库中的记录进行匹配的方式.

我的代码中(取自MVC部分),这个唯一的ID在LogOn()action方法的开关内给出:

public ActionResult LogOn()
{
    var openid = new OpenIdRelyingParty();
    IAuthenticationResponse response = openid.GetResponse();

    if (response != null)
    {
        switch (response.Status)
        {
            case AuthenticationStatus.Authenticated:
                FormsAuthentication.RedirectFromLoginPage(
                    response.ClaimedIdentifier, false);  // <-------- ID HERE! "response.ClaimedIdentifier"
                break;
            case AuthenticationStatus.Canceled:
                ModelState.AddModelError("loginIdentifier",
                    "Login was cancelled at the provider");
                break;
            case AuthenticationStatus.Failed:
                ModelState.AddModelError("loginIdentifier",
                    "Login failed using the provided OpenID identifier");
                break;
        }
    }

    return View();
}

[HttpPost]
public ActionResult LogOn(string loginIdentifier)
{
    if (!Identifier.IsValid(loginIdentifier))
    {
        ModelState.AddModelError("loginIdentifier", …
Run Code Online (Sandbox Code Playgroud)

c# openid dotnetopenauth asp.net-mvc-3 steam

10
推荐指数
1
解决办法
2190
查看次数

DotNetOpenAuth.Asp无法在MVC4应用程序单元测试中加载程序集或其中一个依赖项

我在项目中面临非常奇怪的错误.我安装了DotnetOpenAuth.Aspnet和Microsoft.AspNet.WebPages.OAuth库nuget包.当我运行项目时没有问题.但是当我为控制器编写测试时,它会抛出如下的异常.

测试方法MvcApplication2.Tests.ControllerTest.should_return_not_empty_content引发异常:

    System.IO.FileLoadException: Could not load file or assembly 'DotNetOpenAuth.AspNet, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' 
or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Run Code Online (Sandbox Code Playgroud)

另一个奇怪的观点是,如果我在VS 2010中设置一个项目作为MVC3应用程序并且测试正在通过.没有失败.但是当我在VS2012中执行完全相同的设置时,它会触发与上面相同的错误.当我在stackoverflow上搜索时,我看到了这个解决方案, 但它也没有用.

您可以在以下行中找到所有项目和样本测试.它只是一个app app测试项目.很容易阅读.

此外,我在此处添加了一个示例代码,用于控制器和失败的测试.

代码预览的pastebin链接是http://pastebin.com/1PCpq3hW

任何帮助,将不胜感激.

Vs2010和2012失败和成功的项目

详细的日志结果如下


    *** Assembly Binder Log Entry  (13.12.2012 @ 22:27:31) ***

    The operation failed.
    Bind result: hr = 0x80131040. No description available.

    Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
    Running under executable  C:\Program Files (x86)\JetBrains\ReSharper\v7.0\Bin\JetBrains.ReSharper.TaskRunner.CLR4.exe
    --- A detailed …

visual-studio-2010 dotnetopenauth asp.net-mvc-3 asp.net-mvc-4 visual-studio-2012

10
推荐指数
3
解决办法
2万
查看次数

如何使用OAuth 2 - OAuth 2 C#示例

我必须弄清楚如何使用OAuth 2才能使用Deviantart api.

我得到了client_id和client_secret部分

这里是他们提供的信息

端点

您使用OAuth 2.0向我们进行身份验证所需的唯一信息是您的应用的值client_idclient_secret值,以及下面显示的端点.

OAuth 2.0草案10:

自由软件 网址:htt

OAuth 2.0草案15:

自由软件 网址:htt

安慰剂电话

依赖于OAuth 2.0身份验证的第一个API调用是安慰剂调用.在进行可能很长的真实API调用(例如文件上载)之前,检查访问令牌是否仍然有效非常有用.您可以使用以下端点之一调用它(必须提供访问令牌):

https://www.deviantart.com/api/draft10/placebo https://www.deviantart.com/api/draft15/placebo

您需要使用与您获得令牌的OAuth 2.0草案相对应的端点.

它总是返回以下JSON: {status: "success"}

我在网上搜索过,找到了这个很棒的库.

DotNetOpenAuth v4.0.1

http://www.dotnetopenauth.net/

添加它作为参考,但不知道下一步该做什么.即使是一个非常小的例子对于如何使用OAuth 2也非常有用

using DotNetOpenAuth;
using DotNetOpenAuth.OAuth2;
Run Code Online (Sandbox Code Playgroud)

这里是deviantart提供信息的页面

http://www.deviantart.com/developers/oauth2

好了,到目前为止,我得到了什么,但没有工作

public static WebServerClient CreateClient() {
    var desc = GetAuthServerDescription();
    var client = new WebServerClient(desc, clientIdentifier: "myid");
    client.ClientCredentialApplicator = ClientCredentialApplicator.PostParameter("mysecret");
    return client;
}

public static AuthorizationServerDescription GetAuthServerDescription() {
    var authServerDescription = new AuthorizationServerDescription();
    authServerDescription.AuthorizationEndpoint …
Run Code Online (Sandbox Code Playgroud)

c# oauth dotnetopenauth oauth-2.0

10
推荐指数
1
解决办法
7万
查看次数

dotnetopenid教程

非常基本的问题,但有人可以指点我一个关于如何实现和使用dotnetopenid的建设性教程?

我很难找到任何解释如何实现这个东西的真实文档.我在他们的网站上找不到任何东西,我已经完成了几个样本,但仍然无法解决,而且包含的.chm文件只是参考资料,而不是"入门"指南.

谷歌搜索也让我失望:(

dotnetopenauth

9
推荐指数
1
解决办法
2447
查看次数