Introduced `ApiKeyAuthOptions` for API key configuration, including a `Key` property and `SectionName` for binding. Updated `ApiKeyAuthMiddleware` to validate the `X-Api-Key` header against the configured API key. Added conditional middleware application in `Program.cs` based on the presence of a configured API key. Bound the `ApiKey` section in `appsettings.json` and `appsettings.Development.json` to store the API key, with a default value of `null`. This improves security and centralizes API key management.
23 lines
411 B
JSON
23 lines
411 B
JSON
{
|
|
"Serilog": {
|
|
"MinimumLevel": {
|
|
"Default": "Debug",
|
|
"Override": {
|
|
"Microsoft": "Warning",
|
|
"Microsoft.AspNetCore": "Warning",
|
|
"Microsoft.EntityFrameworkCore": "Warning",
|
|
"System": "Warning"
|
|
}
|
|
}
|
|
},
|
|
"ApiKey": {
|
|
"Key": null
|
|
},
|
|
"Logging": {
|
|
"LogLevel": {
|
|
"Default": "Information",
|
|
"Microsoft.AspNetCore": "Warning"
|
|
}
|
|
}
|
|
}
|