Fixed: Don't set cookies for static resources

Closes #4356
pull/4507/head
Mark McDowall 4 years ago
parent efd9fe9ad0
commit 6619350f87

@ -6,6 +6,7 @@ using System.Security.Principal;
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 Sonarr.Http.Authentication
return true;
}
if (context.Request.IsBundledJsRequest())
{
return true;
}
if (ValidUser(context))
{
return true;

@ -0,0 +1,30 @@
using System;
using System.Linq;
using Nancy;
using Nancy.Bootstrapper;
namespace Sonarr.Http.Extensions.Pipelines
{
public class SetCookieHeaderPipeline : IRegisterNancyPipeline
{
public int Order => 99;
public void Register(IPipelines pipelines)
{
pipelines.AfterRequest.AddItemToEndOfPipeline((Action<NancyContext>) 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);
}
}
}
}
}

@ -40,6 +40,11 @@ namespace Sonarr.Http.Extensions
return request.Path.StartsWith("/Content/", StringComparison.InvariantCultureIgnoreCase);
}
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) ||

Loading…
Cancel
Save