2010-06-21 3 views
0

MVC2로 업그레이드 한 후 가장 최근의 dotnetopenauth에서 "No OpenID endpoint found"가 계속 나타납니다. Google Apps를 사용하여 로그인하려고 할 때. 나는 localhost에서 잘 작동하지만 내 도메인에서는 그렇지 않습니다 - 어떤 아이디어입니까?dotnetopenauth, MVC2 그리고 OpenID 끝 점이 없습니다.

namespace TheDataEngineMVCb1.Areas.Admin.Controllers 
{ 
    using System; 
    using System.Collections.Generic; 
    using System.Diagnostics.CodeAnalysis; 
    using System.Globalization; 
    using System.Linq; 
    using System.Security.Principal; 
    using System.Web; 
    using System.Web.Mvc; 
    using System.Web.Security; 
    using System.Web.UI; 
    using DotNetOpenAuth.Messaging; 
    using DotNetOpenAuth.OpenId; 
    using DotNetOpenAuth.OpenId.RelyingParty; 
    using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; 

    [HandleError] 
    public class AccountController : Controller 
    { 
     private static readonly HostMetaDiscoveryService GoogleAppsDiscovery = new HostMetaDiscoveryService 
     { 
      UseGoogleHostedHostMeta = true, 
     }; 

     private static OpenIdRelyingParty openid = new OpenIdRelyingParty(); 

     public ActionResult Index() 
     { 
      return View("Index"); 
     } 

     public ActionResult LoginPopup() 
     { 
      return View("LoginPopup"); 
     } 

     public ActionResult Logout() 
     { 
      FormsAuthentication.SignOut(); 
      return Redirect("/Admin"); 
     } 

     public ActionResult Login() 
     { 
      // Stage 1: display login form to user 
      return View("Login"); 
     } 

     [ValidateInput(false)] 
     public ActionResult Authenticate(string returnUrl) 
     { 
      openid.DiscoveryServices.Clear(); 
      openid.DiscoveryServices.Insert(0, GoogleAppsDiscovery); 
      var response = openid.GetResponse(); 
      if (response == null) 
      { 
       // Stage 2: user submitting Identifier 
       Identifier id; 

       if (Identifier.TryParse(Request.Form["openid_identifier"], out id) && Request.Form["openid_identifier"]!=null) 
       { 
        try 
        { 

         Session["openid_identifier"] = Server.HtmlEncode(Request.Form["openid_identifier"]); 
         var request = openid.CreateRequest(Request.Form["openid_identifier"]); 

         return request.RedirectingResponse.AsActionResult(); 
        } 
        catch (ProtocolException ex) 
        { 
         ViewData["Message"] = ex.Message; 
         return View("Login"); 
        } 
       } 
       else 
       { 
        ViewData["Message"] = "Invalid identifier"; 
        return View("Login"); 
       } 
      } 
      else 
      { 
       // Stage 3: OpenID Provider sending assertion response 
       switch (response.Status) 
       { 
        case AuthenticationStatus.Authenticated: 
         string authEmail = Request["dnoa.userSuppliedIdentifier"].ToString(); 

         FormsAuthentication.SetAuthCookie(authEmail, false); 

         if (!string.IsNullOrEmpty(returnUrl)) 
         { 
          return Redirect(returnUrl); 
         } 
         else 
         { 
          return RedirectToAction("Index", "Home"); 
         } 
        case AuthenticationStatus.Canceled: 
         ViewData["Message"] = "Canceled at provider"; 
         return View("Login"); 
        case AuthenticationStatus.Failed: 
         ViewData["Message"] = response.Exception.Message; 
         return View("Login"); 
       } 
      } 
      return new EmptyResult(); 
     } 
    } 
} 

답변

3

신뢰 문제 일 수 있습니다. Google Apps OpenID에서는 RP가 완전 신뢰로 표시되어야합니다. 아마도 그것은 귀하의 로컬 호스트에 있지만 귀하의 라이브 사이트에 없을까요?

+0

MVC2로 업그레이드 할 때 변경되었지만 이상하게 작동했습니다 (MVC1에서 정상적으로 작동 함). - 감사합니다. – pch

관련 문제