Blame SOURCES/0006-Add-none-option-for-samesite.patch

493c9a
From fb5ad7bf997946df4472cb94d7875ee70281d59c Mon Sep 17 00:00:00 2001
493c9a
From: Anthony Critelli <acritelli@datto.com>
493c9a
Date: Tue, 7 Jan 2020 11:14:24 -0500
493c9a
Subject: [PATCH] Add none option for samesite
493c9a
493c9a
---
493c9a
 README.md                 | 7 +++++--
493c9a
 auth_mellon.h             | 3 ++-
493c9a
 auth_mellon_config.c      | 2 ++
493c9a
 auth_mellon_cookie.c      | 4 +++-
493c9a
 auth_mellon_diagnostics.c | 1 +
493c9a
 5 files changed, 13 insertions(+), 4 deletions(-)
493c9a
493c9a
diff --git a/README.md b/README.md
493c9a
index be374bc..82a88fc 100644
493c9a
--- a/README.md
493c9a
+++ b/README.md
493c9a
@@ -218,8 +218,11 @@ MellonDiagnosticsEnable Off
493c9a
 
493c9a
         # MellonCookieSameSite allows control over the SameSite value used
493c9a
         # for the authentication cookie.
493c9a
-        # The setting accepts values of "Strict" or "Lax"
493c9a
-        # If not set, the SameSite attribute is not set on the cookie.
493c9a
+        # The setting accepts values of "Strict", "Lax", or "None".
493c9a
+        # When using none, you should set "MellonSecureCookie On" to prevent
493c9a
+        # compatibility issues with newer browsers.
493c9a
+        # If not set, the SameSite attribute is not set on the cookie. In newer
493c9a
+        # browsers, this may cause SameSite to default to "Lax"
493c9a
         # Default: not set
493c9a
         # MellonCookieSameSite lax
493c9a
 
493c9a
diff --git a/auth_mellon.h b/auth_mellon.h
493c9a
index 9ef2d8a..5f5a20b 100644
493c9a
--- a/auth_mellon.h
493c9a
+++ b/auth_mellon.h
493c9a
@@ -164,7 +164,8 @@ typedef enum {
493c9a
 typedef enum {
493c9a
   am_samesite_default,
493c9a
   am_samesite_lax,
493c9a
-  am_samesite_strict
493c9a
+  am_samesite_strict,
493c9a
+  am_samesite_none,
493c9a
 } am_samesite_t;
493c9a
 
493c9a
 typedef enum {
493c9a
diff --git a/auth_mellon_config.c b/auth_mellon_config.c
493c9a
index 7932e2d..f1a9d12 100644
493c9a
--- a/auth_mellon_config.c
493c9a
+++ b/auth_mellon_config.c
493c9a
@@ -583,6 +583,8 @@ static const char *am_set_samesite_slot(cmd_parms *cmd,
493c9a
         d->cookie_samesite = am_samesite_lax;
493c9a
     } else if(!strcasecmp(arg, "strict")) {
493c9a
         d->cookie_samesite = am_samesite_strict;
493c9a
+    } else if(!strcasecmp(arg, "none")) {
493c9a
+        d->cookie_samesite = am_samesite_none;
493c9a
     } else {
493c9a
         return "The MellonCookieSameSite parameter must be 'lax' or 'strict'";
493c9a
     }
493c9a
diff --git a/auth_mellon_cookie.c b/auth_mellon_cookie.c
493c9a
index 8394c18..b2c8535 100644
493c9a
--- a/auth_mellon_cookie.c
493c9a
+++ b/auth_mellon_cookie.c
493c9a
@@ -1,7 +1,7 @@
493c9a
 /*
493c9a
  *
493c9a
  *   auth_mellon_cookie.c: an authentication apache module
493c9a
- *   Copyright © 2003-2007 UNINETT (http://www.uninett.no/)
493c9a
+ *   Copyright © 2003-2007 UNINETT (http://www.uninett.no/)
493c9a
  *
493c9a
  *   This program is free software; you can redistribute it and/or modify
493c9a
  *   it under the terms of the GNU General Public License as published by
493c9a
@@ -73,6 +73,8 @@ static const char *am_cookie_params(request_rec *r)
493c9a
         cookie_samesite = "; SameSite=Lax";
493c9a
     } else if (cfg->cookie_samesite == am_samesite_strict) {
493c9a
         cookie_samesite = "; SameSite=Strict";
493c9a
+    } else if (cfg->cookie_samesite == am_samesite_none) {
493c9a
+        cookie_samesite = "; SameSite=None";
493c9a
     }
493c9a
 
493c9a
     secure_cookie = cfg->secure;
493c9a
diff --git a/auth_mellon_diagnostics.c b/auth_mellon_diagnostics.c
493c9a
index 792e894..912814b 100644
493c9a
--- a/auth_mellon_diagnostics.c
493c9a
+++ b/auth_mellon_diagnostics.c
493c9a
@@ -214,6 +214,7 @@ am_diag_samesite_str(request_rec *r, am_samesite_t samesite)
493c9a
     case am_samesite_default: return "default";
493c9a
     case am_samesite_lax:     return "lax";
493c9a
     case am_samesite_strict:  return "strict";
493c9a
+    case am_samesite_none:    return "none";
493c9a
     default:
493c9a
         return apr_psprintf(r->pool, "unknown (%d)", samesite);
493c9a
     }
493c9a
-- 
493c9a
2.21.0
493c9a