Skip to content

Commit 51f9918

Browse files
Remove Guid in sample with Jwt (#26305)
1 parent 857722c commit 51f9918

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/SignalR/samples/JwtSample/Startup.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.IdentityModel.Tokens.Jwt;
66
using System.Security.Claims;
7+
using System.Security.Cryptography;
78
using System.Threading.Tasks;
89
using Microsoft.AspNetCore.Authentication.JwtBearer;
910
using Microsoft.AspNetCore.Builder;
@@ -17,9 +18,16 @@ namespace JwtSample
1718
{
1819
public class Startup
1920
{
20-
private readonly SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey(Guid.NewGuid().ToByteArray());
21+
private readonly SymmetricSecurityKey SecurityKey;
2122
private readonly JwtSecurityTokenHandler JwtTokenHandler = new JwtSecurityTokenHandler();
2223

24+
public Startup()
25+
{
26+
var key = new byte[16];
27+
RandomNumberGenerator.Fill(key);
28+
SecurityKey = new SymmetricSecurityKey(key);
29+
}
30+
2331
public void ConfigureServices(IServiceCollection services)
2432
{
2533
services.AddSignalR();

0 commit comments

Comments
 (0)