Add API key authentication middleware support

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.
This commit is contained in:
2026-10-20 11:21:18 +02:00
parent 048456ddc7
commit d07bc2418b
5 changed files with 31 additions and 3 deletions

View File

@@ -10,6 +10,9 @@
}
}
},
"ApiKey": {
"Key": null
},
"Logging": {
"LogLevel": {
"Default": "Information",