Optimize server modules a bit. Pass individual config elements instead of the whole server config. Load target composite once into the request. Enable loading of shared component implementations from the main contribution.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1291134 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8fdc6a6dc4
commit
4f245967cb
9 changed files with 441 additions and 433 deletions
|
|
@ -67,9 +67,7 @@ const failable<value> handle(const list<value>& params) {
|
|||
cout << "relay: " << &relay << endl;
|
||||
|
||||
// Redirect HTTPD request to Mod-axis2
|
||||
if (r->args == NULL)
|
||||
return redirectToAxis2(httpd::redirectURI("/axis2", string(r->uri)), r, relay);
|
||||
return redirectToAxis2(httpd::redirectURI("/axis2", string(r->uri), string(r->args)), r, relay);
|
||||
return redirectToAxis2(string("/axis2") + r->uri + r->args != NULL? string("?") + r->args : string(""), r, relay);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ fi
|
|||
if [ -x ../../components/log/scribe-cat ]; then
|
||||
cat >tmp/conf/log.conf <<EOF
|
||||
# Generated by: ssl-start $*
|
||||
LogLevel notice
|
||||
ErrorLog "|$here/../../components/log/scribe-cat server"
|
||||
CustomLog "|$here/../../components/log/scribe-cat server" combined
|
||||
|
||||
|
|
@ -101,7 +100,6 @@ EOF
|
|||
else
|
||||
cat >tmp/conf/log.conf <<EOF
|
||||
# Generated by: ssl=start $*
|
||||
LogLevel debug
|
||||
ErrorLog $here/tmp/logs/error_log
|
||||
CustomLog $here/tmp/logs/access_log combined
|
||||
|
||||
|
|
@ -137,6 +135,7 @@ cat >>tmp/conf/svhost-ssl.conf <<EOF
|
|||
# Error pages
|
||||
ErrorDocument 404 /public/notfound/
|
||||
ErrorDocument 401 /public/notauth/
|
||||
ErrorDocument 403 /public/notauth/
|
||||
ErrorDocument 500 /public/oops/
|
||||
ErrorDocument 405 /public/oops/
|
||||
|
||||
|
|
@ -150,8 +149,9 @@ SCAContribution $here/
|
|||
SCAComposite server.composite
|
||||
|
||||
# Configure SCA Composite for mass dynamic virtual Hosting
|
||||
SCAVirtualContribution $here/apps/
|
||||
SCAVirtualComposite app.composite
|
||||
#SCAVirtualContribution $here/data/apps/
|
||||
#SCAVirtualComposite app.composite
|
||||
SCAVirtualContributor Composites
|
||||
|
||||
EOF
|
||||
|
||||
|
|
@ -163,8 +163,13 @@ Alias /home/home.b64 $here/htdocs/home/home.b64
|
|||
|
||||
EOF
|
||||
|
||||
# Create app resource links
|
||||
./mkapplinks data ../../../../.. ../../../../../../nuvem
|
||||
# Create app implementation resource links
|
||||
if [ ! -e "nuvem" ]; then
|
||||
ln -s "../../../nuvem/nuvem-parallel/nuvem" "nuvem"
|
||||
fi
|
||||
if [ ! -e "lib" ]; then
|
||||
ln -s "../../components" "lib"
|
||||
fi
|
||||
|
||||
# Configure app resource aliases
|
||||
cat >>tmp/conf/svhost-ssl.conf <<EOF
|
||||
|
|
|
|||
|
|
@ -51,12 +51,6 @@ LogLevel notice
|
|||
ErrorLog "|$here/../../components/log/scribe-cat server"
|
||||
CustomLog "|$here/../../components/log/scribe-cat server" combined
|
||||
|
||||
EOF
|
||||
|
||||
cat >tmp/conf/log-ssl.conf <<EOF
|
||||
# Generated by: start $*
|
||||
CustomLog "|$here/../../components/log/scribe-cat server" sslcombined
|
||||
|
||||
EOF
|
||||
|
||||
else
|
||||
|
|
@ -66,12 +60,6 @@ LogLevel debug
|
|||
ErrorLog $here/tmp/logs/error_log
|
||||
CustomLog $here/tmp/logs/access_log combined
|
||||
|
||||
EOF
|
||||
|
||||
cat >tmp/conf/log-ssl.conf <<EOF
|
||||
# Generated by: start $*
|
||||
CustomLog $here/tmp/logs/ssl_access_log sslcombined
|
||||
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
|
@ -82,6 +70,7 @@ cat >>tmp/conf/svhost.conf <<EOF
|
|||
# Error pages
|
||||
ErrorDocument 404 /public/notfound/
|
||||
ErrorDocument 401 /public/notauth/
|
||||
ErrorDocument 403 /public/notauth/
|
||||
ErrorDocument 500 /public/oops/
|
||||
ErrorDocument 405 /public/oops/
|
||||
|
||||
|
|
@ -95,8 +84,9 @@ SCAContribution $here/
|
|||
SCAComposite server.composite
|
||||
|
||||
# Configure SCA Composite for mass dynamic virtual Hosting
|
||||
SCAVirtualContribution $here/data/apps/
|
||||
SCAVirtualComposite app.composite
|
||||
#SCAVirtualContribution $here/data/apps/
|
||||
#SCAVirtualComposite app.composite
|
||||
SCAVirtualContributor Composites
|
||||
|
||||
EOF
|
||||
|
||||
|
|
@ -108,8 +98,13 @@ Alias /home/home.b64 $here/htdocs/home/home.b64
|
|||
|
||||
EOF
|
||||
|
||||
# Create app resource links
|
||||
./mkapplinks data ../../../../.. ../../../../../../nuvem
|
||||
# Create app implementation resource links
|
||||
if [ ! -e "nuvem" ]; then
|
||||
ln -s "../../../nuvem/nuvem-parallel/nuvem" "nuvem"
|
||||
fi
|
||||
if [ ! -e "lib" ]; then
|
||||
ln -s "../../components" "lib"
|
||||
fi
|
||||
|
||||
# Configure app resource aliases
|
||||
cat >>tmp/conf/svhost.conf <<EOF
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ const value valueToElement(const value& t) {
|
|||
// Convert a single value to an attribute or an element
|
||||
if (!isList(v)) {
|
||||
if (substr(n, 0, 1) == atsign)
|
||||
return mklist<value>(attribute, substr(n, 1), v);
|
||||
return mklist<value>(attribute, c_str(substr(n, 1)), v);
|
||||
return mklist(element, n, v);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,22 @@ template<typename C> C& dirConf(const void* c) {
|
|||
return *(C*)c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a request-scoped module configuration.
|
||||
*/
|
||||
template<typename C> C& makeRequestConf(const request_rec* r, const module* mod) {
|
||||
C* c = new (gc_new<C>(r->pool)) C(r->pool, r);
|
||||
ap_set_module_config(r->request_config, mod, c);
|
||||
return *c;
|
||||
}
|
||||
|
||||
template<typename C> C& requestConf(const request_rec* r, const module* mod) {
|
||||
C* c = (C*)ap_get_module_config(r->request_config, mod);
|
||||
if (c == NULL)
|
||||
return makeRequestConf<C>(r, mod);
|
||||
return *c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the host name for a server.
|
||||
*/
|
||||
|
|
@ -424,17 +440,6 @@ const int reportStatus(const failable<int>& rc) {
|
|||
return content(rc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a redirect URI.
|
||||
*/
|
||||
const string redirectURI(const string& file, const string& pi) {
|
||||
return file + pi;
|
||||
}
|
||||
|
||||
const string redirectURI(const string& file, const string& pi, const string& args) {
|
||||
return file + pi + "?" + args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a value to an HTTPD request struc
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ int postConfigMerge(ServerConf& mainsc, apr_pool_t* p, server_rec* s) {
|
|||
if (s == NULL)
|
||||
return OK;
|
||||
ServerConf& sc = httpd::serverConf<ServerConf>(s, &mod_tuscany_ssltunnel);
|
||||
debug(httpd::serverName(s), "modwiring::postConfigMerge::serverName");
|
||||
debug(httpd::serverName(s), "modssltunnel::postConfigMerge::serverName");
|
||||
|
||||
// Merge configuration from main server
|
||||
if (length(sc.ca) == 0 && length(mainsc.ca) !=0)
|
||||
|
|
@ -105,7 +105,7 @@ int postConfigMerge(ServerConf& mainsc, apr_pool_t* p, server_rec* s) {
|
|||
int postConfig(apr_pool_t* p, unused apr_pool_t* plog, unused apr_pool_t* ptemp, server_rec* s) {
|
||||
gc_scoped_pool pool(p);
|
||||
ServerConf& sc = httpd::serverConf<ServerConf>(s, &mod_tuscany_ssltunnel);
|
||||
debug(httpd::serverName(s), "modwiring::postConfig::serverName");
|
||||
debug(httpd::serverName(s), "modssltunnel::postConfig::serverName");
|
||||
|
||||
// Register the SSLTUNNEL method
|
||||
M_SSLTUNNEL = ap_method_register(p, "SSLTUNNEL");
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ const list<string> sign(const string& verb, const string& uri, const list<value>
|
|||
/**
|
||||
* Handle an authorize request.
|
||||
*/
|
||||
const failable<int> authorize(const list<list<value> >& args, request_rec* r, const ServerConf& sc) {
|
||||
const failable<int> authorize(const list<list<value> >& args, request_rec* r, const list<list<value> >& appkeys, const memcache::MemCached& mc) {
|
||||
// Extract authorize, access_token, client ID and info URIs
|
||||
const list<value> req = assoc<value>("mod_oauth1_request_token", args);
|
||||
if (isNil(req) || isNil(cdr(req)))
|
||||
|
|
@ -196,7 +196,7 @@ const failable<int> authorize(const list<list<value> >& args, request_rec* r, co
|
|||
debug(redir, "modoauth1::authorize::redir");
|
||||
|
||||
// Lookup client app configuration
|
||||
const list<value> app = assoc<value>(cadr(cid), sc.appkeys);
|
||||
const list<value> app = assoc<value>(cadr(cid), appkeys);
|
||||
if (isNil(app) || isNil(cdr(app)))
|
||||
return mkfailure<int>(string("client id not found: ") + cadr(cid));
|
||||
list<value> appkey = cadr(app);
|
||||
|
|
@ -230,7 +230,7 @@ const failable<int> authorize(const list<list<value> >& args, request_rec* r, co
|
|||
return mkfailure<int>("Couldn't retrieve oauth_token_secret");
|
||||
|
||||
// Store the request token in memcached
|
||||
const failable<bool> prc = memcache::put(mklist<value>("tuscanyOAuth1Token", cadr(tv)), cadr(sv), sc.mc);
|
||||
const failable<bool> prc = memcache::put(mklist<value>("tuscanyOAuth1Token", cadr(tv)), cadr(sv), mc);
|
||||
if (!hasContent(prc))
|
||||
return mkfailure<int>(reason(prc));
|
||||
|
||||
|
|
@ -294,7 +294,7 @@ const failable<list<value> > profileUserInfo(const value& cid, const string& inf
|
|||
/**
|
||||
* Handle an access_token request.
|
||||
*/
|
||||
const failable<int> access_token(const list<list<value> >& args, request_rec* r, const ServerConf& sc) {
|
||||
const failable<int> accessToken(const list<list<value> >& args, request_rec* r, const list<list<value> >& appkeys, const memcache::MemCached& mc) {
|
||||
// Extract access_token URI, client ID and verification code
|
||||
const list<value> tok = assoc<value>("mod_oauth1_access_token", args);
|
||||
if (isNil(tok) || isNil(cdr(tok)))
|
||||
|
|
@ -313,13 +313,13 @@ const failable<int> access_token(const list<list<value> >& args, request_rec* r,
|
|||
return mkfailure<int>("Missing oauth_verifier parameter");
|
||||
|
||||
// Lookup client app configuration
|
||||
const list<value> app = assoc<value>(cadr(cid), sc.appkeys);
|
||||
const list<value> app = assoc<value>(cadr(cid), appkeys);
|
||||
if (isNil(app) || isNil(cdr(app)))
|
||||
return mkfailure<int>(string("client id not found: ") + cadr(cid));
|
||||
list<value> appkey = cadr(app);
|
||||
|
||||
// Retrieve the request token from memcached
|
||||
const failable<value> sv = memcache::get(mklist<value>("tuscanyOAuth1Token", cadr(tv)), sc.mc);
|
||||
const failable<value> sv = memcache::get(mklist<value>("tuscanyOAuth1Token", cadr(tv)), mc);
|
||||
if (!hasContent(sv))
|
||||
return mkfailure<int>(reason(sv));
|
||||
|
||||
|
|
@ -372,7 +372,7 @@ const failable<int> access_token(const list<list<value> >& args, request_rec* r,
|
|||
|
||||
// Store user info in memcached keyed by session ID
|
||||
const value sid = string("OAuth1_") + mkrand();
|
||||
const failable<bool> prc = memcache::put(mklist<value>("tuscanyOpenAuth", sid), content(iv), sc.mc);
|
||||
const failable<bool> prc = memcache::put(mklist<value>("tuscanyOpenAuth", sid), content(iv), mc);
|
||||
if (!hasContent(prc))
|
||||
return mkfailure<int>(reason(prc));
|
||||
|
||||
|
|
@ -433,13 +433,13 @@ static int checkAuthn(request_rec *r) {
|
|||
// Handle OAuth authorize request step
|
||||
if (step == "authorize") {
|
||||
r->ap_auth_type = const_cast<char*>(atype);
|
||||
return httpd::reportStatus(authorize(args, r, sc));
|
||||
return httpd::reportStatus(authorize(args, r, sc.appkeys, sc.mc));
|
||||
}
|
||||
|
||||
// Handle OAuth access_token request step
|
||||
if (step == "access_token") {
|
||||
r->ap_auth_type = const_cast<char*>(atype);
|
||||
return httpd::reportStatus(access_token(args, r, sc));
|
||||
return httpd::reportStatus(accessToken(args, r, sc.appkeys, sc.mc));
|
||||
}
|
||||
|
||||
// Redirect to the login page
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ const failable<int> authenticated(const list<list<value> >& attrs, const list<li
|
|||
/**
|
||||
* Handle an authorize request.
|
||||
*/
|
||||
const failable<int> authorize(const list<list<value> >& args, request_rec* r, const ServerConf& sc) {
|
||||
const failable<int> authorize(const list<list<value> >& args, request_rec* r, const list<list<value> >& appkeys) {
|
||||
// Extract authorize, access_token, client ID and info URIs
|
||||
const list<value> auth = assoc<value>("mod_oauth2_authorize", args);
|
||||
if (isNil(auth) || isNil(cdr(auth)))
|
||||
|
|
@ -146,7 +146,7 @@ const failable<int> authorize(const list<list<value> >& args, request_rec* r, co
|
|||
debug(redir, "modoauth2::authorize::redir");
|
||||
|
||||
// Lookup client app configuration
|
||||
const list<value> app = assoc<value>(cadr(cid), sc.appkeys);
|
||||
const list<value> app = assoc<value>(cadr(cid), appkeys);
|
||||
if (isNil(app) || isNil(cdr(app)))
|
||||
return mkfailure<int>(string("client id not found: ") + cadr(cid));
|
||||
list<value> appkey = cadr(app);
|
||||
|
|
@ -171,7 +171,7 @@ const failable<list<value> > profileUserInfo(const value& cid, const list<value>
|
|||
/**
|
||||
* Handle an access_token request.
|
||||
*/
|
||||
const failable<int> access_token(const list<list<value> >& args, request_rec* r, const ServerConf& sc) {
|
||||
const failable<int> accessToken(const list<list<value> >& args, request_rec* r, const list<list<value> >& appkeys, const perthread_ptr<http::CURLSession>& cs, const memcache::MemCached& mc) {
|
||||
// Extract access_token URI, client ID and authorization code
|
||||
const list<value> tok = assoc<value>("mod_oauth2_access_token", args);
|
||||
if (isNil(tok) || isNil(cdr(tok)))
|
||||
|
|
@ -187,7 +187,7 @@ const failable<int> access_token(const list<list<value> >& args, request_rec* r,
|
|||
return mkfailure<int>("Missing code parameter");
|
||||
|
||||
// Lookup client app configuration
|
||||
const list<value> app = assoc<value>(cadr(cid), sc.appkeys);
|
||||
const list<value> app = assoc<value>(cadr(cid), appkeys);
|
||||
if (isNil(app) || isNil(cdr(app)))
|
||||
return mkfailure<int>(string("client id not found: ") + cadr(cid));
|
||||
list<value> appkey = cadr(app);
|
||||
|
|
@ -201,7 +201,7 @@ const failable<int> access_token(const list<list<value> >& args, request_rec* r,
|
|||
const list<list<value> > targs = mklist<list<value> >(mklist<value>("client_id", car(appkey)), mklist<value>("redirect_uri", httpd::escape(redir)), mklist<value>("client_secret", cadr(appkey)), code);
|
||||
const string turi = httpd::unescape(cadr(tok)) + string("?") + http::queryString(targs);
|
||||
debug(turi, "modoauth2::access_token::tokenuri");
|
||||
const failable<value> tr = http::get(turi, *(sc.cs));
|
||||
const failable<value> tr = http::get(turi, *(cs));
|
||||
if (!hasContent(tr))
|
||||
return mkfailure<int>(reason(tr));
|
||||
debug(tr, "modoauth2::access_token::response");
|
||||
|
|
@ -215,7 +215,7 @@ const failable<int> access_token(const list<list<value> >& args, request_rec* r,
|
|||
const list<list<value> > iargs = mklist<list<value> >(tv);
|
||||
const string iuri = httpd::unescape(cadr(info)) + string("?") + http::queryString(iargs);
|
||||
debug(iuri, "modoauth2::access_token::infouri");
|
||||
const failable<value> profres = http::get(iuri, *(sc.cs));
|
||||
const failable<value> profres = http::get(iuri, *(cs));
|
||||
if (!hasContent(profres))
|
||||
return mkfailure<int>("Couldn't retrieve user info");
|
||||
debug(content(profres), "modoauth2::access_token::info");
|
||||
|
|
@ -227,7 +227,7 @@ const failable<int> access_token(const list<list<value> >& args, request_rec* r,
|
|||
|
||||
// Store user info in memcached keyed by session ID
|
||||
const value sid = string("OAuth2_") + mkrand();
|
||||
const failable<bool> prc = memcache::put(mklist<value>("tuscanyOpenAuth", sid), content(iv), sc.mc);
|
||||
const failable<bool> prc = memcache::put(mklist<value>("tuscanyOpenAuth", sid), content(iv), mc);
|
||||
if (!hasContent(prc))
|
||||
return mkfailure<int>(reason(prc));
|
||||
|
||||
|
|
@ -288,13 +288,13 @@ static int checkAuthn(request_rec *r) {
|
|||
// Handle OAuth authorize request step
|
||||
if (step == "authorize") {
|
||||
r->ap_auth_type = const_cast<char*>(atype);
|
||||
return httpd::reportStatus(authorize(args, r, sc));
|
||||
return httpd::reportStatus(authorize(args, r, sc.appkeys));
|
||||
}
|
||||
|
||||
// Handle OAuth access_token request step
|
||||
if (step == "access_token") {
|
||||
r->ap_auth_type = const_cast<char*>(atype);
|
||||
return httpd::reportStatus(access_token(args, r, sc));
|
||||
return httpd::reportStatus(accessToken(args, r, sc.appkeys, sc.cs, sc.mc));
|
||||
}
|
||||
|
||||
// Redirect to the login page
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue