Skip to content
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

https://{name}.service.signalr.net/api/v1/auth/accessKey not proxied with ServerEndpoint or ClientEndpoint properties #1802

Closed
ranjithsnair opened this issue Jun 28, 2023 · 0 comments · Fixed by #1805, #1812 or #1813
Assignees
Labels
bug Something isn't working

Comments

@ranjithsnair
Copy link
Contributor

ranjithsnair commented Jun 28, 2023

Describe the bug

We are currently using SignalR in default mode, and have set up a proxy endpoint for SignalR in API Management by following the instructions in this link: https://learn.microsoft.com/en-us/azure/azure-signalr/signalr-howto-work-with-apim. Additionally, we have added an extra endpoint in API Management for ServerEndpoint Websocket connection, which has a custom policy to replace the current Authorization header with API Management managed identity access token. This means that you only need to add the API Management managed identity to the "SignalR App Server" role, and anyone can connect as a server using the API Management proxy. The server authentication is happening in the API Management policy only.

However, the issue we are facing now is that the SDK is calling https://{name}.service.signalr.net/api/v1/auth/accessKey directly, instead of using the ServerEndpoint or ClientEndpoint proxy. As a result, the solution is failing to negotiate client connection requests.

To Reproduce

Follow the instructions provided in this Microsoft Azure SignalR tutorial: https://learn.microsoft.com/en-us/azure/azure-signalr/signalr-howto-work-with-apim.

Additionally, create a websocket API with a URL path of /server

AspNet Core Server Code:

services.AddSignalR(configure =>
{
    configure.EnableDetailedErrors = true;
})
.AddAzureSignalR(option =>
{
    option.Endpoints = new ServiceEndpoint[]
    {
         new ServiceEndpoint(new Uri("https://{name}.service.signalr.net"), new DefaultAzureCredential())
         {
              ClientEndpoint = new Uri("..."),
              ServerEndpoint = new Uri("..."),
         }
     };
});

....

app.UseEndpoints(endpoints =>
{
     endpoints.MapHub<MessageHub>("/messageHub");
});

Client Code:

_connectionBuilder = new HubConnectionBuilder();
_connection = _connectionBuilder
   .WithUrl("http://localhost:5000/messageHub")
   .WithAutomaticReconnect()
   .Build();

Run the server and client solutions and attempt to establish a connection.

We will close this issue if:

  • Proxy https://{name}.service.signalr.net/api/v1/auth/accessKey using API Management ServerEndpoint or ClientEndpoint URL.
  • /api/v1/auth/accessKey should append to full proxy URL not just base URL
  • find any other solution to fix this issue

Exceptions (if any)

info: Microsoft.Azure.SignalR.AadAccessKey[3]
      Succeed in authorizing AccessKey for 'https://{name}.service.signalr.net/'
crit: Microsoft.Azure.SignalR.ServiceRouteHelper[1]
      Client negotiate failed: The given AzureAD identity don't have the permission to generate access token.
info: Microsoft.Azure.SignalR.AadAccessKey[3]
      Succeed in authorizing AccessKey for 'https://{name}.service.signalr.net/'
info: Microsoft.Azure.SignalR.AadAccessKey[3]
      Succeed in authorizing AccessKey for 'https://{name}.service.signalr.net/'

Further technical details

  • <PackageReference Include="Microsoft.Azure.SignalR" Version="1.21.3" />
  • <FrameworkReference Include="Microsoft.AspNetCore.App" />
  • <PackageReference Include="Azure.Identity" Version="1.9.0" />
  • <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.7" />
@ranjithsnair ranjithsnair changed the title https://{name}.service.signalr.net/api/v1/auth/accessKey not proxied with ServerEndpoint property https://{name}.service.signalr.net/api/v1/auth/accessKey not proxied with ServerEndpoint or ClientEndpoint properties Jun 28, 2023
@vicancy vicancy added the bug Something isn't working label Jul 3, 2023
This was referenced Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants