Skip to content

Commit

Permalink
Port fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wtgodbe committed Jan 11, 2024
1 parent c3295d5 commit 0e9d775
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Net.Http;
using System.Net.WebSockets;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Security.Principal;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -2818,7 +2819,7 @@ public async Task ConnectionClosedRequestedTriggeredOnAuthExpiration()
[InlineData(HttpTransportType.WebSockets)]
public async Task AuthenticationExpirationSetOnAuthenticatedConnectionWithJWT(HttpTransportType transportType)
{
SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey(Guid.NewGuid().ToByteArray());
SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey(SHA256.HashData(Guid.NewGuid().ToByteArray()));
JwtSecurityTokenHandler JwtTokenHandler = new JwtSecurityTokenHandler();

using var host = CreateHost(services =>
Expand Down Expand Up @@ -2980,7 +2981,7 @@ public async Task AuthenticationExpirationSetOnAuthenticatedConnectionWithCookie
[InlineData(HttpTransportType.WebSockets)]
public async Task AuthenticationExpirationUsesCorrectScheme(HttpTransportType transportType)
{
var SecurityKey = new SymmetricSecurityKey(Guid.NewGuid().ToByteArray());
var SecurityKey = new SymmetricSecurityKey(SHA256.HashData(Guid.NewGuid().ToByteArray()));
var JwtTokenHandler = new JwtSecurityTokenHandler();

using var host = CreateHost(services =>
Expand Down
2 changes: 1 addition & 1 deletion src/SignalR/samples/JwtSample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace JwtSample;

public class Startup
{
private readonly SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey(RandomNumberGenerator.GetBytes(16));
private readonly SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey(RandomNumberGenerator.GetBytes(32));
private readonly JwtSecurityTokenHandler JwtTokenHandler = new JwtSecurityTokenHandler();

public void ConfigureServices(IServiceCollection services)
Expand Down
3 changes: 2 additions & 1 deletion src/SignalR/server/SignalR/test/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IdentityModel.Tokens.Jwt;
using System.IO;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
Expand All @@ -18,7 +19,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests;

public class Startup
{
private readonly SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey(Guid.NewGuid().ToByteArray());
private readonly SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey(SHA256.HashData(Guid.NewGuid().ToByteArray()));
private readonly JwtSecurityTokenHandler JwtTokenHandler = new JwtSecurityTokenHandler();

public void ConfigureServices(IServiceCollection services)
Expand Down

0 comments on commit 0e9d775

Please sign in to comment.