1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-07-15 00:57:36 +02:00

Fixed: Set SameSite=Strict for SonarrAuth cookie

(cherry picked from commit 675c72f02e7565a937b40c23ec27df6d86f95dc3)
This commit is contained in:
Mark McDowall 2021-03-07 15:10:56 -08:00 committed by Qstick
parent 5d5e66f0d7
commit fc12770495
2 changed files with 39 additions and 2 deletions

View File

@ -4,7 +4,6 @@
using Nancy.Authentication.Basic;
using Nancy.Authentication.Forms;
using Nancy.Bootstrapper;
using Nancy.Cookies;
using Nancy.Cryptography;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Authentication;
@ -117,7 +116,7 @@ private void SlidingAuthenticationForFormsAuth(NancyContext context)
if (FormsAuthentication.DecryptAndValidateAuthenticationCookie(formsAuthCookieValue, _formsAuthConfig).IsNotNullOrWhiteSpace())
{
var formsAuthCookie = new NancyCookie(formsAuthCookieName, formsAuthCookieValue, true, false, DateTime.UtcNow.AddDays(7))
var formsAuthCookie = new RadarrNancyCookie(formsAuthCookieName, formsAuthCookieValue, true, false, DateTime.UtcNow.AddDays(7))
{
Path = GetCookiePath()
};

View File

@ -0,0 +1,38 @@
using System;
using Nancy.Cookies;
namespace Radarr.Http.Authentication
{
public class RadarrNancyCookie : NancyCookie
{
public RadarrNancyCookie(string name, string value)
: base(name, value)
{
}
public RadarrNancyCookie(string name, string value, DateTime expires)
: base(name, value, expires)
{
}
public RadarrNancyCookie(string name, string value, bool httpOnly)
: base(name, value, httpOnly)
{
}
public RadarrNancyCookie(string name, string value, bool httpOnly, bool secure)
: base(name, value, httpOnly, secure)
{
}
public RadarrNancyCookie(string name, string value, bool httpOnly, bool secure, DateTime? expires)
: base(name, value, httpOnly, secure, expires)
{
}
public override string ToString()
{
return base.ToString() + "; SameSite=Strict";
}
}
}