瀏覽代碼

Merge pull request #2746 from dafo90/master

Authentication request log with IP
Bond-009 5 年之前
父節點
當前提交
bcf53b3226
共有 1 個文件被更改,包括 7 次插入2 次删除
  1. 7 2
      Emby.Server.Implementations/Library/UserManager.cs

+ 7 - 2
Emby.Server.Implementations/Library/UserManager.cs

@@ -264,6 +264,7 @@ namespace Emby.Server.Implementations.Library
         {
         {
             if (string.IsNullOrWhiteSpace(username))
             if (string.IsNullOrWhiteSpace(username))
             {
             {
+                _logger.LogInformation("Authentication request without username has been denied (IP: {IP}).", remoteEndPoint);
                 throw new ArgumentNullException(nameof(username));
                 throw new ArgumentNullException(nameof(username));
             }
             }
 
 
@@ -319,11 +320,13 @@ namespace Emby.Server.Implementations.Library
 
 
             if (user == null)
             if (user == null)
             {
             {
+                _logger.LogInformation("Authentication request for {UserName} has been denied (IP: {IP}).", username, remoteEndPoint);
                 throw new AuthenticationException("Invalid username or password entered.");
                 throw new AuthenticationException("Invalid username or password entered.");
             }
             }
 
 
             if (user.Policy.IsDisabled)
             if (user.Policy.IsDisabled)
             {
             {
+                _logger.LogInformation("Authentication request for {UserName} has been denied because this account is currently disabled (IP: {IP}).", username, remoteEndPoint);
                 throw new AuthenticationException(
                 throw new AuthenticationException(
                     string.Format(
                     string.Format(
                         CultureInfo.InvariantCulture,
                         CultureInfo.InvariantCulture,
@@ -333,11 +336,13 @@ namespace Emby.Server.Implementations.Library
 
 
             if (!user.Policy.EnableRemoteAccess && !_networkManager.IsInLocalNetwork(remoteEndPoint))
             if (!user.Policy.EnableRemoteAccess && !_networkManager.IsInLocalNetwork(remoteEndPoint))
             {
             {
+                _logger.LogInformation("Authentication request for {UserName} forbidden: remote access disabled and user not in local network (IP: {IP}).", username, remoteEndPoint);
                 throw new AuthenticationException("Forbidden.");
                 throw new AuthenticationException("Forbidden.");
             }
             }
 
 
             if (!user.IsParentalScheduleAllowed())
             if (!user.IsParentalScheduleAllowed())
             {
             {
+                _logger.LogInformation("Authentication request for {UserName} is not allowed at this time due parental restrictions (IP: {IP}).", username, remoteEndPoint);
                 throw new AuthenticationException("User is not allowed access at this time.");
                 throw new AuthenticationException("User is not allowed access at this time.");
             }
             }
 
 
@@ -351,14 +356,14 @@ namespace Emby.Server.Implementations.Library
                 }
                 }
 
 
                 ResetInvalidLoginAttemptCount(user);
                 ResetInvalidLoginAttemptCount(user);
+                _logger.LogInformation("Authentication request for {UserName} has succeeded.", user.Name);
             }
             }
             else
             else
             {
             {
                 IncrementInvalidLoginAttemptCount(user);
                 IncrementInvalidLoginAttemptCount(user);
+                _logger.LogInformation("Authentication request for {UserName} has been denied (IP: {IP}).", user.Name, remoteEndPoint);
             }
             }
 
 
-            _logger.LogInformation("Authentication request for {0} {1}.", user.Name, success ? "has succeeded" : "has been denied");
-
             return success ? user : null;
             return success ? user : null;
         }
         }