-
Notifications
You must be signed in to change notification settings - Fork 389
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
Net8 Azure SignalR OIDC authentication #255
Comments
Could you share with me a minimum reproable project, for example, where do you consume cookies, where HttpContextAccessor.HttpContext is called? When using Azure SignalR, Azure SignalR SDK reads UserPrincipal data from HttpContext after the authentication middleware and reconstruct the HttpContext. |
https://github.com/njannink/BlazorServerAppOidcWithHub/tree/main See here an example project. Fill in your OIDC + Azure SignalR details in the
|
Hi @njannink, I met the same issue when commenting out AddAzureSignalR part. So I believe this is a general issue when integrating SignalR into the OIDC auth workflow with Blazor WebAssembly. The chat tab works if I manually Login before click (The same applies to AddAzureSignalR). I tried a JS client and see the detailed error in the Network tab as: Created a PR for the JS client here (which shows more error details in the browser): njannink/BlazorServerAppOidcWithHub#1 |
Its actually now Blazor WebAssembly, but Blazor Server. In the App.razor the render-mode is InteractiveServer. In blazor webassembly it was working fine, but switching to Blazor WebAssemly is too much work for us at this moment |
So to fix it you have to do somehting with CORS policies? |
Is it to change the SignalR connection logic to only connect when authorized better? Hi @davidfowl do we have any best practice guidance on such scenario for SignalR working with OIDC? |
Yes, this is the solution with any interactive logic scenario. |
I just used the simple OIDC sample to create this project. But indeed you should hide the Chat page untill you are authenticated. But the original question remains. What is the recommended way to connect to authenticated (Azure) SignalR when using Blazor Server? But as soon as you start using Azure SignalR in combination with Blazor the HttpContextAccessor can no longer be used. |
Not sure if I understand the question correctly. When Add(Azure)SignalR is put below Auth middleware it leverages the normal auth workflow and you could apply |
What is the current suggested way to do OIDC authentication over Azure SignalR using AspNetCore 8?
As soon as I switch to Azure SignalR in my Blazor Server app the HttpContextAccessor.HttpContext becomes null so I can no longer access the cookies.
The text was updated successfully, but these errors were encountered: