Merge Develop in master (#57)
* Merge master in develop (#55)
* Fix reachable and IP leak test (#44)
* Fix reachable check
Fixes failing reachable checks when Basic Authentication is enabled in
Sonarr, Radarr, etc.
* Add option to disable IP leak test
* Revert "Fix reachable and IP leak test (#44)" (#46)
This reverts commit 3f5d7bbef3.
* Release 0.6.1 (#48)
* Fix typo
* Fix typos
* Fix typos
* Fix typo
* Clarify error message
* Fix reachable and ipleak test (#47)
* Fix reachable check
Fixes failing reachable checks when Basic Authentication is enabled in
Sonarr, Radarr, etc.
* Add option to disable IP leak test
---------
Co-authored-by: Jonas F <github@pcjones.de>
* Add IpLeakTest environment variable to docker compose
---------
Co-authored-by: akuntsch <github@akuntsch.de>
* Create Dockerfile.arm64
---------
Co-authored-by: akuntsch <github@akuntsch.de>
* Add configurable cache duration
* Make proxy port configurable
* Make proxy port configurable
* Add API Key auth
* Add default settings to appsettings
* Fix too many Unauthorized access attempt warnings
---------
Co-authored-by: akuntsch <github@akuntsch.de>
This commit is contained in:
@@ -45,10 +45,15 @@ namespace UmlautAdaptarr.Services
|
|||||||
if (_options.ApiKey != null)
|
if (_options.ApiKey != null)
|
||||||
{
|
{
|
||||||
var headers = ParseHeaders(buffer, bytesRead);
|
var headers = ParseHeaders(buffer, bytesRead);
|
||||||
|
|
||||||
if (!headers.TryGetValue("Proxy-Authorization", out var proxyAuthorizationHeader) ||
|
if (!headers.TryGetValue("Proxy-Authorization", out var proxyAuthorizationHeader) ||
|
||||||
!ValidateApiKey(proxyAuthorizationHeader))
|
!ValidateApiKey(proxyAuthorizationHeader))
|
||||||
|
{
|
||||||
|
var isFirstRequest = !headers.ContainsKey("Proxy-Authorization");
|
||||||
|
if (!isFirstRequest)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Unauthorized access attempt.");
|
_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"));
|
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();
|
clientSocket.Close();
|
||||||
return;
|
return;
|
||||||
@@ -66,6 +71,7 @@ namespace UmlautAdaptarr.Services
|
|||||||
await HandleHttp(requestString, clientStream, clientSocket, buffer, bytesRead);
|
await HandleHttp(requestString, clientStream, clientSocket, buffer, bytesRead);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ValidateApiKey(string proxyAuthorizationHeader)
|
private bool ValidateApiKey(string proxyAuthorizationHeader)
|
||||||
{
|
{
|
||||||
// Expect the header to be in the format: "Basic <base64encodedApiKey>"
|
// Expect the header to be in the format: "Basic <base64encodedApiKey>"
|
||||||
|
|||||||
Reference in New Issue
Block a user