File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77using System . Text ;
88using Microsoft . OpenApi . Models ;
99using Todo . Services ;
10+ using Todo ;
1011
1112var builder = WebApplication . CreateBuilder ( args ) ;
1213
3839builder . Services . AddScoped < LoginService > ( ) ;
3940
4041
41- builder . Services . AddAuthentication ( x =>
42- {
43- x . DefaultAuthenticateScheme = JwtBearerDefaults . AuthenticationScheme ;
44- x . DefaultChallengeScheme = JwtBearerDefaults . AuthenticationScheme ;
45- } ) ;
42+ var key = Encoding . ASCII . GetBytes ( Settings . Secret ) ;
43+ builder . Services . AddAuthentication ( JwtBearerDefaults . AuthenticationScheme )
44+ . AddJwtBearer ( options =>
45+ {
46+ options . TokenValidationParameters = new TokenValidationParameters
47+ {
48+ ValidateIssuerSigningKey = true ,
49+ IssuerSigningKey = new SymmetricSecurityKey ( key ) ,
50+ ValidateIssuer = false ,
51+ ValidateAudience = false ,
52+ } ;
53+ } ) ;
4654
4755var app = builder . Build ( ) ;
4856app . UseSwagger ( ) ;
You can’t perform that action at this time.
0 commit comments