Failing to connect when IIS enables both Anonymous and Basic #2145

Closed
gustavo-armenta opened this Issue Jun 13, 2013 · 9 comments

Comments

Projects
None yet
5 participants
Contributor

gustavo-armenta commented Jun 13, 2013

First request completes with status 200

GET http://localhost:81/signalr/negotiate?clientProtocol=1.3 HTTP/1.1
User-Agent: SignalR.Client.NET45/2.0.0.0 (Microsoft Windows NT 6.2.9200.0)
Host: localhost:81
Connection: Keep-Alive

Second request completes with status 401

GET http://localhost:81/signalr/connect?transport=serverSentEvents&connectionToken=PD63Uw3vImkQ5bkt4nX9zIBIk2RK56dMOVuxgJrFLBZ4Dplcn0Lknp5IbpToGgMKm6y38T3DM70Rn2rrICrchsNXEbJW42OsEVaPsN9FrzsKONzu6MK9m5UVsyVmemaF&connectionData=[%7B%22Name%22:%22AuthHub%22%7D] HTTP/1.1
User-Agent: SignalR.Client.NET45/2.0.0.0 (Microsoft Windows NT 6.2.9200.0)
Accept: text/event-stream
Host: localhost:81

Third request completes with status 500

GET http://localhost:81/signalr/connect?transport=serverSentEvents&connectionToken=PD63Uw3vImkQ5bkt4nX9zIBIk2RK56dMOVuxgJrFLBZ4Dplcn0Lknp5IbpToGgMKm6y38T3DM70Rn2rrICrchsNXEbJW42OsEVaPsN9FrzsKONzu6MK9m5UVsyVmemaF&connectionData=[%7B%22Name%22:%22AuthHub%22%7D] HTTP/1.1
User-Agent: SignalR.Client.NET45/2.0.0.0 (Microsoft Windows NT 6.2.9200.0)
Accept: text/event-stream
Authorization: Basic cmVkbW9uZFxndXN0YXZvYTpFa3ltaXphcmU3OVA=
Host: localhost:81

Error message on the last http response

[InvalidOperationException]: Unrecognized user identity.  The user identity cannot change during an active SignalR connection.
   at Microsoft.AspNet.SignalR.PersistentConnection.GetConnectionId(HostContext context, String connectionToken) in d:\signalr\dev\src\Microsoft.AspNet.SignalR.Core\PersistentConnection.cs:line 288
   at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(HostContext context) in d:\signalr\dev\src\Microsoft.AspNet.SignalR.Core\PersistentConnection.cs:line 208
   at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest(HostContext context) in d:\signalr\dev\src\Microsoft.AspNet.SignalR.Core\Hubs\HubDispatcher.cs:line 257
   at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(IDictionary`2 environment) in d:\signalr\dev\src\Microsoft.AspNet.SignalR.Core\PersistentConnection.cs:line 153
   at Microsoft.AspNet.SignalR.Owin.Middleware.HubDispatcherMiddleware.ProcessRequest(OwinRequest request, OwinResponse response) in d:\signalr\dev\src\Microsoft.AspNet.SignalR.Core\Owin\Middleware\HubDispatcherMiddleware.cs:line 27
   at Microsoft.AspNet.SignalR.Owin.Middleware.SignalRMiddleware.Invoke(OwinRequest request, OwinResponse response) in d:\signalr\dev\src\Microsoft.AspNet.SignalR.Core\Owin\Middleware\SignalRMiddleware.cs:line 38
   at Microsoft.AspNet.SignalR.Samples.Startup.ClaimsMiddleware.Invoke(OwinRequest request, OwinResponse response) in d:\signalr\dev\samples\Microsoft.AspNet.SignalR.Samples\App_Start\Startup.cs:line 57
   at Microsoft.AspNet.SignalR.Owin.Middleware.SignalRMiddleware.Invoke(OwinRequest request, OwinResponse response) in d:\signalr\dev\src\Microsoft.AspNet.SignalR.Core\Owin\Middleware\SignalRMiddleware.cs:line 23
   at Microsoft.AspNet.SignalR.Owin.Middleware.SignalRMiddleware.Invoke(OwinRequest request, OwinResponse response) in d:\signalr\dev\src\Microsoft.AspNet.SignalR.Core\Owin\Middleware\SignalRMiddleware.cs:line 23
   at Microsoft.AspNet.SignalR.Owin.Middleware.SignalRMiddleware.Invoke(OwinRequest request, OwinResponse response) in d:\signalr\dev\src\Microsoft.AspNet.SignalR.Core\Owin\Middleware\SignalRMiddleware.cs:line 23
   at Microsoft.AspNet.SignalR.Owin.Middleware.SignalRMiddleware.Invoke(OwinRequest request, OwinResponse response) in d:\signalr\dev\src\Microsoft.AspNet.SignalR.Core\Owin\Middleware\SignalRMiddleware.cs:line 23
   at Microsoft.Owin.Infrastructure.OwinMiddlewareTransition.Invoke(IDictionary`2 environment)
   at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.BeginEvent(Object sender, EventArgs e, AsyncCallback cb, Object extradata)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar)
   at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

MosheL commented Jun 17, 2013

what is your identity in web.config (impersonate, etc)

Owner

davidfowl commented Jun 17, 2013

The client needs to be updated to send the hubs on the negotiate request.

Contributor

gustavo-armenta commented Jun 17, 2013

@MosheL , I don't have any identity/impersonation configuration on my file
https://github.com/SignalR/SignalR/blob/dev/samples/Microsoft.AspNet.SignalR.Samples/Web.config

I enabled Anonymous and Basic directly on the virtual directory on IIS Manager Console

davidfowl was assigned Jun 18, 2013

Owner

davidfowl commented Jun 26, 2013

.NET client fixed 4330ccc

@davidfowl davidfowl added a commit that referenced this issue Jun 27, 2013

@davidfowl davidfowl Remove unnecessary passing of connection data.
- Get rid of extra calls passing the hub list to send and abort
- Set preauthenticate to true in both client impls

#2145
774dda8
Owner

davidfowl commented Jun 29, 2013

This is done now.

Contributor

gustavo-armenta commented Jul 1, 2013

We need to do the same fix for JS client. You can use the Windows Store JS client to validate the fix

NTaylorMullen was assigned Jul 2, 2013

Contributor

gustavo-armenta commented Jul 19, 2013

@NTaylorMullen , use branch test2145 to repro the bug. When the debugger is attached, enable to stop in all exceptions

Contributor

gustavo-armenta commented Jul 19, 2013

Also need to verify issue #2288

@NTaylorMullen NTaylorMullen added a commit that referenced this issue Jul 20, 2013

@NTaylorMullen NTaylorMullen Added connection data (hub subscriptions) to every request.
- This also involved moving the starting event above the negotiation logic instead of inside, this way connection data is built before the negotiate request.

#2145
35bd03c

@NTaylorMullen NTaylorMullen added a commit that referenced this issue Jul 20, 2013

@NTaylorMullen NTaylorMullen Added tests to verify that connection data is passed with all requests.
- This also involved adding a ConnectionDataVerifierHub which checks requests to ensure that all requests contain the correct information associated with them.

#2145
ee6d068

@NTaylorMullen NTaylorMullen added a commit that referenced this issue Jul 21, 2013

@NTaylorMullen @NTaylorMullen NTaylorMullen + NTaylorMullen Added connection data (hub subscriptions) to every request.
- This also involved moving the starting event above the negotiation logic instead of inside, this way connection data is built before the negotiate request.

#2145
1e58e5c

@NTaylorMullen NTaylorMullen added a commit that referenced this issue Jul 21, 2013

@NTaylorMullen @NTaylorMullen NTaylorMullen + NTaylorMullen Added tests to verify that connection data is passed with all requests.
- This also involved adding a ConnectionDataVerifierHub which checks requests to ensure that all requests contain the correct information associated with them.

#2145
5ae7eae
Contributor

gustavo-armenta commented Jul 22, 2013

verified on Fiddler "/negotiate" contains connectionData running Windows Store JS Sample Basic Auth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment