From 1c20f12ba18ce1285a978ba9b3d33b21c29a858e Mon Sep 17 00:00:00 2001 From: erickson Date: Sat, 19 Aug 2006 17:08:13 +0000 Subject: [PATCH] sending authtoken in request header and logging to activity log git-svn-id: svn://svn.open-ils.org/ILS/trunk@5606 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/common/js/RemoteRequest.js | 10 +++++++++- OpenSRF/src/gateway/osrf_json_gateway.c | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Open-ILS/web/opac/common/js/RemoteRequest.js b/Open-ILS/web/opac/common/js/RemoteRequest.js index cefe1549d4..ef9d1b36de 100644 --- a/Open-ILS/web/opac/common/js/RemoteRequest.js +++ b/Open-ILS/web/opac/common/js/RemoteRequest.js @@ -218,6 +218,8 @@ RemoteRequest.prototype.send = function(blocking) { if(this.cancelled) return; + + /* determine the xmlhttp server dynamically */ var url = location.protocol + "//" + location.host + "/" + XML_HTTP_GATEWAY; @@ -249,13 +251,19 @@ RemoteRequest.prototype.send = function(blocking) { return; } - if( this.type == 'POST' ) { data = this.param_string; this.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } + try { + var ses = cookieManager.read(COOKIE_SES); + if(!ses && isXUL()) ses = xulG['authtoken']; + if( ses ) this.xmlhttp.setRequestHeader('X-OILS-Authtoken', ses); + } catch(e) {} + + try{ this.xmlhttp.send( data ); } catch(e){} this.sendCount += 1; diff --git a/OpenSRF/src/gateway/osrf_json_gateway.c b/OpenSRF/src/gateway/osrf_json_gateway.c index 1425e4620e..213ea52a23 100644 --- a/OpenSRF/src/gateway/osrf_json_gateway.c +++ b/OpenSRF/src/gateway/osrf_json_gateway.c @@ -133,10 +133,24 @@ static int osrf_json_gateway_method_handler (request_rec *r) { } else { + /* This will log all heaers to the apache error log + const apr_array_header_t* arr = apr_table_elts(r->headers_in); + const void* ptr; + + while( (ptr = apr_array_pop(arr)) ) { + apr_table_entry_t* e = (apr_table_entry_t*) ptr; + fprintf(stderr, "Table entry: %s : %s\n", e->key, e->val ); + } + fflush(stderr); + */ + + /* ----------------------------------------------------------------- */ /* log all requests to the activity log */ + const char* authtoken = apr_table_get(r->headers_in, "X-OILS-Authtoken"); + if(!authtoken) authtoken = ""; growing_buffer* act = buffer_init(128); - buffer_fadd(act, "[%s] %s %s", r->connection->remote_ip, service, method ); + buffer_fadd(act, "[%s] [%s] %s %s", r->connection->remote_ip, authtoken, service, method ); char* str; int i = 0; while( (str = osrfStringArrayGetString(mparams, i++)) ) if( i == 1 ) buffer_fadd(act, " %s", str); -- 2.11.0