<domain>127.0.0.1</domain>
</domains>
+ <!-- These are the services that the gateway will serve.
+ Any other requests will receive a HTT_NOT_FOUND -->
+ <services>
+ <service>opensrf.math</service>
+ <service>open-ils.cat</service>
+ <service>open-ils.search</service>
+ <service>open-ils.circ</service>
+ <service>open-ils.actor</service>
+ <service>open-ils.auth</service>
+ </services>
+
+
<!-- jabber login info -->
<username>mylogin</username>
<passwd>mypassword</passwd>
#include "apachetools.h"
#include "opensrf/osrf_app_session.h"
#include "opensrf/osrf_system.h"
+#include "opensrf/osrfConfig.h"
#include "objson/object.h"
#include "objson/json2xml.h"
#include <sys/time.h>
char* osrf_json_gateway_config_file = NULL;
int bootstrapped = 0;
int numserved = 0;
+osrfStringArray* allowedServices = NULL;
static const char* osrf_json_gateway_set_config(cmd_parms *parms, void *config, const char *arg) {
osrf_json_gateway_config *cfg;
static void osrf_json_gateway_child_init(apr_pool_t *p, server_rec *s) {
char* cfg = osrf_json_gateway_config_file;
- if( ! osrf_system_bootstrap_client( cfg, CONFIG_CONTEXT) ) {
+ if( ! osrf_system_bootstrap_client( cfg, CONFIG_CONTEXT ) ) {
ap_log_error( APLOG_MARK, APLOG_ERR, 0, s,
"Unable to Bootstrap OpenSRF Client with config %s..", cfg);
return;
}
+
bootstrapped = 1;
+ allowedServices = osrfNewStringArray(8);
osrfLogInfo(OSRF_LOG_MARK, "Bootstrapping gateway child for requests");
+ osrfConfigGetValueList( NULL, allowedServices, "/services/service" );
+
+ int i;
+ for( i = 0; i < allowedServices->size; i++ ) {
+ fprintf(stderr, "allowed service: %s\n",
+ osrfStringArrayGetString(allowedServices, i));
+ }
-#ifdef OSRF_GATEWAY_ENABLE_RLIMIT /* emergency measures only */
+#ifdef OSRF_GATEWAY_ENABLE_RLIMIT /* emergency test measures only */
struct rlimit lim = { 536870912, 536870912 }; /* 512MB */
setrlimit(RLIMIT_AS, &lim);
setrlimit(RLIMIT_MEMLOCK,&lim);
ap_set_content_type(r, "text/plain");
}
+ int ret = OK;
+
+ if(!(service && method) ||
+ !osrfStringArrayContains(allowedServices, service)) {
- if( service && method ) {
+ osrfLogError(OSRF_LOG_MARK,
+ "Service [%s] not found or not allowed", service);
+ ret = HTTP_NOT_FOUND;
+
+ } else {
osrfLogInfo( OSRF_LOG_MARK, "service=%s, method=%s", service, method );
osrfAppSession* session = osrf_app_client_session_init(service);
osrfLogDebug(OSRF_LOG_MARK, "Gateway served %d requests", ++numserved);
- return OK;
+ return ret;
}