fix(security): remove API key query string authentication vector

Query string (?apiKey=...) leaks credentials in server logs, referrer
headers, and browser history. Only Authorization header and X-API-Key
header are now accepted for API key authentication.
This commit is contained in:
Arnaud Dartois committed 2026-07-17 19:21:25 +00:00
1 parent 7a71a09102
commit ca394a9eaa
1 file changed
+1 -2
@@ -36,8 +36,7 @@ public class ApiKeyAuthenticationHandler : AuthenticationHandler<ApiKeyAuthentic
{
var apiKey = Request.Headers.Authorization.FirstOrDefault()
?.Replace("Bearer ", "", StringComparison.OrdinalIgnoreCase)
?? Request.Headers["X-API-Key"].FirstOrDefault()
?? Request.Query["apiKey"].FirstOrDefault();
?? Request.Headers["X-API-Key"].FirstOrDefault();
if (string.IsNullOrEmpty(apiKey) || apiKey.Length < 8)
return AuthenticateResult.NoResult();