From 231c6cf147584db91738bc220692e2382818af53 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 25 Dec 2013 23:49:22 -0800 Subject: [PATCH] Log file requests will be authenticated when they come through with an API key Fixed: Opening log files in the UI --- src/NzbDrone.Api/Extensions/RequestExtensions.cs | 8 +++++++- src/NzbDrone.Api/Frontend/Mappers/LogFileMapper.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Api/Extensions/RequestExtensions.cs b/src/NzbDrone.Api/Extensions/RequestExtensions.cs index 02686deb6..672cdb7d5 100644 --- a/src/NzbDrone.Api/Extensions/RequestExtensions.cs +++ b/src/NzbDrone.Api/Extensions/RequestExtensions.cs @@ -7,7 +7,7 @@ public static class RequestExtensions { public static bool IsApiRequest(this Request request) { - return request.Path.StartsWith("/api/", StringComparison.InvariantCultureIgnoreCase); + return request.Path.StartsWith("/api/", StringComparison.InvariantCultureIgnoreCase) || request.IsLogFileRequest(); } public static bool IsSignalRRequest(this Request request) @@ -21,5 +21,11 @@ public static bool IsLocalRequest(this Request request) request.UserHostAddress.Equals("127.0.0.1") || request.UserHostAddress.Equals("::1")); } + + private static bool IsLogFileRequest(this Request request) + { + return request.Path.StartsWith("/log/", StringComparison.InvariantCultureIgnoreCase) && + request.Path.EndsWith(".txt", StringComparison.InvariantCultureIgnoreCase); + } } } diff --git a/src/NzbDrone.Api/Frontend/Mappers/LogFileMapper.cs b/src/NzbDrone.Api/Frontend/Mappers/LogFileMapper.cs index e41a9b711..f251fff97 100644 --- a/src/NzbDrone.Api/Frontend/Mappers/LogFileMapper.cs +++ b/src/NzbDrone.Api/Frontend/Mappers/LogFileMapper.cs @@ -25,7 +25,7 @@ protected override string Map(string resourceUrl) public override bool CanHandle(string resourceUrl) { - return resourceUrl.StartsWith("/log") && resourceUrl.EndsWith(".txt"); + return resourceUrl.StartsWith("/log/") && resourceUrl.EndsWith(".txt"); } } } \ No newline at end of file