diff --git a/UmlautAdaptarr/Services/HttpProxyService.cs b/UmlautAdaptarr/Services/HttpProxyService.cs index 7253905..1e1c640 100644 --- a/UmlautAdaptarr/Services/HttpProxyService.cs +++ b/UmlautAdaptarr/Services/HttpProxyService.cs @@ -45,10 +45,15 @@ namespace UmlautAdaptarr.Services if (_options.ApiKey != null) { var headers = ParseHeaders(buffer, bytesRead); + if (!headers.TryGetValue("Proxy-Authorization", out var proxyAuthorizationHeader) || !ValidateApiKey(proxyAuthorizationHeader)) { - _logger.LogWarning("Unauthorized access attempt."); + var isFirstRequest = !headers.ContainsKey("Proxy-Authorization"); + if (!isFirstRequest) + { + _logger.LogWarning("Unauthorized access attempt."); + } await clientStream.WriteAsync(Encoding.ASCII.GetBytes("HTTP/1.1 407 Proxy Authentication Required\r\nProxy-Authenticate: Basic realm=\"Proxy\"\r\n\r\n")); clientSocket.Close(); return;