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 4
4
using System ;
5
5
using System . IdentityModel . Tokens . Jwt ;
6
6
using System . Security . Claims ;
7
+ using System . Security . Cryptography ;
7
8
using System . Threading . Tasks ;
8
9
using Microsoft . AspNetCore . Authentication . JwtBearer ;
9
10
using Microsoft . AspNetCore . Builder ;
@@ -17,9 +18,16 @@ namespace JwtSample
17
18
{
18
19
public class Startup
19
20
{
20
- private readonly SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey ( Guid . NewGuid ( ) . ToByteArray ( ) ) ;
21
+ private readonly SymmetricSecurityKey SecurityKey ;
21
22
private readonly JwtSecurityTokenHandler JwtTokenHandler = new JwtSecurityTokenHandler ( ) ;
22
23
24
+ public Startup ( )
25
+ {
26
+ var key = new byte [ 16 ] ;
27
+ RandomNumberGenerator . Fill ( key ) ;
28
+ SecurityKey = new SymmetricSecurityKey ( key ) ;
29
+ }
30
+
23
31
public void ConfigureServices ( IServiceCollection services )
24
32
{
25
33
services . AddSignalR ( ) ;
You can’t perform that action at this time.
0 commit comments