|
|
70c9ed |
From 1d61071f18a0e63e03b9c37cc407327b91fc6273 Mon Sep 17 00:00:00 2001
|
|
|
70c9ed |
From: Jarek Polok <jpolok@xenophile.cern.ch>
|
|
|
70c9ed |
Date: Tue, 11 Nov 2014 17:38:57 +0100
|
|
|
70c9ed |
Subject: [PATCH] Adding MellonMergeEnvVars (optional) functionality Allows to
|
|
|
70c9ed |
concatenate env. variables values in single variable name, ie:
|
|
|
70c9ed |
|
|
|
70c9ed |
VAR=val1;val2;val3;...
|
|
|
70c9ed |
|
|
|
70c9ed |
instead of standard mod_auth_mellom behaviour:
|
|
|
70c9ed |
|
|
|
70c9ed |
VAR=val1
|
|
|
70c9ed |
VAR_0=val1
|
|
|
70c9ed |
VAR_1=val2
|
|
|
70c9ed |
VAR_2=val3
|
|
|
70c9ed |
...
|
|
|
70c9ed |
---
|
|
|
70c9ed |
README | 16 ++++++++++++++++
|
|
|
70c9ed |
auth_mellon.h | 1 +
|
|
|
70c9ed |
auth_mellon_cache.c | 35 ++++++++++++++++++++++++++---------
|
|
|
70c9ed |
auth_mellon_config.c | 18 ++++++++++++++++++
|
|
|
70c9ed |
4 files changed, 61 insertions(+), 9 deletions(-)
|
|
|
70c9ed |
|
|
|
70c9ed |
diff --git a/README b/README
|
|
|
70c9ed |
index 238171301a857b9ede7933b9f4981c4bb58731ec..b5ff9b8ed8364367c32d8251d3d69fc27046d1dd 100644
|
|
|
70c9ed |
--- a/README
|
|
|
70c9ed |
+++ b/README
|
|
|
70c9ed |
@@ -232,6 +232,13 @@ MellonPostCount 100
|
|
|
70c9ed |
# Default. None set.
|
|
|
70c9ed |
MellonSetEnvNoPrefix "DISPLAY_NAME" "displayName"
|
|
|
70c9ed |
|
|
|
70c9ed |
+ # MellonMergeEnvVars merges multiple values of environement variables
|
|
|
70c9ed |
+ # set using MellonSetEnv into single variable:
|
|
|
70c9ed |
+ # ie: MYENV_VAR => val1;val2;val3 instead of default behaviour of:
|
|
|
70c9ed |
+ # MYENV_VAR_0 => val1, MYENV_VAR_1 => val2 ... etc.
|
|
|
70c9ed |
+ # Default: MellonMergeEnvVars Off
|
|
|
70c9ed |
+ MellonMergeEnvVars On
|
|
|
70c9ed |
+
|
|
|
70c9ed |
# If MellonSessionDump is set, then the SAML session will be
|
|
|
70c9ed |
# available in the MELLON_SESSION environment variable
|
|
|
70c9ed |
MellonSessionDump Off
|
|
|
70c9ed |
@@ -590,6 +597,15 @@ MELLON_<name>, and once named <MELLON_<name>_0.
|
|
|
70c9ed |
In the case of multivalued attributes MELLON_<name> will contain the first
|
|
|
70c9ed |
value.
|
|
|
70c9ed |
|
|
|
70c9ed |
+NOTE:
|
|
|
70c9ed |
+
|
|
|
70c9ed |
+if MellonMergeEnvVars is set to On multiple values of attributes
|
|
|
70c9ed |
+will be stored in single environement variable, separated by ";"
|
|
|
70c9ed |
+
|
|
|
70c9ed |
+MELLON_<name> -> "value1;value2;value3[;valueX]"
|
|
|
70c9ed |
+
|
|
|
70c9ed |
+and variables MELLON_<name>_0, MELLON_<name>_1, MELLON_<name>_2 will
|
|
|
70c9ed |
+not be created.
|
|
|
70c9ed |
|
|
|
70c9ed |
The following code is a simple php-script which prints out all the
|
|
|
70c9ed |
variables:
|
|
|
70c9ed |
diff --git a/auth_mellon.h b/auth_mellon.h
|
|
|
70c9ed |
index e915cbfbdd33072637780145ce5d7fcf7d9ebc88..8649674617d9cb31438e9d73a822f688ce43182f 100644
|
|
|
70c9ed |
--- a/auth_mellon.h
|
|
|
70c9ed |
+++ b/auth_mellon.h
|
|
|
70c9ed |
@@ -175,6 +175,7 @@ typedef struct am_dir_cfg_rec {
|
|
|
70c9ed |
|
|
|
70c9ed |
const char *varname;
|
|
|
70c9ed |
int secure;
|
|
|
70c9ed |
+ int merge_env_vars;
|
|
|
70c9ed |
const char *cookie_domain;
|
|
|
70c9ed |
const char *cookie_path;
|
|
|
70c9ed |
apr_array_header_t *cond;
|
|
|
70c9ed |
diff --git a/auth_mellon_cache.c b/auth_mellon_cache.c
|
|
|
70c9ed |
index ed96732c5dec221443839be91dda50431834611b..1982e604049ca6655ea93034d5f05dd72281b34e 100644
|
|
|
70c9ed |
--- a/auth_mellon_cache.c
|
|
|
70c9ed |
+++ b/auth_mellon_cache.c
|
|
|
70c9ed |
@@ -521,6 +521,7 @@ void am_cache_env_populate(request_rec *r, am_cache_entry_t *t)
|
|
|
70c9ed |
const char *varname;
|
|
|
70c9ed |
const char *varname_prefix;
|
|
|
70c9ed |
const char *value;
|
|
|
70c9ed |
+ const char *prefixed_varname;
|
|
|
70c9ed |
int *count;
|
|
|
70c9ed |
int status;
|
|
|
70c9ed |
|
|
|
70c9ed |
@@ -581,6 +582,8 @@ void am_cache_env_populate(request_rec *r, am_cache_entry_t *t)
|
|
|
70c9ed |
}
|
|
|
70c9ed |
}
|
|
|
70c9ed |
|
|
|
70c9ed |
+ prefixed_varname = apr_pstrcat(r->pool, varname_prefix, varname, NULL);
|
|
|
70c9ed |
+
|
|
|
70c9ed |
/* Find the number of times this variable has been set. */
|
|
|
70c9ed |
count = apr_hash_get(counters, varname, APR_HASH_KEY_STRING);
|
|
|
70c9ed |
if(count == NULL) {
|
|
|
70c9ed |
@@ -591,18 +594,32 @@ void am_cache_env_populate(request_rec *r, am_cache_entry_t *t)
|
|
|
70c9ed |
apr_hash_set(counters, varname, APR_HASH_KEY_STRING, count);
|
|
|
70c9ed |
|
|
|
70c9ed |
/* Add the variable without a suffix. */
|
|
|
70c9ed |
+ apr_table_set(r->subprocess_env,prefixed_varname,value);
|
|
|
70c9ed |
+ }
|
|
|
70c9ed |
+
|
|
|
70c9ed |
+ if (d->merge_env_vars != 1) {
|
|
|
70c9ed |
+
|
|
|
70c9ed |
+ /* Add the variable with a suffix indicating how many times it has
|
|
|
70c9ed |
+ * been added before.
|
|
|
70c9ed |
+ */
|
|
|
70c9ed |
apr_table_set(r->subprocess_env,
|
|
|
70c9ed |
- apr_pstrcat(r->pool, varname_prefix, varname, NULL),
|
|
|
70c9ed |
+ apr_psprintf(r->pool, "%s_%d", prefixed_varname, *count),
|
|
|
70c9ed |
value);
|
|
|
70c9ed |
+
|
|
|
70c9ed |
+ } else if (*count > 0) {
|
|
|
70c9ed |
+
|
|
|
70c9ed |
+ /*
|
|
|
70c9ed |
+ * Merge multiple values, separating with ";"
|
|
|
70c9ed |
+ * this makes auth_mellon work same way mod_shib is:
|
|
|
70c9ed |
+ * https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPAttributeAccess
|
|
|
70c9ed |
+ */
|
|
|
70c9ed |
+ apr_table_set(r->subprocess_env,
|
|
|
70c9ed |
+ prefixed_varname,
|
|
|
70c9ed |
+ apr_pstrcat(r->pool,
|
|
|
70c9ed |
+ apr_table_get(r->subprocess_env,prefixed_varname),
|
|
|
70c9ed |
+ ";", value, NULL));
|
|
|
70c9ed |
}
|
|
|
70c9ed |
-
|
|
|
70c9ed |
- /* Add the variable with a suffix indicating how many times it has
|
|
|
70c9ed |
- * been added before.
|
|
|
70c9ed |
- */
|
|
|
70c9ed |
- apr_table_set(r->subprocess_env,
|
|
|
70c9ed |
- apr_psprintf(r->pool, "%s%s_%d", varname_prefix, varname, *count),
|
|
|
70c9ed |
- value);
|
|
|
70c9ed |
-
|
|
|
70c9ed |
+
|
|
|
70c9ed |
/* Increase the count. */
|
|
|
70c9ed |
++(*count);
|
|
|
70c9ed |
}
|
|
|
70c9ed |
diff --git a/auth_mellon_config.c b/auth_mellon_config.c
|
|
|
70c9ed |
index dbcbfaa6604f4bdcfdf940a1d724947ff1100a6e..d3a408a6bcbec4fc1286222542aecbfcd3ba43e9 100644
|
|
|
70c9ed |
--- a/auth_mellon_config.c
|
|
|
70c9ed |
+++ b/auth_mellon_config.c
|
|
|
70c9ed |
@@ -70,6 +70,12 @@ static const apr_size_t post_size = 1024 * 1024 * 1024;
|
|
|
70c9ed |
*/
|
|
|
70c9ed |
static const int post_count = 100;
|
|
|
70c9ed |
|
|
|
70c9ed |
+/* whether to merge env. vars or not
|
|
|
70c9ed |
+ * the MellonMergeEnvVars configuration directive if you change this.
|
|
|
70c9ed |
+ */
|
|
|
70c9ed |
+static const int default_merge_env_vars = -1;
|
|
|
70c9ed |
+
|
|
|
70c9ed |
+
|
|
|
70c9ed |
/* This function handles configuration directives which set a
|
|
|
70c9ed |
* multivalued string slot in the module configuration (the destination
|
|
|
70c9ed |
* strucure is a hash).
|
|
|
70c9ed |
@@ -1218,6 +1224,13 @@ const command_rec auth_mellon_commands[] = {
|
|
|
70c9ed |
OR_AUTHCFG,
|
|
|
70c9ed |
"Whether we should replay POST requests that trigger authentication. Default is off."
|
|
|
70c9ed |
),
|
|
|
70c9ed |
+ AP_INIT_FLAG(
|
|
|
70c9ed |
+ "MellonMergeEnvVars",
|
|
|
70c9ed |
+ ap_set_flag_slot,
|
|
|
70c9ed |
+ (void *)APR_OFFSETOF(am_dir_cfg_rec, merge_env_vars),
|
|
|
70c9ed |
+ OR_AUTHCFG,
|
|
|
70c9ed |
+ "Whether to merge environement variables multi-values or not. Default is off."
|
|
|
70c9ed |
+ ),
|
|
|
70c9ed |
{NULL}
|
|
|
70c9ed |
};
|
|
|
70c9ed |
|
|
|
70c9ed |
@@ -1273,6 +1286,7 @@ void *auth_mellon_dir_config(apr_pool_t *p, char *d)
|
|
|
70c9ed |
|
|
|
70c9ed |
dir->varname = default_cookie_name;
|
|
|
70c9ed |
dir->secure = default_secure_cookie;
|
|
|
70c9ed |
+ dir->merge_env_vars = default_merge_env_vars;
|
|
|
70c9ed |
dir->cond = apr_array_make(p, 0, sizeof(am_cond_t));
|
|
|
70c9ed |
dir->cookie_domain = NULL;
|
|
|
70c9ed |
dir->cookie_path = NULL;
|
|
|
70c9ed |
@@ -1393,6 +1407,10 @@ void *auth_mellon_dir_merge(apr_pool_t *p, void *base, void *add)
|
|
|
70c9ed |
add_cfg->secure :
|
|
|
70c9ed |
base_cfg->secure);
|
|
|
70c9ed |
|
|
|
70c9ed |
+ new_cfg->merge_env_vars = (add_cfg->merge_env_vars != default_merge_env_vars ?
|
|
|
70c9ed |
+ add_cfg->merge_env_vars :
|
|
|
70c9ed |
+ base_cfg->merge_env_vars);
|
|
|
70c9ed |
+
|
|
|
70c9ed |
new_cfg->cookie_domain = (add_cfg->cookie_domain != NULL ?
|
|
|
70c9ed |
add_cfg->cookie_domain :
|
|
|
70c9ed |
base_cfg->cookie_domain);
|
|
|
70c9ed |
--
|
|
|
70c9ed |
2.1.0
|
|
|
70c9ed |
|