X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-proxy.cpp;h=a9ca482406e74b9f696de1b3f8061c8171d37da6;hb=e571596972971da916ded37860ec0c84a804adc9;hp=8e4d2e6adf709e6851b19485cceb78bb7c6228d5;hpb=75f60aabe2777970f5b971cf4fce3f03354d5dbc;p=yazproxy-moved-to-github.git diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 8e4d2e6..a9ca482 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy.cpp,v 1.74 2007-04-16 21:54:27 adam Exp $ +/* $Id: yaz-proxy.cpp,v 1.77 2007-05-08 12:05:09 adam Exp $ Copyright (c) 1998-2007, Index Data. This file is part of the yazproxy. @@ -487,7 +487,7 @@ char *Yaz_Proxy::get_cookie(Z_OtherInformation **otherInfo) Z_OtherInformationUnit *oi = update_otherInformation(otherInfo, 0, yaz_oid_userinfo_cookie, 1, 1); - if (oi->which == Z_OtherInfo_characterInfo) + if (oi && oi->which == Z_OtherInfo_characterInfo) return oi->information.characterInfo; return 0; } @@ -497,7 +497,7 @@ char *Yaz_Proxy::get_proxy(Z_OtherInformation **otherInfo) Z_OtherInformationUnit *oi = update_otherInformation(otherInfo, 0, yaz_oid_userinfo_proxy, 1, 1); - if (oi->which == Z_OtherInfo_characterInfo) + if (oi && oi->which == Z_OtherInfo_characterInfo) return oi->information.characterInfo; return 0; } @@ -1011,7 +1011,7 @@ void Yaz_Proxy::convert_records_charset(Z_NamePlusRecordList *p, if (npr->which == Z_NamePlusRecord_databaseRecord) { Z_External *r = npr->u.databaseRecord; - const int *oid = r->direct_reference; + const Odr_oid *oid = r->direct_reference; if (!oid) continue; @@ -2765,24 +2765,51 @@ void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq) m_s2z_present_apdu = 0; m_s2z_stylesheet = 0; - + Z_IdAuthentication *auth = NULL; - if (*authorization_str) + if (srw_pdu->username && srw_pdu->password) { + yaz_log(YLOG_LOG, "username/password: %s/%s\n", + srw_pdu->username, srw_pdu->password); auth = (Z_IdAuthentication *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdAuthentication)); auth->which = Z_IdAuthentication_idPass; auth->u.idPass = (Z_IdPass *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdPass)); auth->u.idPass->groupId = NULL; - char *p = strchr(authorization_str, ':'); - if (p) + auth->u.idPass->password = odr_strdup(m_s2z_odr_init, srw_pdu->password); + auth->u.idPass->userId = odr_strdup(m_s2z_odr_init, srw_pdu->username); + } + else + { + if (*authorization_str) + { + yaz_log(YLOG_LOG, "authorization_str present: %s\n", authorization_str); + auth = (Z_IdAuthentication *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdAuthentication)); + auth->which = Z_IdAuthentication_idPass; + auth->u.idPass = (Z_IdPass *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdPass)); + auth->u.idPass->groupId = NULL; + char *p = strchr(authorization_str, ':'); + if (p) + { + *p = '\0'; + p++; + auth->u.idPass->password = odr_strdup(m_s2z_odr_init, p); + } + auth->u.idPass->userId = odr_strdup(m_s2z_odr_init, authorization_str); + } + else { - *p = '\0'; - p++; - auth->u.idPass->password = odr_strdup(m_s2z_odr_init, p); + // Use _client_ IP as shown in the log entries...! + yaz_log(YLOG_LOG, "No authorization_str present: use client IP: %s\n", m_peername); + + auth = (Z_IdAuthentication *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdAuthentication)); + auth->which = Z_IdAuthentication_idPass; + auth->u.idPass = (Z_IdPass *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdPass)); + auth->u.idPass->groupId = NULL; + auth->u.idPass->password = NULL; + auth->u.idPass->userId = odr_strdup(m_s2z_odr_init, m_peername); } - auth->u.idPass->userId = odr_strdup(m_s2z_odr_init, authorization_str); - } - + } + if (srw_pdu->which == Z_SRW_searchRetrieve_request) {