diff --git a/src/Lidarr.Http/Authentication/AuthenticationService.cs b/src/Lidarr.Http/Authentication/AuthenticationService.cs index 091ca7efb..6ee799f2e 100644 --- a/src/Lidarr.Http/Authentication/AuthenticationService.cs +++ b/src/Lidarr.Http/Authentication/AuthenticationService.cs @@ -7,6 +7,7 @@ using Lidarr.Http.Extensions; using Nancy; using Nancy.Authentication.Basic; using Nancy.Authentication.Forms; +using Nancy.Routing.Trie.Nodes; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Authentication; @@ -161,6 +162,11 @@ namespace Lidarr.Http.Authentication return true; } + if (context.Request.IsBundledJsRequest()) + { + return true; + } + if (ValidUser(context)) { return true; diff --git a/src/Lidarr.Http/Extensions/Pipelines/SetCookieHeaderPipeline.cs b/src/Lidarr.Http/Extensions/Pipelines/SetCookieHeaderPipeline.cs new file mode 100644 index 000000000..f0ed8f76b --- /dev/null +++ b/src/Lidarr.Http/Extensions/Pipelines/SetCookieHeaderPipeline.cs @@ -0,0 +1,30 @@ +using System; +using System.Linq; +using Nancy; +using Nancy.Bootstrapper; + +namespace Lidarr.Http.Extensions.Pipelines +{ + public class SetCookieHeaderPipeline : IRegisterNancyPipeline + { + public int Order => 99; + + public void Register(IPipelines pipelines) + { + pipelines.AfterRequest.AddItemToEndOfPipeline((Action)Handle); + } + + private void Handle(NancyContext context) + { + if (context.Request.IsContentRequest() || context.Request.IsBundledJsRequest()) + { + var authCookie = context.Response.Cookies.FirstOrDefault(c => c.Name == "SonarrAuth"); + + if (authCookie != null) + { + context.Response.Cookies.Remove(authCookie); + } + } + } + } +} diff --git a/src/Lidarr.Http/Extensions/RequestExtensions.cs b/src/Lidarr.Http/Extensions/RequestExtensions.cs index ab1c3f7a6..11f944c80 100644 --- a/src/Lidarr.Http/Extensions/RequestExtensions.cs +++ b/src/Lidarr.Http/Extensions/RequestExtensions.cs @@ -52,6 +52,11 @@ namespace Lidarr.Http.Extensions return defaultValue; } + public static bool IsBundledJsRequest(this Request request) + { + return !request.Path.EqualsIgnoreCase("/initialize.js") && request.Path.EndsWith(".js", StringComparison.InvariantCultureIgnoreCase); + } + public static bool IsSharedContentRequest(this Request request) { return request.Path.StartsWith("/MediaCover/", StringComparison.InvariantCultureIgnoreCase) ||