From c13e457780e4085b4e9b45e1d170d12a22dbf7da Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Thu, 20 Oct 2022 23:54:25 +0200 Subject: [PATCH] check for existence of WhitelistedIps --- .../Authentication/SecretKeyAuthenticationHandler.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MareSynchronosServer/MareSynchronosServices/Authentication/SecretKeyAuthenticationHandler.cs b/MareSynchronosServer/MareSynchronosServices/Authentication/SecretKeyAuthenticationHandler.cs index 6caa66c..cdd3579 100644 --- a/MareSynchronosServer/MareSynchronosServices/Authentication/SecretKeyAuthenticationHandler.cs +++ b/MareSynchronosServer/MareSynchronosServices/Authentication/SecretKeyAuthenticationHandler.cs @@ -179,10 +179,14 @@ public class SecretKeyAuthenticationHandler logger.LogInformation("FailedAuthForTempBan: {num}", _failedAttemptsForTempBan); _tempBanMinutes = config.GetValue("TempBanDurationInMinutes", 30); logger.LogInformation("TempBanMinutes: {num}", _tempBanMinutes); - _whitelistedIps = config.GetSection("WhitelistedIps").Get>(); - foreach (var ip in _whitelistedIps) + var whitelisted = config.GetSection("WhitelistedIps"); + if (!string.IsNullOrEmpty(whitelisted.Value)) { - logger.LogInformation("Whitelisted IP: " + ip); + _whitelistedIps = whitelisted.Get>(); + foreach (var ip in _whitelistedIps) + { + logger.LogInformation("Whitelisted IP: " + ip); + } } } } \ No newline at end of file