|
|
6e7331 |
From f34a1cfeefc7915fb12f05c74d3a8a60f60388fa Mon Sep 17 00:00:00 2001
|
|
|
6e7331 |
From: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
|
|
|
6e7331 |
Date: Wed, 15 Jan 2020 17:58:53 +0100
|
|
|
6e7331 |
Subject: [PATCH 8/9] add value of OIDC_SET_COOKIE_APPEND env var to Set-Cookie
|
|
|
6e7331 |
headers
|
|
|
6e7331 |
|
|
|
6e7331 |
- useful for handling changing/upcoming SameSite behaviors across
|
|
|
6e7331 |
different browsers, e.g.:
|
|
|
6e7331 |
SetEnvIf User-Agent ".*IOS.*" OIDC_SET_COOKIE_APPEND=SameSite=None
|
|
|
6e7331 |
- bump to 2.4.1rc4
|
|
|
6e7331 |
|
|
|
6e7331 |
Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
|
|
|
6e7331 |
(cherry picked from commit a326dbe843a755124ecee883db52dcdc26284c26)
|
|
|
6e7331 |
---
|
|
|
6e7331 |
ChangeLog | 5 +++++
|
|
|
6e7331 |
src/util.c | 27 +++++++++++++++++++++++++++
|
|
|
6e7331 |
2 files changed, 32 insertions(+)
|
|
|
6e7331 |
|
|
|
6e7331 |
diff --git a/ChangeLog b/ChangeLog
|
|
|
6e7331 |
index 6f28a3c..b3ed8f3 100644
|
|
|
6e7331 |
--- a/ChangeLog
|
|
|
6e7331 |
+++ b/ChangeLog
|
|
|
6e7331 |
@@ -1,3 +1,8 @@
|
|
|
6e7331 |
+01/15/2020
|
|
|
6e7331 |
+- add value of OIDC_SET_COOKIE_APPEND env var to Set-Cookie headers
|
|
|
6e7331 |
+ useful for handling changing/upcoming SameSite behaviors across different browsers, e.g.:
|
|
|
6e7331 |
+ SetEnvIf User-Agent ".*IOS.*" OIDC_SET_COOKIE_APPEND=SameSite=None
|
|
|
6e7331 |
+
|
|
|
6e7331 |
3/10/2016
|
|
|
6e7331 |
- release 1.8.8
|
|
|
6e7331 |
|
|
|
6e7331 |
diff --git a/src/util.c b/src/util.c
|
|
|
6e7331 |
index b687cb6..472d0cd 100644
|
|
|
6e7331 |
--- a/src/util.c
|
|
|
6e7331 |
+++ b/src/util.c
|
|
|
6e7331 |
@@ -676,6 +676,27 @@ static char *oidc_util_get_cookie_path(request_rec *r) {
|
|
|
6e7331 |
return (rv);
|
|
|
6e7331 |
}
|
|
|
6e7331 |
|
|
|
6e7331 |
+#define OIDC_SET_COOKIE_APPEND_ENV_VAR "OIDC_SET_COOKIE_APPEND"
|
|
|
6e7331 |
+
|
|
|
6e7331 |
+const char *oidc_util_set_cookie_append_value(request_rec *r, oidc_cfg *c) {
|
|
|
6e7331 |
+ const char *env_var_value = NULL;
|
|
|
6e7331 |
+
|
|
|
6e7331 |
+ if (r->subprocess_env != NULL)
|
|
|
6e7331 |
+ env_var_value = apr_table_get(r->subprocess_env,
|
|
|
6e7331 |
+ OIDC_SET_COOKIE_APPEND_ENV_VAR);
|
|
|
6e7331 |
+
|
|
|
6e7331 |
+ if (env_var_value == NULL) {
|
|
|
6e7331 |
+ oidc_debug(r, "no cookie append environment variable %s found",
|
|
|
6e7331 |
+ OIDC_SET_COOKIE_APPEND_ENV_VAR);
|
|
|
6e7331 |
+ return NULL;
|
|
|
6e7331 |
+ }
|
|
|
6e7331 |
+
|
|
|
6e7331 |
+ oidc_debug(r, "cookie append environment variable %s=%s found",
|
|
|
6e7331 |
+ OIDC_SET_COOKIE_APPEND_ENV_VAR, env_var_value);
|
|
|
6e7331 |
+
|
|
|
6e7331 |
+ return env_var_value;
|
|
|
6e7331 |
+}
|
|
|
6e7331 |
+
|
|
|
6e7331 |
/*
|
|
|
6e7331 |
* set a cookie in the HTTP response headers
|
|
|
6e7331 |
*/
|
|
|
6e7331 |
@@ -685,6 +706,7 @@ void oidc_util_set_cookie(request_rec *r, const char *cookieName,
|
|
|
6e7331 |
oidc_cfg *c = ap_get_module_config(r->server->module_config,
|
|
|
6e7331 |
&auth_openidc_module);
|
|
|
6e7331 |
char *headerString, *currentCookies, *expiresString = NULL;
|
|
|
6e7331 |
+ const char *appendString = NULL;
|
|
|
6e7331 |
|
|
|
6e7331 |
/* see if we need to clear the cookie */
|
|
|
6e7331 |
if (apr_strnatcmp(cookieValue, "") == 0)
|
|
|
6e7331 |
@@ -710,6 +732,11 @@ void oidc_util_set_cookie(request_rec *r, const char *cookieName,
|
|
|
6e7331 |
";Secure" : ""),
|
|
|
6e7331 |
c->cookie_http_only != FALSE ? ";HttpOnly" : "");
|
|
|
6e7331 |
|
|
|
6e7331 |
+ appendString = oidc_util_set_cookie_append_value(r, c);
|
|
|
6e7331 |
+ if (appendString != NULL)
|
|
|
6e7331 |
+ headerString = apr_psprintf(r->pool, "%s; %s", headerString,
|
|
|
6e7331 |
+ appendString);
|
|
|
6e7331 |
+
|
|
|
6e7331 |
/* sanity check on overall cookie value size */
|
|
|
6e7331 |
if (strlen(headerString) > 4093) {
|
|
|
6e7331 |
oidc_warn(r,
|
|
|
6e7331 |
--
|
|
|
6e7331 |
2.26.2
|
|
|
6e7331 |
|