[cpp-sp] branch main updated: Add some property default constants.

Scott Cantor cantor.2 at osu.edu
Tue Jan 14 21:32:09 UTC 2025


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=bb37e0f46557999bd9a5d77ed3e6b98cf552f417

The following commit(s) were added to refs/heads/main by this push:
     new bb37e0f4 Add some property default constants.
bb37e0f4 is described below

commit bb37e0f46557999bd9a5d77ed3e6b98cf552f417
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Jan 14 16:32:05 2025 -0500

    Add some property default constants.
---
 apache/mod_shib_24.cpp               |  6 +++---
 iis7_shib/IIS7Request.cpp            | 10 ++++++----
 iis7_shib/ShibHttpModule.cpp         |  2 +-
 iis7_shib/register.cpp               |  4 ++--
 shibsp/Agent.cpp                     |  5 +++++
 shibsp/Agent.h                       |  6 +++++-
 shibsp/platform/iis/ModuleConfig.cpp |  6 ++++++
 shibsp/platform/iis/ModuleConfig.h   |  6 ++++++
 8 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/apache/mod_shib_24.cpp b/apache/mod_shib_24.cpp
index 53978b02..e3db898e 100644
--- a/apache/mod_shib_24.cpp
+++ b/apache/mod_shib_24.cpp
@@ -1450,14 +1450,14 @@ extern "C" void shib_child_init(apr_pool_t* p, server_rec* s)
     ap_log_error(APLOG_MARK, APLOG_INFO|APLOG_NOERRNO, 0, s, "child_init: shib_module initializing in pid (%d)", (int)getpid());
 
     const Agent& agent = g_Config->getAgent();
-    g_unsetHeaderValue = agent.getString(Agent::UNSET_HEADER_VALUE_PROP_NAME);
-    g_checkSpoofing = agent.getBool(Agent::CHECK_SPOOFING_PROP_NAME, true);
+    g_unsetHeaderValue = agent.getString(Agent::UNSET_HEADER_VALUE_PROP_NAME, "");
+    g_checkSpoofing = agent.getBool(Agent::CHECK_SPOOFING_PROP_NAME, Agent::CHECK_SPOOFING_PROP_DEFAULT);
     if (g_checkSpoofing) {
         const char* altkey = agent.getString(Agent::SPOOF_KEY_PROP_NAME);
         if (altkey)
             g_spoofKey = altkey;
     }
-    g_catchAll = agent.getBool(Agent::CATCH_ALL_PROP_NAME, false);
+    g_catchAll = agent.getBool(Agent::CATCH_ALL_PROP_NAME, Agent::CATCH_ALL_PROP_DEFAULT);
 
     // Set the cleanup handler, passing in the server_rec for logging.
     apr_pool_cleanup_register(p, s, &shib_exit, apr_pool_cleanup_null);
diff --git a/iis7_shib/IIS7Request.cpp b/iis7_shib/IIS7Request.cpp
index 7f0191fd..7fea5769 100644
--- a/iis7_shib/IIS7Request.cpp
+++ b/iis7_shib/IIS7Request.cpp
@@ -65,9 +65,10 @@ IIS7Request::IIS7Request(IHttpContext *pHttpContext, IHttpEventProvider *pEventP
         throwError("Get Server Secure", hr);
     }
 
-    m_useHeaders = site.getBool(ModuleConfig::USE_HEADERS_PROP_NAME, false);
+    m_useHeaders = site.getBool(ModuleConfig::USE_HEADERS_PROP_NAME, ModuleConfig::USE_HEADERS_PROP_DEFAULT);
+    // This default matches the previous setting.
     m_safeHeaderNames = site.getBool(ModuleConfig::SAFE_HEADER_NAMES_PROP_NAME, m_useHeaders);
-    m_useVariables = site.getBool(ModuleConfig::USE_VARIABLES_PROP_NAME, true);
+    m_useVariables = site.getBool(ModuleConfig::USE_VARIABLES_PROP_NAME, ModuleConfig::USE_VARIABLES_PROP_DEFAULT);
 
     string prop(site.getString(ModuleConfig::ROLE_ATTRIBUTES_PROP_NAME, "");
     split_to_container(m_roleAttributeNames, prop);
@@ -178,7 +179,8 @@ void IIS7Request::setRemoteUser(const char* user)
     IAuthenticationProvider *auth = dynamic_cast<IAuthenticationProvider*>(m_event);
 
     if (auth) {
-        string authnRole(m_site.getString(ModuleConfig::AUTHENTICATED_ROLE_PROP_NAME, "ShibbolethAuthnN"));
+        string authnRole(m_site.getString(ModuleConfig::AUTHENTICATED_ROLE_PROP_NAME,
+            ModuleConfig::AUTHENTICATED_ROLE_PROP_DEFAULT));
         std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
         m_roles.insert(converter.from_bytes(authnRole));
         auth->SetUser(new ShibUser(user, m_roles));
@@ -213,7 +215,7 @@ void IIS7Request::clearHeader(const char* rawname, const char* cginame)
                 }
             }
         }
-        string unsetHeaderValue(g_Config->getAgent().getString("unsetHeaderValue", ""));
+        string unsetHeaderValue(g_Config->getAgent().getString(Agent::UNSET_HEADER_NAME_PROP_NAME, ""));
         HRESULT hr = m_request->SetHeader(m_safeHeaderNames ? makeSafeHeader(rawname).c_str() : rawname,
             unsetHeaderValue.c_str(), static_cast<USHORT>(unsetHeaderValue.length()), TRUE);
         if (FAILED(hr)) {
diff --git a/iis7_shib/ShibHttpModule.cpp b/iis7_shib/ShibHttpModule.cpp
index 10b71793..887ef83f 100644
--- a/iis7_shib/ShibHttpModule.cpp
+++ b/iis7_shib/ShibHttpModule.cpp
@@ -46,7 +46,7 @@ ShibHttpModule::DoHandler(
     if (!site)
         return RQ_NOTIFICATION_CONTINUE;
 
-    string prefix(site->getString(ModuleConfig::HANDLER_PREFIX_PROP_NAME, "/Shibboleth.sso"));
+    string prefix(site->getString(ModuleConfig::HANDLER_PREFIX_PROP_NAME, ModuleConfig::HANDLER_PREFIX_PROP_DEFAULT));
     std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
     wstring handlerPrefix = converter.from_bytes(prefix);
 
diff --git a/iis7_shib/register.cpp b/iis7_shib/register.cpp
index 44050f97..b9000e13 100644
--- a/iis7_shib/register.cpp
+++ b/iis7_shib/register.cpp
@@ -103,8 +103,8 @@ RegisterModule(
         return E_FAIL;
     }
 
-    g_checkSpoofing = agent.getBool(Agent::CHECK_SPOOFING_PROP_NAME, true);
-    g_catchAll = agent.getBool(Agent::CATCH_ALL_PROP_NAME, true);
+    g_checkSpoofing = agent.getBool(Agent::CHECK_SPOOFING_PROP_NAME, Agent::CHECK_SPOOFING_PROP_DEFAULT);
+    g_catchAll = agent.getBool(Agent::CATCH_ALL_PROP_NAME, Agent::CATCH_ALL_PROP_DEFAULT);
 
     if (g_checkSpoofing) {
         g_spoofKey = agent.getString(Agent::SPOOF_KEY_PROP_NAME, "");
diff --git a/shibsp/Agent.cpp b/shibsp/Agent.cpp
index 91f2fdca..f5e087d2 100644
--- a/shibsp/Agent.cpp
+++ b/shibsp/Agent.cpp
@@ -48,9 +48,14 @@ using namespace shibsp;
 using namespace std;
 
 const char Agent::UNSET_HEADER_VALUE_PROP_NAME[] = "unsetHeaderValue";
+
 const char Agent::CHECK_SPOOFING_PROP_NAME[] = "checkSpoofing";
+bool Agent::CHECK_SPOOFING_PROP_DEFAULT = true;
+
 const char Agent::SPOOF_KEY_PROP_NAME[] = "spoofKey";
+
 const char Agent::CATCH_ALL_PROP_NAME[] = "catchAll";
+bool Agent::CATCH_ALL_PROP_DEFAULT = false;
 
 Agent::Agent()
 {
diff --git a/shibsp/Agent.h b/shibsp/Agent.h
index 98dce087..375e6306 100644
--- a/shibsp/Agent.h
+++ b/shibsp/Agent.h
@@ -134,12 +134,16 @@ namespace shibsp {
          */
         virtual std::pair<bool,long> doHandler(SPRequest& request) const;
 
-        /** Property name constants. */
+        /** Property constants. */
+
         static const char UNSET_HEADER_VALUE_PROP_NAME[];
         static const char CHECK_SPOOFING_PROP_NAME[];
         static const char SPOOF_KEY_PROP_NAME[];
         static const char CATCH_ALL_PROP_NAME[];
 
+        static bool CHECK_SPOOFING_PROP_DEFAULT;
+        static bool CATCH_ALL_PROP_DEFAULT;
+
     protected:
         /** The AuthTypes to "recognize" (defaults to "shibboleth"). */
         std::set<std::string> m_authTypes;
diff --git a/shibsp/platform/iis/ModuleConfig.cpp b/shibsp/platform/iis/ModuleConfig.cpp
index 55017d7c..bdc7ea6f 100644
--- a/shibsp/platform/iis/ModuleConfig.cpp
+++ b/shibsp/platform/iis/ModuleConfig.cpp
@@ -62,6 +62,12 @@ const char ModuleConfig::NORMALIZE_REQUEST_PROP_NAME[] = "normalizeRequest";
 const char ModuleConfig::SAFE_HEADER_NAMES_PROP_NAME[] = "safeHeaderNames";
 const char ModuleConfig::HANDLER_PREFIX_PROP_NAME[] = "handlerPrefix";
 
+bool ModuleConfig::USE_VARIABLES_PROP_DEFAULT = true;
+bool ModuleConfig::USE_HEADERS_PROP_DEFAULT = false;
+const char ModuleConfig::AUTHENTICATED_ROLE_PROP_DEFAULT[] = "ShibbolethAuthN";
+bool ModuleConfig::NORMALIZE_REQUEST_PROP_DEFAULT = true;
+const char ModuleConfig::HANDLER_PREFIX_PROP_DEFAULT[] = "/Shibboleth.sso";
+
 const char ModuleConfig::SITE_NAME_PROP_NAME[] = "name";
 const char ModuleConfig::SITE_SCHEME_PROP_NAME[] = "scheme";
 const char ModuleConfig::SITE_PORT_PROP_NAME[] = "port";
diff --git a/shibsp/platform/iis/ModuleConfig.h b/shibsp/platform/iis/ModuleConfig.h
index 60fd6a22..7f3ec8a6 100644
--- a/shibsp/platform/iis/ModuleConfig.h
+++ b/shibsp/platform/iis/ModuleConfig.h
@@ -56,6 +56,12 @@ namespace shibsp {
             static const char SAFE_HEADER_NAMES_PROP_NAME[];
             static const char HANDLER_PREFIX_PROP_NAME[];
 
+            static bool USE_VARIABLES_PROP_DEFAULT;
+            static bool USE_HEADERS_PROP_DEFAULT;
+            static const char AUTHENTICATED_ROLE_PROP_DEFAULT[];
+            static bool NORMALIZE_REQUEST_PROP_DEFAULT;
+            static const char HANDLER_PREFIX_PROP_DEFAULT[];
+
             // Site
             static const char SITE_NAME_PROP_NAME[];
             static const char SITE_SCHEME_PROP_NAME[];

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list