소스 검색

Remove log spam when using legacy api

crobibero 5 년 전
부모
커밋
e30a85025f

+ 6 - 0
Emby.Server.Implementations/HttpServer/Security/AuthService.cs

@@ -146,11 +146,17 @@ namespace Emby.Server.Implementations.HttpServer.Security
             {
             {
                 return true;
                 return true;
             }
             }
+
             if (authAttribtues.AllowLocalOnly && request.IsLocal)
             if (authAttribtues.AllowLocalOnly && request.IsLocal)
             {
             {
                 return true;
                 return true;
             }
             }
 
 
+            if (authAttribtues.IgnoreLegacyAuth)
+            {
+                return true;
+            }
+
             return false;
             return false;
         }
         }
 
 

+ 9 - 2
Jellyfin.Api/Auth/CustomAuthenticationHandler.cs

@@ -37,13 +37,20 @@ namespace Jellyfin.Api.Auth
         /// <inheritdoc />
         /// <inheritdoc />
         protected override Task<AuthenticateResult> HandleAuthenticateAsync()
         protected override Task<AuthenticateResult> HandleAuthenticateAsync()
         {
         {
-            var authenticatedAttribute = new AuthenticatedAttribute();
+            var authenticatedAttribute = new AuthenticatedAttribute
+            {
+                IgnoreLegacyAuth = true
+            };
+
             try
             try
             {
             {
                 var user = _authService.Authenticate(Request, authenticatedAttribute);
                 var user = _authService.Authenticate(Request, authenticatedAttribute);
                 if (user == null)
                 if (user == null)
                 {
                 {
-                    return Task.FromResult(AuthenticateResult.Fail("Invalid user"));
+                    return Task.FromResult(AuthenticateResult.NoResult());
+                    // TODO return when legacy API is removed.
+                    // Don't spam the log with "Invalid User"
+                    // return Task.FromResult(AuthenticateResult.Fail("Invalid user"));
                 }
                 }
 
 
                 var claims = new[]
                 var claims = new[]

+ 4 - 0
MediaBrowser.Controller/Net/AuthenticatedAttribute.cs

@@ -52,6 +52,8 @@ namespace MediaBrowser.Controller.Net
             return (Roles ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
             return (Roles ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
         }
         }
 
 
+        public bool IgnoreLegacyAuth { get; set; }
+        
         public bool AllowLocalOnly { get; set; }
         public bool AllowLocalOnly { get; set; }
     }
     }
 
 
@@ -63,5 +65,7 @@ namespace MediaBrowser.Controller.Net
         bool AllowLocalOnly { get; }
         bool AllowLocalOnly { get; }
 
 
         string[] GetRoles();
         string[] GetRoles();
+        
+        bool IgnoreLegacyAuth { get; }
     }
     }
 }
 }