File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/SignalR/samples/JwtSample Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 44using System ;
55using System . IdentityModel . Tokens . Jwt ;
66using System . Security . Claims ;
7+ using System . Security . Cryptography ;
78using System . Threading . Tasks ;
89using Microsoft . AspNetCore . Authentication . JwtBearer ;
910using 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 ( ) ;
You can’t perform that action at this time.
0 commit comments