Add few config to create the token
This commit is contained in:
@@ -29,6 +29,9 @@ namespace skydiveLogs_api
|
||||
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
|
||||
|
||||
// JWT
|
||||
var jwtConf = Configuration.GetSection("JWT")
|
||||
.GetChildren()
|
||||
.ToDictionary(d => d.Key, d => d.Value);
|
||||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
@@ -39,29 +42,11 @@ namespace skydiveLogs_api
|
||||
ValidateAudience = true,
|
||||
ValidateLifetime = true,
|
||||
ValidateIssuerSigningKey = true,
|
||||
ValidIssuer = "toto", // Configuration["jwt:issuer"],
|
||||
ValidAudience = "toto", // Configuration["jwt:issuer"],
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("azertyuiopqsdfghjklmwxcvbn" /* this.Configuration["jwt:key"] */))
|
||||
ValidIssuer = jwtConf["Issuer"],
|
||||
ValidAudience = jwtConf["Issuer"],
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtConf["Key"]))
|
||||
};
|
||||
});
|
||||
//var key = Encoding.ASCII.GetBytes("azertyuiopqsdfghjklmwxcvbn");
|
||||
//services.AddAuthentication(x =>
|
||||
//{
|
||||
// x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
// x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
//})
|
||||
//.AddJwtBearer(x =>
|
||||
//{
|
||||
// x.RequireHttpsMetadata = false;
|
||||
// x.SaveToken = true;
|
||||
// x.TokenValidationParameters = new TokenValidationParameters
|
||||
// {
|
||||
// ValidateIssuerSigningKey = true,
|
||||
// IssuerSigningKey = new SymmetricSecurityKey(key),
|
||||
// ValidateIssuer = false,
|
||||
// ValidateAudience = false
|
||||
// };
|
||||
//});
|
||||
|
||||
// CORS
|
||||
var corsConf = Configuration.GetSection("Cors")
|
||||
|
||||
Reference in New Issue
Block a user