diff options
author | manu@netbsd.org <manu@netbsd.org@a716ebb1-153a-0410-b759-cfb97c6a1b53> | 2009-05-15 08:57:03 +0000 |
---|---|---|
committer | manu@netbsd.org <manu@netbsd.org@a716ebb1-153a-0410-b759-cfb97c6a1b53> | 2009-05-15 08:57:03 +0000 |
commit | 1803631503fca57e7f173bdd824c6da47a2db33f (patch) | |
tree | bdd0b3d2808796c4f3e5676e0b57b9f6b7d00a22 /auth_mellon_cache.c | |
parent | 4bbb403f59108ebeda333b8fd8b562d781bbdc36 (diff) | |
download | mod_auth_mellon-1803631503fca57e7f173bdd824c6da47a2db33f.tar.gz mod_auth_mellon-1803631503fca57e7f173bdd824c6da47a2db33f.tar.xz mod_auth_mellon-1803631503fca57e7f173bdd824c6da47a2db33f.zip |
Add support for IdP initiated SOAP single logout.
git-svn-id: https://modmellon.googlecode.com/svn/trunk@49 a716ebb1-153a-0410-b759-cfb97c6a1b53
Diffstat (limited to 'auth_mellon_cache.c')
-rw-r--r-- | auth_mellon_cache.c | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/auth_mellon_cache.c b/auth_mellon_cache.c index 749a817..058e278 100644 --- a/auth_mellon_cache.c +++ b/auth_mellon_cache.c @@ -28,12 +28,15 @@ * * Parameters: * server_rec *s The current server. - * const char *key The session key. + * const char *key The session key or user + * am_cache_key_t type AM_CACHE_SESSION or AM_CACHE_NAMEID * * Returns: * The session entry on success or NULL on failure. */ -am_cache_entry_t *am_cache_lock(server_rec *s, const char *key) +am_cache_entry_t *am_cache_lock(server_rec *s, + am_cache_key_t type, + const char *key) { am_mod_cfg_rec *mod_cfg; am_cache_entry_t *table; @@ -43,10 +46,22 @@ am_cache_entry_t *am_cache_lock(server_rec *s, const char *key) /* Check if we have a valid session key. We abort if we don't. */ - if(key == NULL || strlen(key) != AM_SESSION_ID_LENGTH) { + if (key == NULL) return NULL; - } + switch (type) { + case AM_CACHE_SESSION: + if (strlen(key) != AM_SESSION_ID_LENGTH) + return NULL; + break; + case AM_CACHE_NAMEID: + if (strlen(key) > AM_CACHE_MAX_LASSO_IDENTITY_SIZE) + return NULL; + break; + default: + return NULL; + break; + } mod_cfg = am_get_mod_cfg(s); @@ -63,7 +78,25 @@ am_cache_entry_t *am_cache_lock(server_rec *s, const char *key) for(i = 0; i < mod_cfg->init_cache_size; i++) { - if(strcmp(table[i].key, key) == 0) { + const char *tablekey; + + switch (type) { + case AM_CACHE_SESSION: + tablekey = table[i].key; + break; + case AM_CACHE_NAMEID: + /* tablekey may be NULL */ + tablekey = am_cache_env_fetch_first(&table[i], "NAME_ID"); + break; + default: + tablekey = NULL; + break; + } + + if (tablekey == NULL) + continue; + + if(strcmp(tablekey, key) == 0) { /* We found the entry. */ if(table[i].expires > apr_time_now()) { /* And it hasn't expired. */ @@ -113,7 +146,7 @@ am_cache_entry_t *am_cache_new(server_rec *s, const char *key) /* First we try to find another session with the given key. */ - t = am_cache_lock(s, key); + t = am_cache_lock(s, AM_CACHE_SESSION, key); if(t == NULL) { @@ -288,6 +321,29 @@ int am_cache_env_append(am_cache_entry_t *t, return OK; } +/* This function fetches a value from a session. + * If multiple values are available, the first one is returned. + * + * Parameters: + * am_cache_entry_t *t The current session. + * const char *var The name of the value to be stored. + * + * Returns: + * The first value, NULL if it does not exist. + */ +const char *am_cache_env_fetch_first(am_cache_entry_t *t, + const char *var) +{ + int i; + + for (i = 0; t->size; i++) { + if (strcmp(t->env[i].varname, var) == 0) + return t->env[i].value; + } + + return NULL; +} + /* This function populates the subprocess environment with data received * from the IdP. |