Catch up some changes.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Fri, 8 Jun 2007 20:15:01 +0000 (20:15 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Fri, 8 Jun 2007 20:15:01 +0000 (20:15 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2294 cb58f699-b61c-0410-a6fe-9272a202ed29

isapi_shib/isapi_shib.cpp
isapi_shib/isapi_shib.vcproj
nsapi_shib/nsapi_shib.vcproj
util/siterefresh.vcproj

index 485e248..a84d748 100644 (file)
@@ -94,6 +94,8 @@ namespace {
     SPConfig* g_Config = NULL;
     map<string,site_t> g_Sites;
     bool g_bNormalizeRequest = true;
+    string g_unsetHeaderValue;
+    bool g_checkSpoofing = true;
     vector<string> g_NoCerts;
 }
 
@@ -192,9 +194,15 @@ extern "C" BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pVer)
     
     // Access the implementation-specifics for site mappings.
     ServiceProvider* sp=g_Config->getServiceProvider();
-    xmltooling::Locker locker(sp);
+    Locker locker(sp);
     const PropertySet* props=sp->getPropertySet("InProcess");
     if (props) {
+        pair<bool,const char*> unsetValue=props->getString("unsetHeaderValue");
+        if (unsetValue.first)
+            g_unsetHeaderValue = unsetValue.second;
+        pair<bool,bool> checkSpoofing=props->getBool("checkSpoofing");
+        if (checkSpoofing.first && !checkSpoofing.second)
+            g_checkSpoofing = false;
         const DOMElement* impl=XMLHelper::getFirstChildElement(props->getElement(),Implementation);
         if (impl && (impl=XMLHelper::getFirstChildElement(impl,ISAPI))) {
             const XMLCh* flag=impl->getAttributeNS(NULL,normalizeRequest);
@@ -345,12 +353,11 @@ class ShibTargetIsapiF : public AbstractSPRequest
   int m_port;
   string m_scheme,m_hostname,m_uri;
   mutable string m_remote_addr,m_content_type,m_method;
+  dynabuf m_allhttp;
 
 public:
-  ShibTargetIsapiF(PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_PREPROC_HEADERS pn, const site_t& site) {
-
-    m_pfc = pfc;
-    m_pn = pn;
+  ShibTargetIsapiF(PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_PREPROC_HEADERS pn, const site_t& site)
+      : m_pfc(pfc), m_pn(pn), m_allhttp(4096) {
 
     // URL path always come from IIS.
     dynabuf var(256);
@@ -430,10 +437,16 @@ public:
     if (level >= SPError)
         LogEvent(NULL, EVENTLOG_ERROR_TYPE, 2100, NULL, msg.c_str());
   }
-  void clearHeader(const char* name) {
-    string hdr(!strcmp(name,"REMOTE_USER") ? "remote-user" : name);
+  void clearHeader(const char* rawname, const char* cginame) {
+    if (g_checkSpoofing) {
+        if (m_allhttp.empty())
+               GetServerVariable(m_pfc,"ALL_HTTP",m_allhttp,4096);
+        if (strstr(m_allhttp, cginame))
+            throw opensaml::SecurityPolicyException("Attempt to spoof header ($1) was detected.", params(1, rawname));
+    }
+    string hdr(!strcmp(rawname,"REMOTE_USER") ? "remote-user" : rawname);
     hdr += ':';
-    m_pn->SetHeader(m_pfc, const_cast<char*>(hdr.c_str()), "");
+    m_pn->SetHeader(m_pfc, const_cast<char*>(hdr.c_str()), const_cast<char*>(g_unsetHeaderValue.c_str()));
   }
   void setHeader(const char* name, const char* value) {
     string hdr(name);
@@ -443,8 +456,8 @@ public:
   string getHeader(const char* name) const {
     string hdr(name);
     hdr += ':';
-    dynabuf buf(1024);
-    GetHeader(m_pn, m_pfc, const_cast<char*>(hdr.c_str()), buf, 1024, false);
+    dynabuf buf(256);
+    GetHeader(m_pn, m_pfc, const_cast<char*>(hdr.c_str()), buf, 256, false);
     return string(buf);
   }
   void setRemoteUser(const char* user) {
@@ -856,9 +869,9 @@ public:
   }
 
   // Not used in the extension.
-  virtual void clearHeader(const char* name) { throw runtime_error("clearHeader not implemented"); }
-  virtual void setHeader(const char* name, const char* value) { throw runtime_error("setHeader not implemented"); }
-  virtual void setRemoteUser(const char* user) { throw runtime_error("setRemoteUser not implemented"); }
+  void clearHeader(const char* rawname, const char* cginame) { throw runtime_error("clearHeader not implemented"); }
+  void setHeader(const char* name, const char* value) { throw runtime_error("setHeader not implemented"); }
+  void setRemoteUser(const char* user) { throw runtime_error("setRemoteUser not implemented"); }
 };
 
 extern "C" DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)
index b1324c7..589df07 100644 (file)
@@ -15,8 +15,8 @@
        <Configurations>
                <Configuration
                        Name="Release|Win32"
-                       OutputDirectory=".\Release"
-                       IntermediateDirectory=".\Release"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
                        ConfigurationType="2"
                        InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
                        UseOfMFC="0"
@@ -79,7 +79,6 @@
                                Name="VCLinkerTool"
                                AdditionalOptions="/export:GetExtensionVersion /export:GetFilterVersion /export:TerminateExtension /export:TerminateFilter /export:HttpFilterProc /export:HttpExtensionProc"
                                AdditionalDependencies="log4cpp.lib xerces-c_2.lib xmltooling-lite1.lib"
-                               OutputFile=".\Release/isapi_shib.dll"
                                LinkIncremental="1"
                                SuppressStartupBanner="true"
                                AdditionalLibraryDirectories="..\..\cpp-xmltooling\Release"
                </Configuration>
                <Configuration
                        Name="Debug|Win32"
-                       OutputDirectory=".\Debug"
-                       IntermediateDirectory=".\Debug"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
                        ConfigurationType="2"
                        InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
                        UseOfMFC="0"
                                Name="VCLinkerTool"
                                AdditionalOptions="/export:GetExtensionVersion /export:GetFilterVersion /export:TerminateExtension /export:TerminateFilter /export:HttpFilterProc /export:HttpExtensionProc"
                                AdditionalDependencies="log4cppD.lib xerces-c_2D.lib xmltooling-lite1D.lib"
-                               OutputFile=".\Debug/isapi_shib.dll"
                                LinkIncremental="2"
                                SuppressStartupBanner="true"
                                AdditionalLibraryDirectories="&quot;..\..\cpp-xmltooling\Debug&quot;"
index 0267d9f..0b62d28 100644 (file)
@@ -15,8 +15,8 @@
        <Configurations>
                <Configuration
                        Name="Release|Win32"
-                       OutputDirectory=".\Release"
-                       IntermediateDirectory=".\Release"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
                        ConfigurationType="2"
                        InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
                        UseOfMFC="0"
@@ -77,7 +77,6 @@
                        <Tool
                                Name="VCLinkerTool"
                                AdditionalDependencies="log4cpp.lib xerces-c_2.lib xmltooling-lite1.lib ns-httpd30.lib"
-                               OutputFile=".\Release/nsapi_shib.dll"
                                LinkIncremental="1"
                                SuppressStartupBanner="true"
                                AdditionalLibraryDirectories="&quot;..\..\cpp-xmltooling\Release&quot;"
                </Configuration>
                <Configuration
                        Name="Debug|Win32"
-                       OutputDirectory=".\Debug"
-                       IntermediateDirectory=".\Debug"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
                        ConfigurationType="2"
                        InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
                        UseOfMFC="0"
                        <Tool
                                Name="VCLinkerTool"
                                AdditionalDependencies="log4cppD.lib xerces-c_2D.lib xmltooling-lite1D.lib ns-httpd30.lib"
-                               OutputFile=".\Debug/nsapi_shib.dll"
                                LinkIncremental="2"
                                SuppressStartupBanner="true"
                                AdditionalLibraryDirectories="&quot;..\..\cpp-xmltooling\Debug&quot;"
index 1192ffb..b7f8a12 100644 (file)
@@ -73,7 +73,6 @@
                        <Tool
                                Name="VCLinkerTool"
                                AdditionalDependencies="log4cpp.lib xerces-c_2.lib xsec_1.lib saml2.lib"
-                               OutputFile=".\Release/siterefresh.exe"
                                LinkIncremental="1"
                                SuppressStartupBanner="true"
                                AdditionalLibraryDirectories="..\..\cpp-opensaml2\Release;..\..\cpp-xmltooling\Release"
                        <Tool
                                Name="VCLinkerTool"
                                AdditionalDependencies="log4cppD.lib xerces-c_2D.lib xsec_1D.lib saml2D.lib xmltooling1D.lib"
-                               OutputFile=".\Debug/siterefresh.exe"
                                LinkIncremental="2"
                                SuppressStartupBanner="true"
                                AdditionalLibraryDirectories="..\..\cpp-opensaml2\Debug;..\..\cpp-xmltooling\Debug"