Skip to content

Commit

Permalink
Revoke public interface change.
Browse files Browse the repository at this point in the history
  • Loading branch information
terencefan committed Apr 17, 2020
1 parent 4410b72 commit 0eaa4af
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
16 changes: 8 additions & 8 deletions src/Microsoft.Azure.SignalR.Management/IServiceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public interface IServiceManager
/// <returns>The task object representing the asynchronous operation.</returns>
Task<IServiceHubContext> CreateHubContextAsync(string hubName, ILoggerFactory loggerFactory = null, CancellationToken cancellationToken = default);

/// <summary>
/// Creates a client access token for SignalR hub connections to connect to Azure SignalR Service.
/// </summary>
/// <param name="hubName">The hub name.</param>
/// <param name="userId">The user ID.</param>
/// <param name="claims">The claim list to be put into access token.</param>
/// <param name="lifeTime">The lifetime of the token. The default value is one hour.</param>
/// <summary>
/// Creates a client access token for SignalR hub connections to connect to Azure SignalR Service.
/// </summary>
/// <param name="hubName">The hub name.</param>
/// <param name="userId">The user ID.</param>
/// <param name="claims">The claim list to be put into access token.</param>
/// <param name="lifeTime">The lifetime of the token. The default value is one hour.</param>
/// <returns>Client access token to Azure SignalR Service.</returns>
Task<string> GenerateClientAccessToken(string hubName, string userId = null, IList<Claim> claims = null, TimeSpan? lifeTime = null);
string GenerateClientAccessToken(string hubName, string userId = null, IList<Claim> claims = null, TimeSpan? lifeTime = null);

/// <summary>
/// Creates an client endpoint for SignalR hub connections to connect to Azure SignalR Service
Expand Down
7 changes: 5 additions & 2 deletions src/Microsoft.Azure.SignalR.Management/ServiceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public async Task<IServiceHubContext> CreateHubContextAsync(string hubName, ILog
}
}

public Task<string> GenerateClientAccessToken(string hubName, string userId = null, IList<Claim> claims = null, TimeSpan? lifeTime = null)
public string GenerateClientAccessToken(string hubName, string userId = null, IList<Claim> claims = null, TimeSpan? lifeTime = null)
{
var claimsWithUserId = new List<Claim>();
if (userId != null)
Expand All @@ -143,7 +143,10 @@ public Task<string> GenerateClientAccessToken(string hubName, string userId = nu
{
claimsWithUserId.AddRange(claims);
}
return _endpointProvider.GenerateClientAccessTokenAsync(hubName, claimsWithUserId, lifeTime);

var task = _endpointProvider.GenerateClientAccessTokenAsync(hubName, claimsWithUserId, lifeTime);
task.Wait();
return task.Result;
}

public string GetClientEndpoint(string hubName) => _endpointProvider.GetClientEndpoint(hubName, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,8 @@ private static string[] GetTestStringList(string prefix, int count)
var serviceHubContext = await serviceManager.CreateHubContextAsync(HubName, loggerFactory);

var clientEndpoint = serviceManager.GetClientEndpoint(HubName);
var tasks = from userName in _userNames
var tokens = from userName in _userNames
select serviceManager.GenerateClientAccessToken(HubName, userName);

await Task.WhenAll(tasks);

var tokens = new List<string>();
foreach (var task in tasks)
{
tokens.Add(task.Result);
}
return (clientEndpoint, tokens, serviceHubContext);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ from appName in _appNames

[Theory]
[MemberData(nameof(TestGenerateAccessTokenData))]
internal async Task GenerateClientAccessTokenTest(string userId, Claim[] claims, string appName)
internal void GenerateClientAccessTokenTest(string userId, Claim[] claims, string appName)
{
var manager = new ServiceManager(new ServiceManagerOptions() { ConnectionString = _testConnectionString, ApplicationName = appName }, null);
var tokenString = await manager.GenerateClientAccessToken(HubName, userId, claims, _tokenLifeTime);
var tokenString = manager.GenerateClientAccessToken(HubName, userId, claims, _tokenLifeTime);
var token = JwtTokenHelper.JwtHandler.ReadJwtToken(tokenString);

string expectedToken = JwtTokenHelper.GenerateExpectedAccessToken(token, GetExpectedClientEndpoint(appName), AccessKey, claims);
Expand Down

0 comments on commit 0eaa4af

Please sign in to comment.