当用户单击我的站点中需要身份验证的链接时,浏览器将重定向到登录页面.登录页面包含returnUrl查询字符串参数.问题是,如果用户使用OpenID进行身份验证,则提供程序会将用户重定向回登录页面,并且不包含returnUrl参数,这非常无聊,因为我将用户重定向到主页而不是尝试的页面.
我正在使用DotNetOpenID,有没有办法解决这个问题?
我试图弄清楚如何通过open id验证后获取用户信息.如果我在呼叫时提供ClaimsRequest或FetchRequest并不重要
response.GetExtension<ClaimsResponse>
//Or
response.GetExtension<FetchResponse>
//Or
response.GetUntrustedExtension<ClaimsResponse>
// OR
response.GetUntrustedExtension<FetchResponse>
我总是得到一个空引用.我正在添加信息,就像我看到的所有示例一样:
request.AddExtension(new ClaimsRequest{ Email = DemandLevel.Require });
// Or
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
request.AddExtension(fetch);
知道我做错了什么吗?
更新
添加安德鲁建议的配置信息让我成为了那里的一部分.我终于得到一个ClaimsResponse,response.GetUntrustedExtension<ClaimsResponse>但response.GetExtension<ClaimsResponse>仍然返回null.返回的ClaimsResponse实际上并不包含我请求的任何数据.这是请求:
var request = openId.CreateRequest(Request.Form["openid_identifier"]);
request.AddExtension(new ClaimsRequest
    {
        BirthDate = DemandLevel.Request,
        Country = DemandLevel.Request,
        Email = DemandLevel.Require,
        FullName = DemandLevel.Request,
        Gender = DemandLevel.Request,
        Language = DemandLevel.Request,
        Nickname = DemandLevel.Request,
        PostalCode = DemandLevel.Request,
        TimeZone = DemandLevel.Request 
      });
      return request.RedirectingResponse.AsActionResult();
这是我的配置
  <uri>
    <idn enabled="All"/>
    <iriParsing enabled="true"/>
  </uri>
  <dotNetOpenAuth>
    <openid maxAuthenticationTime="0:05"> …我无法在SSL设备后面运行DNOA RP(终止客户端HTTPS连接并将HTTP反向代理到其后面的Web服务器).
问题是,RP是错误从传入请求猜测收件人端点(因为它是不是 HTTPS被它击中了网络服务器的时间)和终点与方案上的return_to URL对比(这是 HTTPS) -它失败的堆栈跟踪下面.我已经在代码中花了一些时间,如果没有自定义构建或非平凡的子类,我没有看到改变这种行为的方法.我已经将Realm和ReturnToUrl的HTTPS版本传递给OpenIdRelyingParty.CreateRequests() - 该部分工作正常.
是否有可能将检测到的收件人方案捏造为HTTPS或跳过股票DNOA版本的方案比较,或者我明天修补自定义构建?
堆栈跟踪:
ERROR DotNetOpenAuth.Messaging - 09 Jul 2010 00:11:39,450 - Protocol error: The openid.return_to parameter (https://XXX/Login.aspx?openid=XXX&dnoa.userSuppliedIdentifier=XXX) does not match the actual URL (http://XXX/Login.aspx?openid=XXX&dnoa.userSuppliedIdentifier=XXX&openid.ns=http://specs.openid.net/auth/2.0&openid.mode=id_res&openid.op_endpoint=XXX&openid.response_nonce=XXX&openid.return_to=https://XXX/Login.aspx?openid=XXX&dnoa.userSuppliedIdentifier=XXX&openid.assoc_handle=XXX&openid.signed=op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle&openid.sig=XXX&openid.identity=XXX&openid.claimed_id=XXX) the request was made with.
 at DotNetOpenAuth.Messaging.ErrorUtilities.VerifyProtocol(Boolean condition, String message, Object[] args)
 at DotNetOpenAuth.OpenId.Messages.IndirectSignedResponse.VerifyReturnToMatchesRecipient()
 at DotNetOpenAuth.OpenId.Messages.IndirectSignedResponse.EnsureValidMessage()
 at DotNetOpenAuth.Messaging.MessageSerializer.Deserialize(IDictionary`2 fields, MessageDictionary messageDictionary)
 at DotNetOpenAuth.Messaging.Reflection.MessageDictionary.Deserialize(IDictionary`2 fields)
 at DotNetOpenAuth.Messaging.Channel.Receive(Dictionary`2 fields, MessageReceivingEndpoint recipient)
 at DotNetOpenAuth.Messaging.Channel.ReadFromRequestCore(HttpRequestInfo request)
 at DotNetOpenAuth.Messaging.Channel.ReadFromRequest(HttpRequestInfo httpRequest)
 at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.GetResponse(HttpRequestInfo httpRequestInfo)
 at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.GetResponse()
我有一个使用WCF REST服务模板40创建的WCF 4服务项目.
我的目标是将单个WCF服务公开为SOAP端点和返回JSON格式数据的RESTful端点.必须通过从示例项目复制的DotNetOpenAuth OAuthAuthorizationManager保护两个端点.
因此,我有一个SOAP WCF服务,可以从我的OAuth服务提供商成功授权消费者.为此,我使用了DotNetOpenAuth服务提供程序示例中的相同配置.
现在,我正在尝试为同一服务设置WCF RESTful JSON响应端点,并保护该端点.我不确定如何做到这一点.我最初的想法是让它看起来像这样:
<behaviors>
  <serviceBehaviors>
    <behavior name="DataApiBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="OAuthServiceProvider.Core.OAuthAuthorizationManager, OAuthServiceProvider" />
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service behaviorConfiguration="DataApiBehavior" name="OAuthServices.DataApi">
    <endpoint address="soap" binding="wsHttpBinding" contract="OAuthServices.Interfaces.IDataApi"/>
    <endpoint address="json" binding="webHttpBinding" contract="OAuthServices.Interfaces.IDataApi"/>
  </service>
</services>
然后我看到这篇关于制作RESTful WCF服务+ DotNetOpenAuth的博客文章:http: //www.theleagueofpaul.com/codesnippet-ooo-openid-odata-oauth-together
我不确定是否设置工厂加服务配置的ServiceAuthorization部分会导致问题.
我也不确定我是否需要在Global.asax中的RegisterRoutes方法中做任何事情:
private void RegisterRoutes()
{
    RouteTable.Routes.Add(new ServiceRoute("DataApi", new WebServiceHostFactory(), typeof(DataApi)));
}
这里的任何建议将不胜感激.谢谢你的帮助.
如果您需要更多信息,请与我们联系.
我现在已经尝试了几个小时来让OAuth继续使用我正在研究的API,显然我的做法一定是错的,因为我经常遇到死胡同.
我得到的:
 - 一个在.NET MVC中实现的API,它以XML或JSON的形式返回数据结果.
 - 它需要API密钥才能使用API.
 - 用于管理API密钥的后端网站(X).
 - 另一个网站(Y),其中包含此API从中提取数据的大量数据.
我应该得到的:
 - 能够让API密钥从网站(Y)访问用户的数据,如果他们通过OAuth(1.0A)自己允许的话.
我尝试过:
 - 到目前为止,我的方法是使用DotNetOpenAuth库,但几乎所有关于如何实现OpenId,OAuth名称空间中的某些类甚至似乎都硬编码为OpenId功能.所以我一直试图看看使用OpenId的示例中发生了什么,看看我是否可以使用其中的一部分来实现没有OpenId的OAuth.
 - 在服务器端,各种方法包括读取"UnauthorizedTokenRequest"并通过调用ServiceProvider.Channel.PrepareResponse(unauthorizedTokenRequest).AsActionResult()返回它.AsActionResult()由于某种原因尝试将两个nonce和timestamp值添加到响应崩溃,并跳过它,它仍然返回一个我无法在客户端读取的响应.  
所以我想,我的问题是:
先感谢您!
- 丹麦约翰尼
我正在使用DotNetOpenAuth进行OpenID登录.Google的提供程序根据调用者的领域(主机名+端口)返回不同的ClaimedIdentifier.
根据OpenID身份验证回调与声明的标识符本身返回的电子邮件地址验证登录是否安全?即,如果我们在电子邮件上验证而不是声明的ID,用户是否可以伪造其电子邮件地址并因此获得对其他用户帐户的访问权限?
我认为只要提供商是可信的,这样就可以了 - 即我们可以信任Google不允许用户使用其他人的电子邮件地址登录.
我正在使用ASP.NET WebAPI为我的ASP.NET MVC4 Web应用程序构建RESTful Web API.我想使用OAuth 1.0来提供授权.我正在寻找DotNetOpenAuth库.任何人都可以帮助我了解如何使用ASP.NET WebAPI的这个库的服务提供程序?
我正在尝试将Google日历集成到我的应用程序中,并且我在使用关闭RefreshToken的OAuth授权方面遇到了一些问题.我收到一个没有问题的AccessToken,但RefreshToken属性为null.请参阅标有"ERROR HERE:"的行,了解我遇到的问题
我的Asp.Net MVC控制器(命名OAuthController)如下所示:
    public ActionResult Index()
    {
        var client = CreateClient();
        client.RequestUserAuthorization(new[] { "https://www.googleapis.com/auth/calendar" }, new Uri("http://localhost/FL.Evaluation.Web/OAuth/CallBack"));
        return View();
    }
    public ActionResult CallBack()
    {
        if (string.IsNullOrEmpty(Request.QueryString["code"])) return null;
        var client = CreateClient();
        // Now getting a 400 Bad Request here
        var state = client.ProcessUserAuthorization();
        // ERROR HERE:  The RefreshToken is NULL
        HttpContext.Session["REFRESH_TOKEN"] = Convert.ToBase64String(Encoding.Unicode.GetBytes(state.RefreshToken));
        return JavaScript("Completed!");
    }
    private static WebServerClient CreateClient()
    {
        return
            new WebServerClient(
                new AuthorizationServerDescription()
                    {
                        TokenEndpoint = new Uri("https://accounts.google.com/o/oauth2/token"),
                        AuthorizationEndpoint = new Uri("https://accounts.google.com/o/oauth2/auth"),
                        ProtocolVersion …在这条线上,我得到一个例外 -
OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
System.Web.Security.MembershipCreateUserException:提供的用户名无效.
进入此的数据是
初始化工作正常
WebSecurity.InitializeDatabaseConnection("club", "User", "UserID", "UserName", autoCreateTables: true);
我找不到任何说明用户名无效的例子?是否有某个标准定义了什么是正确的用户名?
我正在尝试将Google OpenID与Azure上托管的MVC 4应用程序一起使用,但它仍然失败.虽然不是直接的.当我部署应用程序时,它一次又一次地完美运行.然后我离开它一段时间,通常是一天,但可能是一个小时,然后再试一次,它每次都失败.然后刷新,返回主页,该主页将您转到登录页面并再次运行.
错误是:
[InvalidOperationException: Sequence contains no elements]
   System.Linq.Enumerable.First(IEnumerable`1 source) +498
   DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) +106
[ProtocolException: No OpenID endpoint found.]
   DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) +303
   Tools.Helpers.GoogleApps.Login(Uri returnUrl) in c:\Users\Simon\Documents\Visual Studio 2012\Projects\Internal Utils\Website\Helpers\GoogleApps.cs:33
   Tools.Helpers.ExternalLoginResult.ExecuteResult(ControllerContext context) in c:\Users\Simon\Documents\Visual Studio 2012\Projects\Internal Utils\Website\Helpers\ExternalLoginResult.cs:25
   System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +33
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +613
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +263
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +230
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +28
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult …