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:
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();
|
||||
|
||||
Reference in new issue
Block a user