-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Blazor][Server-side]Issue with individual auth and Azure Signalr Service #12724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The HttpContext is null in the IHttpContextAccessor, the fix is likely to set it there. /cc: @anurse |
There is no way to have an HttpContext when using Azure SignalR. There is no HTTP request. |
@anurse That's not technically true. There is a "fake" HttpContext that gets populated. I'm saying that context should be set in the IHttpContextAccessor. Without it, things that depend on that don't work when using the SignalR service, like Identity. That's why I think it should be set there. Blazor could set it https://github.com/aspnet/AspNetCore/blob/master/src/Components/Server/src/ComponentHub.cs#L97 but it is not the right fix, as that only solves the problem for Blazor and not in general for Hubs using the Azure Signalr Service |
The |
@anurse I'm not suggesting we change the behavior, I'm suggesting we keep it inline with the current expectations. When I execute a method on a Hub, I expect the HttpContext to be the one that was there when we set up the connection. I'm saying the answer should be the same when using the SignalR service. We already setup the user, the request url, etc in the signalr service, why wouldn't we set the fabricated HttpContext into the HttpContextAccessor for things to work transparently, to the extent they do when using the Azure SignalR Service? |
The fact that That's why I think this is a larger issue than just setting In general, usage of Anyway, what's the impact of this particular issue? Is this blocking a core Blazor scenario? If so, we need to work out how to unblock that with as little churn as possible since we're in ask-mode now. It looks like you're calling in to Identity or Auth somewhere in the SignalR context and that's using |
It’s inside an Identity abstraction. SignInManager that uses IHttpContextAccessor. I’m not an expert on that area (@SteveSandersonMS is) so I don’t feel comfortable recommending an alternative solution. Ultimately it’s likely we can set this on the ComponentHub but it’s not something I feel we should be doing. I think it is one of our services in DI that uses the SignInManager and that in turn uses the IHttpContextAccessor, so I’m not sure there’s anything we can do. |
We should try to understand if there's something more granular than sign-in manager we should be using. If it's coupled to the idea of request/response, it's probably bad. |
In Preview 8 in most cases (identity being the exception) we get the principal from HubContext. That will work ok with SignalR service, right? One of the outstanding P9 issues is to use the same mechanism in the Identity template too, not SignInManager. |
Correct. The Principal on HubContext is fine. We intentionally set that up appropriately. It's |
Right now, |
Agreed. If your goal is to read the connection's active user, that's what |
@danroth27 Should we just punt this to preview9 (seems like @SteveSandersonMS has a fix in mind) and create an item in the known issues for preview8? |
We've discussed this and it seems this will be resolved as part of #12692. |
The issue is the HttpContext is null when connected through the SignalR service.
We notify the client of the error in an asynchronous way, that's why we see the two error messages.
An exception is thrown trying to initialize the circuit.
The circuit never gets initialized.
We continue because we return without throwing from StartCircuit and then try to invoke EndInvokeJSFromDotNet with the circuit being initialized.
The changes that we added are good because we caught a real issue through the logs.
We should additionally do a couple of things.
Change StartCircuit to return a result type instead of the Circuit ID and to notify clients of the errors synchronously so that they stop processing calls.
On the client side, stop processing interop and other calls after we detect the first error.
/cc @SteveSandersonMS
The text was updated successfully, but these errors were encountered: