Skip to content

Commit

Permalink
Merge pull request #239 from vicancy/dev
Browse files Browse the repository at this point in the history
Merge dev changes to master
  • Loading branch information
vicancy authored Oct 19, 2018
2 parents 941dc33 + c823e99 commit 1db56c6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ This repository contains the open source subset of the .NET SDK.

Package Name | Target Framework | NuGet | MyGet
---|---|---|---
Microsoft.Azure.SignalR | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/v/Microsoft.Azure.SignalR.svg)](https://www.nuget.org/packages/Microsoft.Azure.SignalR) | [![MyGet](https://img.shields.io/myget/azure-signalr-dev/v/Microsoft.Azure.SignalR.svg)](https://www.myget.org/feed/azure-signalr-dev/package/nuget/Microsoft.Azure.SignalR)
Microsoft.Azure.SignalR.Protocols | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/v/Microsoft.Azure.SignalR.Protocols.svg)](https://www.nuget.org/packages/Microsoft.Azure.SignalR.Protocols) | [![MyGet](https://img.shields.io/myget/azure-signalr-dev/v/Microsoft.Azure.SignalR.Protocols.svg)](https://www.myget.org/feed/azure-signalr-dev/package/nuget/Microsoft.Azure.SignalR.Protocols)
Microsoft.Azure.SignalR.AspNet | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/v/Microsoft.Azure.SignalR.AspNet.svg)](https://www.nuget.org/packages/Microsoft.Azure.SignalR.AspNet) | [![MyGet](https://img.shields.io/myget/azure-signalr-dev/v/Microsoft.Azure.SignalR.AspNet.svg)](https://www.myget.org/feed/azure-signalr-dev/package/nuget/Microsoft.Azure.SignalR.AspNet)
Microsoft.Azure.SignalR | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/v/Microsoft.Azure.SignalR.svg)](https://www.nuget.org/packages/Microsoft.Azure.SignalR) | [![MyGet](https://img.shields.io/myget/azure-signalr-dev/vpre/Microsoft.Azure.SignalR.svg)](https://www.myget.org/feed/azure-signalr-dev/package/nuget/Microsoft.Azure.SignalR)
Microsoft.Azure.SignalR.Protocols | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/v/Microsoft.Azure.SignalR.Protocols.svg)](https://www.nuget.org/packages/Microsoft.Azure.SignalR.Protocols) | [![MyGet](https://img.shields.io/myget/azure-signalr-dev/vpre/Microsoft.Azure.SignalR.Protocols.svg)](https://www.myget.org/feed/azure-signalr-dev/package/nuget/Microsoft.Azure.SignalR.Protocols)
Microsoft.Azure.SignalR.AspNet | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/v/Microsoft.Azure.SignalR.AspNet.svg)](https://www.nuget.org/packages/Microsoft.Azure.SignalR.AspNet) | [![MyGet](https://img.shields.io/myget/azure-signalr-dev/vpre/Microsoft.Azure.SignalR.AspNet.svg)](https://www.myget.org/feed/azure-signalr-dev/package/nuget/Microsoft.Azure.SignalR.AspNet)

## Getting Started

Expand Down
12 changes: 11 additions & 1 deletion src/Microsoft.Azure.SignalR/NegotiateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@ public NegotiationResponse Process(HttpContext context, string hubName)
private IEnumerable<Claim> BuildClaims(HttpContext context)
{
var userId = _userIdProvider.GetUserId(new ServiceHubConnectionContext(context));
return ClaimsUtility.BuildJwtClaims(context.User, userId, () => _claimsProvider?.Invoke(context));
return ClaimsUtility.BuildJwtClaims(context.User, userId, GetClaimsProvider(context)).ToList();
}

private Func<IEnumerable<Claim>> GetClaimsProvider(HttpContext context)
{
if (_claimsProvider == null)
{
return null;
}

return () => _claimsProvider.Invoke(context);
}

private static string GetOriginalPath(string path)
Expand Down
4 changes: 3 additions & 1 deletion test/Microsoft.Azure.SignalR.Tests/NegotiateHandlerFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public void GenerateNegotiateResponseWithUserId(Type type, string expectedUserId
User = new ClaimsPrincipal(new ClaimsIdentity(new[]
{
new Claim(CustomClaimType, CustomUserId),
new Claim(ClaimTypes.NameIdentifier, DefaultUserId)
new Claim(ClaimTypes.NameIdentifier, DefaultUserId),
new Claim("custom", "custom"),
}))
};

Expand All @@ -58,6 +59,7 @@ public void GenerateNegotiateResponseWithUserId(Type type, string expectedUserId

var token = JwtSecurityTokenHandler.ReadJwtToken(negotiateResponse.AccessToken);
Assert.Equal(expectedUserId, token.Claims.FirstOrDefault(x => x.Type == Constants.ClaimType.UserId)?.Value);
Assert.Equal("custom", token.Claims.FirstOrDefault(x => x.Type == "custom")?.Value);
}

[Theory]
Expand Down
2 changes: 1 addition & 1 deletion version.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionPrefix>1.0.2</VersionPrefix>
<VersionSuffix>preview1</VersionSuffix>
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' == 'rtm' ">$(VersionPrefix)</PackageVersion>
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' != 'rtm' ">$(VersionPrefix)-$(VersionSuffix)-final</PackageVersion>
Expand Down

0 comments on commit 1db56c6

Please sign in to comment.