[cpp-sp] branch main updated: Add various constants, adjust to allow for empty attribute list.

Scott Cantor cantor.2 at osu.edu
Thu Jun 12 17:03:47 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=48a70f8679d1098ef8afd9eb03d05f49f36b8bf1

The following commit(s) were added to refs/heads/main by this push:
     new 48a70f86 Add various constants, adjust to allow for empty attribute list.
48a70f86 is described below

commit 48a70f8679d1098ef8afd9eb03d05f49f36b8bf1
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jun 12 13:03:41 2025 -0400

    Add various constants, adjust to allow for empty attribute list.
---
 apache/mod_shib_24.cpp                                  |  2 +-
 shibsp/Agent.cpp                                        |  4 ++--
 shibsp/RequestMapper.h                                  |  2 ++
 shibsp/attribute/AttributeConfiguration.h               |  8 ++++++--
 shibsp/attribute/impl/DefaultAttributeConfiguration.cpp | 11 ++++++-----
 shibsp/handler/impl/SessionHandler.cpp                  | 12 ++++++++----
 shibsp/impl/XMLAccessControl.cpp                        |  8 ++++----
 shibsp/impl/XMLRequestMapper.cpp                        |  2 ++
 8 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/apache/mod_shib_24.cpp b/apache/mod_shib_24.cpp
index 17fbc455..829cbdb3 100644
--- a/apache/mod_shib_24.cpp
+++ b/apache/mod_shib_24.cpp
@@ -1008,7 +1008,7 @@ AccessControl::aclresult_t htAccessControl::doShibAttr(
     }
 
     const AttributeConfiguration& attrConfig =
-        sta.getAgent().getAttributeConfiguration(sta.getRequestSettings().first->getString("attributeConfigID"));
+        sta.getAgent().getAttributeConfiguration(sta.getRequestSettings().first->getString(RequestMapper::ATTRIBUTE_CONFIG_ID_PROP_NAME));
 
     bool regexp = false;
     while (*params) {
diff --git a/shibsp/Agent.cpp b/shibsp/Agent.cpp
index 7a268a51..96955cd1 100644
--- a/shibsp/Agent.cpp
+++ b/shibsp/Agent.cpp
@@ -179,7 +179,7 @@ pair<bool,long> Agent::doAuthentication(SPRequest& request, bool handler) const
         }
 
         request.getAgent().getAttributeConfiguration(
-            request.getRequestSettings().first->getString("attributeConfigID")
+            request.getRequestSettings().first->getString(RequestMapper::ATTRIBUTE_CONFIG_ID_PROP_NAME)
             ).clearHeaders(request);
 
         bool sessionExists = false;
@@ -357,7 +357,7 @@ pair<bool,long> Agent::doExport(SPRequest& request, bool requireSession) const
 
         // Export the attributes.
         request.getAgent().getAttributeConfiguration(
-            request.getRequestSettings().first->getString("attributeConfigID")
+            request.getRequestSettings().first->getString(RequestMapper::ATTRIBUTE_CONFIG_ID_PROP_NAME)
             ).exportAttributes(request, *(session.mutex()));
 
         return make_pair(false,0L);
diff --git a/shibsp/RequestMapper.h b/shibsp/RequestMapper.h
index 13e863f3..f3348cda 100644
--- a/shibsp/RequestMapper.h
+++ b/shibsp/RequestMapper.h
@@ -55,6 +55,8 @@ namespace shibsp {
         typedef std::pair<const PropertySet*,AccessControl*> Settings;
 
         static const char APPLICATION_ID_PROP_NAME[];
+        static const char ATTRIBUTE_CONFIG_ID_PROP_NAME[];
+        static const char SESSION_HOOK_PROP_NAME[];
         static const char LIFETIME_PROP_NAME[];
         static const char TIMEOUT_PROP_NAME[];
         static const char CONSISTENT_ADDRESS_PROP_NAME[];
diff --git a/shibsp/attribute/AttributeConfiguration.h b/shibsp/attribute/AttributeConfiguration.h
index 219b34de..4c735e97 100644
--- a/shibsp/attribute/AttributeConfiguration.h
+++ b/shibsp/attribute/AttributeConfiguration.h
@@ -56,13 +56,17 @@ namespace shibsp {
         virtual ~AttributeConfiguration();
 
         /** Used in ACL implementations to enforce legacy authnContextClassRef rule. */
-        static const char LEGACY_CLASSREF_ATTRIBUTE_PROP_PATH[];
+        static const char LEGACY_CLASSREF_ATTRIBUTE_PROP_NAME[];
         static const char LEGACY_CLASSREF_ATTRIBUTE_PROP_DEFAULT[];
 
         /** Used in ACL implementation to enforce legacy time-since-authn rule. */
-        static const char LEGACY_AUTHTIME_ATTRIBUTE_PROP_PATH[];
+        static const char LEGACY_AUTHTIME_ATTRIBUTE_PROP_NAME[];
         static const char LEGACY_AUTHTIME_ATTRIBUTE_PROP_DEFAULT[];
 
+        /** Delimiter to separate multiple attribute values in exported variables. */
+        static const char VALUE_DELIMITER_PROP_NAME[];
+        static const char VALUE_DELIMITER_PROP_DEFAULT[];
+
         /**
          * Post-process a collection of attributes and values from the hub for use by agent code.
          * 
diff --git a/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp b/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
index c879044f..1465ed40 100644
--- a/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
+++ b/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
@@ -80,11 +80,13 @@ namespace {
 
 };
 
-const char AttributeConfiguration::LEGACY_CLASSREF_ATTRIBUTE_PROP_PATH[] = "legacyClassRefAttribute";
-const char AttributeConfiguration::LEGACY_CLASSREF_ATTRIBUTE_PROP_DEFAULT[] = "Shib-AuthnContext-Class";
+const char AttributeConfiguration::LEGACY_CLASSREF_ATTRIBUTE_PROP_NAME[] = "legacyClassRefAttribute";
+const char AttributeConfiguration::LEGACY_AUTHTIME_ATTRIBUTE_PROP_NAME[] = "legacyAuthnTimeAttribute";
+const char AttributeConfiguration::VALUE_DELIMITER_PROP_NAME[] = "attributeValueDelimiter";
 
-const char AttributeConfiguration::LEGACY_AUTHTIME_ATTRIBUTE_PROP_PATH[] = "legacyAuthnTimeAttribute";
+const char AttributeConfiguration::LEGACY_CLASSREF_ATTRIBUTE_PROP_DEFAULT[] = "Shib-AuthnContext-Class";
 const char AttributeConfiguration::LEGACY_AUTHTIME_ATTRIBUTE_PROP_DEFAULT[] = "Shib-Authentication-Instant";
+const char AttributeConfiguration::VALUE_DELIMITER_PROP_DEFAULT[] = ";";
 
 
 AttributeConfiguration::AttributeConfiguration() {}
@@ -202,7 +204,6 @@ bool DefaultAttributeConfiguration::processAttributes(DDF& attributes) const
 
     if (attributes.first().isnull()) {
         m_log.warn("no valid attributes remain in session after processing");
-        return false;
     }
     return true;
 }
@@ -229,7 +230,7 @@ void DefaultAttributeConfiguration::exportAttributes(SPRequest& request, const S
     RequestMapper::Settings settings = request.getRequestSettings();
     const URLEncoder& encoder = AgentConfig::getConfig().getURLEncoder();
 
-    const char* delim = getString("attributeValueDelimiter", ";");
+    const char* delim = getString(VALUE_DELIMITER_PROP_NAME, VALUE_DELIMITER_PROP_DEFAULT);
     size_t delim_len = strlen(delim);
 
     // Default export strategy will include duplicates.
diff --git a/shibsp/handler/impl/SessionHandler.cpp b/shibsp/handler/impl/SessionHandler.cpp
index c8508497..cbf41872 100644
--- a/shibsp/handler/impl/SessionHandler.cpp
+++ b/shibsp/handler/impl/SessionHandler.cpp
@@ -152,7 +152,9 @@ pair<bool,long> SessionHandler::doJSON(SPRequest& request) const
 
     s << "{ ";
     s << "\"expiration\": ";
-    s << ((session.mutex()->getCreation() + request.getRequestSettings().first->getUnsignedInt("lifetime", 28800) - time(nullptr)) / 60);
+    s << ((session.mutex()->getCreation() +
+        request.getRequestSettings().first->getUnsignedInt(RequestMapper::LIFETIME_PROP_NAME, RequestMapper::LIFETIME_PROP_DEFAULT) -
+            time(nullptr)) / 60);
 
     /*
         attributes: [ { "name": "foo", "values" : count } ]
@@ -221,8 +223,8 @@ pair<bool,long> SessionHandler::doHTML(SPRequest& request) const
 {
     // Default delimiter is semicolon but is configurable.
     const char* delim = request.getAgent().getAttributeConfiguration(
-        request.getRequestSettings().first->getString("attributeConfigID")
-        ).getString("attributeValueDelimiter", ";");
+        request.getRequestSettings().first->getString(RequestMapper::ATTRIBUTE_CONFIG_ID_PROP_NAME)
+        ).getString(AttributeConfiguration::VALUE_DELIMITER_PROP_NAME, AttributeConfiguration::VALUE_DELIMITER_PROP_DEFAULT);
     size_t delim_len = strlen(delim);
 
     stringstream s;
@@ -245,7 +247,9 @@ pair<bool,long> SessionHandler::doHTML(SPRequest& request) const
     s << "<u>Miscellaneous</u>" << endl;
 
     s << "<strong>Session Expiration (barring inactivity):</strong> ";
-    s << ((session.mutex()->getCreation() + request.getRequestSettings().first->getUnsignedInt("lifetime", 28800) - time(nullptr)) / 60) << " minute(s)" << endl;
+    s << ((session.mutex()->getCreation() +
+        request.getRequestSettings().first->getUnsignedInt(RequestMapper::LIFETIME_PROP_NAME, RequestMapper::LIFETIME_PROP_DEFAULT) -
+            time(nullptr)) / 60) << " minute(s)" << endl;
     s << endl << "<u>Attributes</u>" << endl;
 
     string key;
diff --git a/shibsp/impl/XMLAccessControl.cpp b/shibsp/impl/XMLAccessControl.cpp
index 67cca34b..444542bf 100644
--- a/shibsp/impl/XMLAccessControl.cpp
+++ b/shibsp/impl/XMLAccessControl.cpp
@@ -194,12 +194,12 @@ AccessControl::aclresult_t Rule::authorized(const SPRequest& request, const Sess
     // Last two rule types rely on AttributeConfiguration...
     
     const AttributeConfiguration& attributeConfig = request.getAgent().getAttributeConfiguration(
-        request.getRequestSettings().first->getString("attributeConfigID")
+        request.getRequestSettings().first->getString(RequestMapper::ATTRIBUTE_CONFIG_ID_PROP_NAME)
         );
 
     if (m_alias == "authnContextClassRef") {
         actual_alias = attributeConfig.getString(
-            AttributeConfiguration::LEGACY_CLASSREF_ATTRIBUTE_PROP_PATH,
+            AttributeConfiguration::LEGACY_CLASSREF_ATTRIBUTE_PROP_NAME,
             AttributeConfiguration::LEGACY_CLASSREF_ATTRIBUTE_PROP_DEFAULT);
     }
 
@@ -272,12 +272,12 @@ AccessControl::aclresult_t RuleRegex::authorized(const SPRequest& request, const
     // Last two rule types rely on AttributeConfiguration...
     
     const AttributeConfiguration& attributeConfig = request.getAgent().getAttributeConfiguration(
-        request.getRequestSettings().first->getString("attributeConfigID")
+        request.getRequestSettings().first->getString(RequestMapper::ATTRIBUTE_CONFIG_ID_PROP_NAME)
         );
 
     if (m_alias == "authnContextClassRef") {
         actual_alias = attributeConfig.getString(
-            AttributeConfiguration::LEGACY_CLASSREF_ATTRIBUTE_PROP_PATH,
+            AttributeConfiguration::LEGACY_CLASSREF_ATTRIBUTE_PROP_NAME,
             AttributeConfiguration::LEGACY_CLASSREF_ATTRIBUTE_PROP_DEFAULT);
     }
 
diff --git a/shibsp/impl/XMLRequestMapper.cpp b/shibsp/impl/XMLRequestMapper.cpp
index 54afad76..dc904de8 100644
--- a/shibsp/impl/XMLRequestMapper.cpp
+++ b/shibsp/impl/XMLRequestMapper.cpp
@@ -156,6 +156,8 @@ void SHIBSP_API shibsp::registerRequestMappers()
 }
 
 const char RequestMapper::APPLICATION_ID_PROP_NAME[] = "applicationId";
+const char RequestMapper::ATTRIBUTE_CONFIG_ID_PROP_NAME[] = "attributeConfigId";
+const char RequestMapper::SESSION_HOOK_PROP_NAME[] = "sessionHook";
 const char RequestMapper::LIFETIME_PROP_NAME[] = "lifetime";
 const char RequestMapper::TIMEOUT_PROP_NAME[] = "timeout";
 const char RequestMapper::CONSISTENT_ADDRESS_PROP_NAME[] = "consistentAddress";

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


More information about the commits mailing list