Blame SOURCES/0016-always-add-a-SameSite-value-to-the-Set-Cookie-header.patch

5b8408
From 2c999448c87b286744ac9802cb8e4277d5c38b71 Mon Sep 17 00:00:00 2001
5b8408
From: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
5b8408
Date: Wed, 29 Jan 2020 13:27:44 +0100
5b8408
Subject: [PATCH 16/19] always add a SameSite value to the Set-Cookie header
5b8408
5b8408
- to satisfy upcoming Chrome/Firefox changes
5b8408
  this can be overridden by using, e.g.:
5b8408
    SetEnvIf User-Agent ".*IOS.*" OIDC_SET_COOKIE_APPEND=;
5b8408
- release 2.4.1rc6
5b8408
5b8408
Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
5b8408
(cherry picked from commit 3b4770f49cc67b9b0ae8732e9908895683ea556c)
5b8408
---
5b8408
 ChangeLog              |  5 +++++
5b8408
 src/mod_auth_openidc.c | 10 +++++++---
5b8408
 src/mod_auth_openidc.h |  1 +
5b8408
 src/session.c          |  2 +-
5b8408
 4 files changed, 14 insertions(+), 4 deletions(-)
5b8408
5b8408
diff --git a/ChangeLog b/ChangeLog
5b8408
index fc7c5ae..b67f764 100644
5b8408
--- a/ChangeLog
5b8408
+++ b/ChangeLog
5b8408
@@ -1,3 +1,8 @@
5b8408
+01/29/2020
5b8408
+- always add a SameSite value to the Set-Cookie header to satisfy upcoming Chrome/Firefox changes
5b8408
+  this can be overridden by using, e.g.:
5b8408
+    SetEnvIf User-Agent ".*IOS.*" OIDC_SET_COOKIE_APPEND=;
5b8408
+
5b8408
 01/15/2020
5b8408
 - add value of OIDC_SET_COOKIE_APPEND env var to Set-Cookie headers
5b8408
   useful for handling changing/upcoming SameSite behaviors across different browsers, e.g.:
5b8408
diff --git a/src/mod_auth_openidc.c b/src/mod_auth_openidc.c
5b8408
index 38558d2..0d2b37c 100644
5b8408
--- a/src/mod_auth_openidc.c
5b8408
+++ b/src/mod_auth_openidc.c
5b8408
@@ -916,7 +916,9 @@ static int oidc_authorization_request_set_cookie(request_rec *r, oidc_cfg *c,
5b8408
 
5b8408
 	/* set it as a cookie */
5b8408
 	oidc_util_set_cookie(r, cookieName, cookieValue, -1,
5b8408
-			c->cookie_same_site ? OIDC_COOKIE_EXT_SAME_SITE_LAX : NULL);
5b8408
+			c->cookie_same_site ?
5b8408
+					OIDC_COOKIE_EXT_SAME_SITE_LAX :
5b8408
+					OIDC_COOKIE_EXT_SAME_SITE_NONE);
5b8408
 
5b8408
 	return HTTP_OK;
5b8408
 }
5b8408
@@ -2183,7 +2185,7 @@ static int oidc_discovery(request_rec *r, oidc_cfg *cfg) {
5b8408
 		oidc_util_set_cookie(r, OIDC_CSRF_NAME, csrf, -1,
5b8408
 				cfg->cookie_same_site ?
5b8408
 						OIDC_COOKIE_EXT_SAME_SITE_STRICT :
5b8408
-						NULL);
5b8408
+						OIDC_COOKIE_EXT_SAME_SITE_NONE);
5b8408
 
5b8408
 		/* see if we need to preserve POST parameters through Javascript/HTML5 storage */
5b8408
 		if (oidc_post_preserve_javascript(r, url, NULL, NULL) == TRUE)
5b8408
@@ -2276,7 +2278,9 @@ static int oidc_discovery(request_rec *r, oidc_cfg *cfg) {
5b8408
 	s = apr_psprintf(r->pool, "%s</form>\n", s);
5b8408
 
5b8408
 	oidc_util_set_cookie(r, OIDC_CSRF_NAME, csrf, -1,
5b8408
-			cfg->cookie_same_site ? OIDC_COOKIE_EXT_SAME_SITE_STRICT : NULL);
5b8408
+			cfg->cookie_same_site ?
5b8408
+					OIDC_COOKIE_EXT_SAME_SITE_STRICT :
5b8408
+					OIDC_COOKIE_EXT_SAME_SITE_NONE);
5b8408
 
5b8408
 	char *javascript = NULL, *javascript_method = NULL;
5b8408
 	char *html_head =
5b8408
diff --git a/src/mod_auth_openidc.h b/src/mod_auth_openidc.h
5b8408
index fada56d..5f1a79a 100644
5b8408
--- a/src/mod_auth_openidc.h
5b8408
+++ b/src/mod_auth_openidc.h
5b8408
@@ -213,6 +213,7 @@ APLOG_USE_MODULE(auth_openidc);
5b8408
 
5b8408
 #define OIDC_COOKIE_EXT_SAME_SITE_LAX    "SameSite=Lax"
5b8408
 #define OIDC_COOKIE_EXT_SAME_SITE_STRICT "SameSite=Strict"
5b8408
+#define OIDC_COOKIE_EXT_SAME_SITE_NONE   "SameSite=None"
5b8408
 
5b8408
 /* https://tools.ietf.org/html/draft-ietf-tokbind-ttrp-01 */
5b8408
 #define OIDC_TB_CFG_PROVIDED_ENV_VAR     "Sec-Provided-Token-Binding-ID"
5b8408
diff --git a/src/session.c b/src/session.c
5b8408
index 1c6e118..cd9ccb8 100644
5b8408
--- a/src/session.c
5b8408
+++ b/src/session.c
5b8408
@@ -204,7 +204,7 @@ static apr_byte_t oidc_session_save_cache(request_rec *r, oidc_session_t *z,
5b8408
 									(first_time ?
5b8408
 											OIDC_COOKIE_EXT_SAME_SITE_LAX :
5b8408
 											OIDC_COOKIE_EXT_SAME_SITE_STRICT) :
5b8408
-											NULL);
5b8408
+											OIDC_COOKIE_EXT_SAME_SITE_NONE);
5b8408
 
5b8408
 	} else {
5b8408
 		/* clear the cookie */
5b8408
-- 
5b8408
2.26.2
5b8408