diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2012-04-02 06:23:35 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2012-04-02 06:23:35 +0000 |
commit | 54b61a4f65fb36be0bc3f190707aac2c4226a4a9 (patch) | |
tree | 5558f85da71d2f0a530001412f339fdc51495315 /sca-cpp/trunk/modules/http/openauth.hpp | |
parent | d28e692331d0fa5cc4a8aa010f4c715da07abf7e (diff) |
Support multiple Auth modules in a single server or proxy config. Minor fixes to the OAuth2 module to comply with the spec.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1308244 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | sca-cpp/trunk/modules/http/openauth.hpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sca-cpp/trunk/modules/http/openauth.hpp b/sca-cpp/trunk/modules/http/openauth.hpp index e044a74fe2..5d887885aa 100644 --- a/sca-cpp/trunk/modules/http/openauth.hpp +++ b/sca-cpp/trunk/modules/http/openauth.hpp @@ -47,7 +47,7 @@ const char* cookieName(const char* cs) { return cs; return cookieName(cs + 1); } -const maybe<string> sessionID(const list<string> c) { +const maybe<string> sessionID(const list<string>& c, const string& key) { if (isNil(c)) return maybe<string>(); const string cn = cookieName(c_str(car(c))); @@ -55,29 +55,29 @@ const maybe<string> sessionID(const list<string> c) { if (i < length(cn)) { const list<string> kv = mklist<string>(substr(cn, 0, i), substr(cn, i+1)); if (!isNil(kv) && !isNil(cdr(kv))) { - if (car(kv) == "TuscanyOpenAuth") + if (car(kv) == key) return cadr(kv); } } - return sessionID(cdr(c)); + return sessionID(cdr(c), key); } -const maybe<string> sessionID(const request_rec* r) { +const maybe<string> sessionID(const request_rec* r, const string& key) { const string c = httpd::cookie(r); debug(c, "openauth::sessionid::cookies"); if (length(c) == 0) return maybe<string>(); - return sessionID(tokenize(";", c)); + return sessionID(tokenize(";", c), key); } /** * Convert a session id to a cookie string. */ -const string cookie(const string& sid, const string& domain) { +const string cookie(const string& key, const string& sid, const string& domain) { const time_t t = time(NULL) + 86400; char exp[32]; strftime(exp, 32, "%a, %d-%b-%Y %H:%M:%S GMT", gmtime(&t)); - const string c = string("TuscanyOpenAuth=") + sid + "; expires=" + string(exp) + "; domain=." + domain + "; path=/"; + const string c = key + string("=") + sid + "; expires=" + string(exp) + "; domain=." + domain + "; path=/"; debug(c, "openauth::cookie"); return c; } |