#include <yaz/tokenizer.h>
#include <yaz/zoom.h>
#include <yaz/otherinfo.h>
+#include <yaz/match_glob.h>
namespace mp = metaproxy_1;
namespace yf = mp::filter;
public:
std::string authentication;
std::string authenticationMode;
+ std::string contentAuthentication;
std::string cfAuth;
std::string cfProxy;
std::string cfSubDB;
std::string torus_searchable_url;
std::string torus_content_url;
std::string torus_auth_url;
+ std::string torus_allow_ip;
std::string default_realm;
std::string torus_auth_hostname;
std::map<std::string,std::string> fieldmap;
s->authenticationMode = mp::xml::get_text(ptr);
}
else if (!strcmp((const char *) ptr->name,
+ "contentAuthentication"))
+ {
+ s->contentAuthentication = mp::xml::get_text(ptr);
+ }
+ else if (!strcmp((const char *) ptr->name,
"cfAuth"))
{
s->cfAuth = mp::xml::get_text(ptr);
torus_content_url = mp::xml::get_text(attr->children);
else if (!strcmp((const char *) attr->name, "auth_url"))
torus_auth_url = mp::xml::get_text(attr->children);
+ else if (!strcmp((const char *) attr->name, "allow_ip"))
+ torus_allow_ip = mp::xml::get_text(attr->children);
else if (!strcmp((const char *) attr->name, "realm"))
default_realm = mp::xml::get_text(attr->children);
else if (!strcmp((const char *) attr->name, "auth_hostname"))
maximumRecords > 0 */
b->set_option("piggyback", sptr->piggyback ? "1" : "0");
+ if (content_authentication.length() == 0)
+ content_authentication = sptr->contentAuthentication;
+
if (authentication.length() == 0)
authentication = sptr->authentication;
struct yaz_poll_fd pfd;
yaz_poll_add(pfd.input_mask, yaz_poll_except);
- if (cs->io_pending && CS_WANT_WRITE)
+ if (cs->io_pending & CS_WANT_WRITE)
yaz_poll_add(pfd.input_mask, yaz_poll_write);
if (cs->io_pending & CS_WANT_READ)
yaz_poll_add(pfd.input_mask, yaz_poll_read);
}
Z_OtherInformation **oi = &req->otherInfo;
- const char *ip =
+ const char *ip_cstr =
yaz_oi_get_string_oid(oi, yaz_oid_userinfo_client_ip, 1, 0);
- if (!ip)
- ip = package.origin().get_address().c_str();
+ std::string ip;
+ if (ip_cstr)
+ ip = ip_cstr;
+ else
+ ip = package.origin().get_address();
- yaz_log(YLOG_LOG, "IP=%s", ip);
+ yaz_log(YLOG_LOG, "IP=%s", ip.c_str());
+ {
+ NMEM nmem = nmem_create();
+ char **darray;
+ int i, num;
+ nmem_strsplit_blank(nmem, m_p->torus_allow_ip.c_str(), &darray, &num);
+ for (i = 0; i < num; i++)
+ {
+ yaz_log(YLOG_LOG, "check against %s+%s", darray[i], ip.c_str());
+ if (yaz_match_glob(darray[i], ip.c_str()))
+ break;
+ }
+ nmem_destroy(nmem);
+ if (i < num)
+ return; /* allow this IP */
+ }
std::string torus_query;
int failure_code;