fix security
This commit is contained in:
@@ -27,6 +27,11 @@ try
|
||||
|
||||
var jwtOptions = builder.Configuration.GetSection(JwtOptions.Section).Get<JwtOptions>()!;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(jwtOptions.SigningKey)
|
||||
|| Encoding.UTF8.GetByteCount(jwtOptions.SigningKey) < 32)
|
||||
throw new InvalidOperationException(
|
||||
"Jwt:SigningKey must be configured and at least 256 bits (32 bytes) for HMAC-SHA256.");
|
||||
|
||||
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user