开发者

dotnetopenauth asp.net mvc2 project template - broken when running from localhost:xxxx

开发者 https://www.devze.com 2023-01-08 22:35 出处:网络
So I create a new dnoa mvc2 site from the template, run setup.aspx without issue, login and authorize my openid - all ok, but on the redirect to

So I create a new dnoa mvc2 site from the template, run setup.aspx without issue, login and authorize my openid - all ok, but on the redirect to

http://localhost:18916/Auth/PopUpReturnTo?dnoa.uipopup=1&dnoa.popupUISupported=1&index=0&dnoa.userSuppliedIdentifier=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid&dnoa.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&dnoa.claimed_id=&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2010-07-24T18%3A06%3A36ZcustWWIY5CfXTQ&openid.return_to=http%3A%2F%2Flocalhost%3A18916%2FAuth%2FPopUpReturn开发者_JAVA百科To%3Fdnoa.uipopup%3D1%26dnoa.popupUISupported%3D1%26index%3D0%26dnoa.userSuppliedIdentifier%3Dhttps%253A%252F%252Fwww.google.com%252Faccounts%252Fo8%252Fid%26dnoa.op_endpoint%3Dhttps%253A%252F%252Fwww.google.com%252Faccounts%252Fo8%252Fud%26dnoa.claimed_id%3D&openid.assoc_handle=AOQobUdkpLPAPC1LRQKPaQcy2UlG8R4pjWmpDCSV_1odtA33o_HfNleiMi9ZjX8RU-kIIJnJ&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle%2Cns.ext1%2Cext1.mode%2Cext1.type.alias3%2Cext1.value.alias3%2Cext1.type.alias1%2Cext1.value.alias1&openid.sig=zkBfpugK7xT0da49hZLNQZz4Xn83UiZB%2BhEHz6B37Cw%3D&openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawk3FGqct35R7wya-0Bkq-0_Qnc1AB-YSw4&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawk3FGqct35R7wya-0Bkq-0_Qnc1AB-YSw4&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_response&openid.ext1.type.alias3=http%3A%2F%2Fschema.openid.net%2Fcontact%2Femail&openid.ext1.value.alias3=sky.sanders%40gmail.com&openid.ext1.type.alias1=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext1.value.alias1=sky.sanders%40gmail.com&openid.ns.ext2=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fui%2F1.0&openid.ext2.mode=popup

all i get is an alert [object Error].

The 'getting started' says that all I have to do is get the database set up and I would be good to go.

This does not seem good to go. If there are other criteria to getting the sample working they should be declared.

In any case, what is required to get this running on localhost:xxx (cassini/cassinidev)?


What you're seeing is due to a bug in IE8 having to do with crossing trust zones (from Local Computer/Intranet to Internet Zone). If you use a non-IE browser it will work. When you publish your web site on the Internet, IE8 will work fine because it doesn't cross into the Intranet zone during login.


I'm using that method you gave me before for my authentication, and here is my Controller Authentication Code

    <ValidateInput(False)> _
    Public Function Authenticate(ByVal returnUrl As String) As ActionResult
        Dim response = openid.GetResponse()
        If response Is Nothing Then
            ' Stage 2: user submitting Identifier
            Dim id As Identifier

            If Identifier.TryParse(Request.Form("openid_identifier"), id) Then

                Try
                    Return openid.CreateRequest(Request.Form("openid_identifier")).RedirectingResponse.AsActionResult()
                Catch ex As ProtocolException
                    ViewData("Message") = ex.Message
                    Return View("Login")
                End Try

            Else

                ViewData("Message") = "Invalid identifier"
                Return View("Login")
            End If
        Else
            ' Stage 3: OpenID Provider sending assertion response
            Select Case response.Status
                Case AuthenticationStatus.Authenticated

                    If Not OpenIDService.IsOpenIdAssociated(response.ClaimedIdentifier) Then
                        UserService.AddUser(response.ClaimedIdentifier, response.FriendlyIdentifierForDisplay)
                        UserService.SubmitChanges()

                        ActivityLogService.AddActivity(OpenIDService.GetOpenId(response.ClaimedIdentifier).UserID, _
                                                           Utilities.ActivityLog.LogType.UserAdded, _
                                                           HttpContext.Request.UserHostAddress)

                    Else
                        ActivityLogService.AddActivity(OpenIDService.GetOpenId(response.ClaimedIdentifier).UserID, _
                                                           Utilities.ActivityLog.LogType.UserLogin, _
                                                           HttpContext.Request.UserHostAddress)
                    End If
                    ActivityLogService.SubmitChanges()


                    ' Create the authentication cookie.  This cookie
                    ' includes the AuthUserData information in the
                    ' userData field of the FormsAuthentication Cookie.
                    Dim authUser As Authentication.AuthUserData = New Authentication.AuthUserData(OpenIDService.GetOpenId(response.ClaimedIdentifier).User)
                    HttpContext.Response.Cookies.Add(Authentication.CustomAuthentication.CreateAuthCookie(response.ClaimedIdentifier, _
                                                                                                                                  authUser, _
                                                                                                                                  True))
                    authUser = Nothing

                    If Not String.IsNullOrEmpty(returnUrl) Then : Return Redirect(returnUrl)
                    Else : Return RedirectToAction("Index", "Events")
                    End If

                Case AuthenticationStatus.Canceled
                    ViewData("Message") = "Canceled at provider"
                    Return View("Login")

                Case AuthenticationStatus.Failed
                    ViewData("Message") = response.Exception.Message
                    Return View("Login")

            End Select
        End If
        Return New EmptyResult()
    End Function

I have a custom table in my database called Users and I also have an OpenIDs table with a UserID field. The OpenIds table allows me to have an unlimited number of OpenIds per user.

All of this works both locally for me as well as on the production server and staging server.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号