Advertisement
otkalce

JWT middleware setup

Mar 9th, 2023 (edited)
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | Source Code | 0 0
  1.   // Configure JWT services
  2.   builder.Services
  3.       .AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
  4.       .AddJwtBearer(o => {
  5.           var Key = Encoding.UTF8.GetBytes("12345678901234567890123456789012");
  6.           o.TokenValidationParameters = new TokenValidationParameters
  7.           {
  8.               ValidateIssuer = false,
  9.               ValidateAudience = false,
  10.               IssuerSigningKey = new SymmetricSecurityKey(Key)
  11.           };
  12.       });
  13.  
  14.   // Use authentication / authorization middleware
  15.   app.UseAuthentication();
  16.   app.UseAuthorization();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement