JWT Token Add Log
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 3m30s
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 3m30s
This commit is contained in:
parent
af23c6e136
commit
5c65a8071b
@ -111,20 +111,27 @@ builder.Services.AddAuthentication(options =>
|
||||
options.RequireHttpsMetadata = false;
|
||||
options.SaveToken = true;
|
||||
options.IncludeErrorDetails = true;
|
||||
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidateAudience = true,
|
||||
ValidateIssuerSigningKey = true,
|
||||
ValidateLifetime = true, // 👈🏽 Agregá esto
|
||||
|
||||
ValidateLifetime = true,
|
||||
ValidIssuer = configuration["JWT:ValidIssuer"],
|
||||
ValidAudience = configuration["JWT:ValidAudience"],
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(configuration["JWT:Secret"])),
|
||||
|
||||
ClockSkew = TimeSpan.Zero
|
||||
};
|
||||
|
||||
options.Events = new JwtBearerEvents
|
||||
{
|
||||
OnAuthenticationFailed = context =>
|
||||
{
|
||||
var logger = context.HttpContext.RequestServices.GetRequiredService<ILoggerFactory>().CreateLogger("JWTDebug");
|
||||
logger.LogError(context.Exception, "Error de autenticación JWT");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
};
|
||||
});
|
||||
#endregion
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user