security: Host-Whitelist & Legacy-API-Key-Übergabe härten (H5, M11)

- trustHosts erlaubt nur die konfigurierten Domains (plus localhost/IP
  für Health-Checks) und verwirft fremde Host-Header, sodass
  X-Forwarded-Host keine URL-Generierung mehr vergiften kann (H5).
- Legacy-API-Keys nur noch per Header (Bearer/X-ApiKey); die alte
  Query-/Body-Übergabe wird nicht mehr zur Auth akzeptiert, erhält aber
  weiterhin den 410-Migrationshinweis statt eines opaken 401 (M11).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-07-14 13:48:28 +00:00
parent 000ae93e3b
commit 299837d2ba
9 changed files with 207 additions and 21 deletions

View file

@ -24,8 +24,10 @@ test('api requests are logged without storing bearer token contents', function (
->and(json_encode($log->toArray()))->not->toContain($plainTextToken);
});
test('legacy api key rejections are logged', function () {
test('legacy api keys in query parameters are rejected and redacted from logs', function () {
/** @var TestCase $this */
// Query-Keys werden nicht für die Auth akzeptiert, erhalten aber den
// 410-Migrationshinweis (statt eines opaken 401) und bleiben aus den Logs.
$this->getJson('/api/v1/categories?api_key=legacy-secret')
->assertStatus(410);