#undef _XOPEN_SOURCE // causes gethostname conflict in unistd.h
#endif
+#ifdef WIN32
+# define _CRT_NONSTDC_NO_DEPRECATE 1
+# define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+
// SAML Runtime
#include <saml/saml.h>
#include <shib/shib.h>
#include <shib-target/shib-target.h>
#include <xercesc/util/regx/RegularExpression.hpp>
+#ifdef WIN32
+# include <winsock.h>
+#endif
+
#undef _XPG4_2
// Apache specific header files
class ShibTargetApache : public ShibTarget
{
+ mutable string m_body;
+ mutable bool m_gotBody;
+
public:
- ShibTargetApache(request_rec* req) {
+ request_rec* m_req;
+ shib_dir_config* m_dc;
+ shib_server_config* m_sc;
+
+ ShibTargetApache(request_rec* req) : m_gotBody(false) {
m_sc = (shib_server_config*)ap_get_module_config(req->server->module_config, &mod_shib);
m_dc = (shib_dir_config*)ap_get_module_config(req->per_dir_config, &mod_shib);
m_req = req;
}
- ~ShibTargetApache() { }
+ ~ShibTargetApache() {}
virtual void log(ShibLogLevel level, const string &msg) {
ShibTarget::log(level,msg);
char* val = ap_psprintf(m_req->pool, "%s=%s", name.c_str(), value.c_str());
ap_table_addn(m_req->err_headers_out, "Set-Cookie", val);
}
- virtual string getArgs(void) { return string(m_req->args ? m_req->args : ""); }
- virtual string getPostData(void) {
+ virtual const char* getQueryString() const { return m_req->args; }
+ virtual const char* getRequestBody() const {
+ if (m_gotBody)
+ return m_body.c_str();
// Read the posted data
if (ap_setup_client_block(m_req, REQUEST_CHUNKED_ERROR))
- throw FatalProfileException("Apache function (setup_client_block) failed while reading profile submission.");
+ throw SAMLException("Apache function (setup_client_block) failed while reading POST request body.");
if (!ap_should_client_block(m_req))
- throw FatalProfileException("Apache function (should_client_block) failed while reading profile submission.");
+ throw SAMLException("Apache function (should_client_block) failed while reading POST request body.");
if (m_req->remaining > 1024*1024)
- throw FatalProfileException("Blocked too-large a submission to profile endpoint.");
- string cgistr;
+ throw SAMLException("Blocked POST request body larger than size limit.");
+ m_gotBody=true;
char buff[HUGE_STRING_LEN];
- ap_hard_timeout("[mod_shib] getPostData", m_req);
+ ap_hard_timeout("[mod_shib] getRequestBody", m_req);
memset(buff, 0, sizeof(buff));
while (ap_get_client_block(m_req, buff, sizeof(buff)-1) > 0) {
ap_reset_timeout(m_req);
- cgistr += buff;
+ m_body += buff;
memset(buff, 0, sizeof(buff));
}
ap_kill_timeout(m_req);
-
- return cgistr;
+ return m_body.c_str();
}
virtual void clearHeader(const string &name) {
ap_table_unset(m_req->headers_in, name.c_str());
}
virtual void* returnDecline(void) { return (void*)DECLINED; }
virtual void* returnOK(void) { return (void*)OK; }
-
- request_rec* m_req;
- shib_dir_config* m_dc;
- shib_server_config* m_sc;
};
/********************************************************************************/
try {
g_Config=&ShibTargetConfig::getConfig();
g_Config->setFeatures(
+ ShibTargetConfig::Caching |
ShibTargetConfig::Listener |
ShibTargetConfig::Metadata |
ShibTargetConfig::AAP |
ShibTargetConfig::RequestMapper |
- ShibTargetConfig::LocalExtensions |
+ ShibTargetConfig::InProcess |
ShibTargetConfig::Logging
);
if (!g_Config->init(g_szSchemaDir)) {
#include "config_win32.h"
+#define _CRT_NONSTDC_NO_DEPRECATE 1
+#define _CRT_SECURE_NO_DEPRECATE 1
+
// SAML Runtime
#include <saml/saml.h>
#include <shib/shib.h>
g_Config=&ShibTargetConfig::getConfig();
g_Config->setFeatures(
ShibTargetConfig::Listener |
+ ShibTargetConfig::Caching |
ShibTargetConfig::Metadata |
ShibTargetConfig::AAP |
ShibTargetConfig::RequestMapper |
- ShibTargetConfig::LocalExtensions |
+ ShibTargetConfig::InProcess |
ShibTargetConfig::Logging
);
if (!g_Config->init(schemadir)) {
// Set the cookie for later. Use it during the redirect.
m_cookie += "Set-Cookie: " + name + "=" + value + "\r\n";
}
- virtual string getArgs(void) { throw runtime_error("getArgs not implemented"); }
- virtual string getPostData(void) { throw runtime_error("getPostData not implemented"); }
+ virtual const char* getQueryString() const { throw runtime_error("getQueryString not implemented"); }
+ virtual const char* getRequestBody() const { throw runtime_error("getRequestBody not implemented"); }
};
DWORD WriteClientError(PHTTP_FILTER_CONTEXT pfc, const char* msg)
{
LPEXTENSION_CONTROL_BLOCK m_lpECB;
string m_cookie;
+ mutable string m_body;
+ mutable bool m_gotBody;
public:
- ShibTargetIsapiE(LPEXTENSION_CONTROL_BLOCK lpECB, const site_t& site) {
+ ShibTargetIsapiE(LPEXTENSION_CONTROL_BLOCK lpECB, const site_t& site) : m_gotBody(false) {
dynabuf ssl(5);
GetServerVariable(lpECB,"HTTPS",ssl,5);
bool SSL=(ssl=="on" || ssl=="ON");
// Set the cookie for later. Use it during the redirect.
m_cookie += "Set-Cookie: " + name + "=" + value + "\r\n";
}
- virtual string getArgs(void) {
- return string(m_lpECB->lpszQueryString ? m_lpECB->lpszQueryString : "");
+ virtual const char* getQueryString() const {
+ return m_lpECB->lpszQueryString;
}
- virtual string getPostData(void) {
+ virtual const char* getRequestBody() const {
+ if (m_gotBody)
+ return m_body.c_str();
if (m_lpECB->cbTotalBytes > 1024*1024) // 1MB?
- throw FatalProfileException("Blocked too-large a submission to profile endpoint.");
+ throw SAMLException("Size of POST request body exceeded limit.");
else if (m_lpECB->cbTotalBytes != m_lpECB->cbAvailable) {
- string cgistr;
+ m_gotBody=true;
char buf[8192];
DWORD datalen=m_lpECB->cbTotalBytes;
while (datalen) {
DWORD buflen=8192;
BOOL ret = m_lpECB->ReadClient(m_lpECB->ConnID, buf, &buflen);
if (!ret || !buflen)
- throw FatalProfileException("Error reading profile submission from browser.");
- cgistr.append(buf, buflen);
+ throw SAMLException("Error reading POST request body from browser.");
+ m_body.append(buf, buflen);
datalen-=buflen;
}
- return cgistr;
}
- else
- return string(reinterpret_cast<char*>(m_lpECB->lpbData),m_lpECB->cbAvailable);
+ else {
+ m_gotBody=true;
+ m_body.assign(reinterpret_cast<char*>(m_lpECB->lpbData),m_lpECB->cbAvailable);
+ }
+ return m_body.c_str();
}
virtual void* sendPage(
const string &msg,