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

changed response for SignalR negotiate to use Microsoft.Azure.SignalR… #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using FunctionMonkey.Abstractions.Builders.Model;
using System.Security.Claims;
using FunctionMonkey.SignalR;

namespace {{Namespace}}
{
Expand Down Expand Up @@ -89,15 +88,17 @@ namespace {{Namespace}}
string userId = principal.FindFirst(claim => claim.Type == "{{{ClaimType}}}").Value;
return CreateSignalRResponse(userId);
}

public static IActionResult CreateSignalRResponse(string userId)
{
List<Claim> claims = new List<Claim>();
claims.Add(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", userId));

AzureSignalRAuthClient client = new AzureSignalRAuthClient(System.Environment.GetEnvironmentVariable("{{ConnectionStringSettingName}}"));
SignalRConnectionInfo info = client.GetClientConnectionInfo("{{{HubName}}}", claims);
return new OkObjectResult(info);
var connectionInfo = new SignalRConnectionInfo();
var serviceManager = StaticServiceHubContextStore.Get("{{ConnectionStringSettingName}}").ServiceManager;
connectionInfo.AccessToken = serviceManager
.GenerateClientAccessToken(
"{{HubName}}",
userId);
connectionInfo.Url = serviceManager.GetClientEndpoint("{{HubName}}");
return new OkObjectResult(connectionInfo);
}

private static string GetRequestUrl(HttpRequest request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using FunctionMonkey.Abstractions.Builders.Model;
using FunctionMonkey.SignalR;
using System.Security.Claims;

namespace {{Namespace}}
Expand Down Expand Up @@ -494,15 +493,14 @@ namespace {{Namespace}}

public static IActionResult CreateSignalRResponse(FunctionMonkey.Commanding.Abstractions.SignalRNegotiateResponse commandResponse)
{
List<Claim> claims = new List<Claim>();
if (!string.IsNullOrWhiteSpace(commandResponse.UserId))
{
claims.Add(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", commandResponse.UserId));
}

AzureSignalRAuthClient client = new AzureSignalRAuthClient(System.Environment.GetEnvironmentVariable("{{ConnectionStringSettingName}}"));
SignalRConnectionInfo info = client.GetClientConnectionInfo(commandResponse.HubName, claims);
return new OkObjectResult(info);
var connectionInfo = new SignalRConnectionInfo();
var serviceManager = StaticServiceHubContextStore.Get("{{ConnectionStringSettingName}}").ServiceManager;
connectionInfo.AccessToken = serviceManager
.GenerateClientAccessToken(
commandResponse.HubName,
commandResponse.UserId);
connectionInfo.Url = serviceManager.GetClientEndpoint(commandResponse.HubName);
return new OkObjectResult(connectionInfo);
}

public static IActionResult CreateResponse(int code, object content, FunctionMonkey.PluginFunctions pluginFunctions)
Expand Down