[cpp-sp] branch main updated: Collapse default attr config, and adjust default remoting URL

Scott Cantor cantor.2 at osu.edu
Tue Oct 14 18:48:55 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=c5b7cda55b2fe84ce150785abac26d662a76d809

The following commit(s) were added to refs/heads/main by this push:
     new c5b7cda5 Collapse default attr config, and adjust default remoting URL
c5b7cda5 is described below

commit c5b7cda55b2fe84ce150785abac26d662a76d809
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Oct 14 14:48:42 2025 -0400

    Collapse default attr config, and adjust default remoting URL
---
 configs/Makefile.am                                |  1 -
 configs/agent.ini                                  | 14 ++++++--
 configs/attributes.ini                             | 12 -------
 shibsp/attribute/AttributeConfiguration.h          | 11 ++++++
 .../impl/DefaultAttributeConfiguration.cpp         | 40 +++++++++++++++++-----
 shibsp/impl/DefaultAgent.cpp                       | 23 +++++--------
 .../remoting/impl/AbstractHTTPRemotingService.cpp  |  2 +-
 tests/data/attribute/impl/attributes.ini           |  4 +--
 8 files changed, 65 insertions(+), 42 deletions(-)

diff --git a/configs/Makefile.am b/configs/Makefile.am
index 5b34e0ed..abd95cd4 100644
--- a/configs/Makefile.am
+++ b/configs/Makefile.am
@@ -16,7 +16,6 @@ CONFIGFILES = \
 	globalLogout.html \
 	partialLogout.html \
 	agent.ini \
-	attributes.ini \
 	handlers.ini \
 	request-map.xml
 
diff --git a/configs/agent.ini b/configs/agent.ini
index 64393367..dfe9f381 100644
--- a/configs/agent.ini
+++ b/configs/agent.ini
@@ -9,9 +9,8 @@ defaultLevel = INFO
 #Shibboleth.RemotingService = DEBUG
 #Shibboleth.libcurl = DEBUG
 
-
 [remoting]
-baseURL = http://localhost/idp/profile/sp/
+baseURL = http://localhost:8080/idp/profile/sp/
 #authMethod = none
 #authCachingCookie = __Host-JSESSIONID
 #tlsCAFile = trustfile.pem
@@ -34,3 +33,14 @@ type = filesystem
 path = request-map.xml
 reloadChanges = true
 
+#[attribute-settings]
+#scopeDelimiter = @
+#exportDuplicateValues = true
+#caseInsensitiveAttributes = foo bar
+#legacyClassRefAttribute = Shib-AuthnContext-Class
+#legacyAuthnTimeAttribute = Shib-Authentication-Instant
+# Set to URL to apply URL encoding on export
+#encoding =
+
+#[attribute-mappings]
+#foo = foo
diff --git a/configs/attributes.ini b/configs/attributes.ini
deleted file mode 100644
index 2a108a1d..00000000
--- a/configs/attributes.ini
+++ /dev/null
@@ -1,12 +0,0 @@
-[settings]
-#scopeDelimiter = @
-#exportDuplicateValues = true
-#caseInsensitiveAttributes = foo bar
-#legacyClassRefAttribute = Shib-AuthnContext-Class
-#legacyAuthnTimeAttribute = Shib-Authentication-Instant
-# Set to URL to apply URL encoding on export
-#encoding =
-
-[mappings]
-foo = foo
-
diff --git a/shibsp/attribute/AttributeConfiguration.h b/shibsp/attribute/AttributeConfiguration.h
index 4c735e97..29e92569 100644
--- a/shibsp/attribute/AttributeConfiguration.h
+++ b/shibsp/attribute/AttributeConfiguration.h
@@ -26,6 +26,8 @@
 #include <memory>
 #include <set>
 
+#include <boost/property_tree/ptree_fwd.hpp>
+
 #ifdef SHIBSP_USE_BOOST_REGEX
 # include <boost/regex_fwd.hpp>
 namespace regexp = boost;
@@ -165,6 +167,15 @@ namespace shibsp {
          * @return the corresponding AttributeConfiguration
          */
         static std::unique_ptr<AttributeConfiguration> newAttributeConfiguration(const char* pathname);
+
+        /**
+         * Create a new AttributeConfiguration based on an existing ptree.
+         * 
+         * @param pt  property tree
+         * 
+         * @return the corresponding AttributeConfiguration
+         */
+        static std::unique_ptr<AttributeConfiguration> newAttributeConfiguration(const boost::property_tree::ptree& pt);
     };
 
 };
diff --git a/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp b/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
index a9a1b728..b7815edf 100644
--- a/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
+++ b/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
@@ -59,6 +59,7 @@ namespace {
     class DefaultAttributeConfiguration : public virtual AttributeConfiguration, public virtual BoostPropertySet {
     public:
         DefaultAttributeConfiguration(const char* pathname);
+        DefaultAttributeConfiguration(const ptree& pt);
         ~DefaultAttributeConfiguration() {}
 
         bool processAttributes(DDF& attributes) const;
@@ -70,9 +71,11 @@ namespace {
         bool hasMatchingValue(const Session& session, const char* attributeId, const regexp::regex& expression) const;
 
     private:
+        void init(const ptree& pt);
         const char* getFirstValue(const Session& session, const char* attributeId) const;
 
         Category& m_log;
+        // Unused ptree if we configure via inline.
         ptree m_pt;
         const char* m_scopeDelimiter;
         const char* m_valueDelimiter;
@@ -96,11 +99,28 @@ AttributeConfiguration::AttributeConfiguration() {}
 
 AttributeConfiguration::~AttributeConfiguration() {}
 
+DefaultAttributeConfiguration::DefaultAttributeConfiguration(const ptree& pt)
+    : m_log(Category::getInstance(SHIBSP_LOGCAT ".AttributeConfiguration"))
+{
+    init(pt);
+}
+
 DefaultAttributeConfiguration::DefaultAttributeConfiguration(const char* pathname)
-    : m_log(Category::getInstance(SHIBSP_LOGCAT ".AttributeConfiguration")), m_urlEncoding(false), m_exportDuplicates(true)
+    : m_log(Category::getInstance(SHIBSP_LOGCAT ".AttributeConfiguration"))
+{
+
+    if (!pathname) {
+        throw ConfigurationException("No pathname supplied for creating AttrbuteConfiguration.");
+    }
+
+    ini_parser::read_ini(pathname, m_pt);
+    init(m_pt);
+}
+
+void DefaultAttributeConfiguration::init(const ptree& pt)
 {
-    static const char SETTINGS_PROP_SECTION_NAME[] = "settings";
-    static const char MAPPINGS_PROP_SECTION_NAME[] = "mappings";
+    static const char SETTINGS_PROP_SECTION_NAME[] = "attribute-settings";
+    static const char MAPPINGS_PROP_SECTION_NAME[] = "attribute-mappings";
 
     static const char CASE_INSENSITIVE_ATTRS_PROP_NAME[] = "caseInsensitiveAttributes";
     static const char ENCODING_PROP_NAME[] = "encoding";
@@ -112,17 +132,14 @@ DefaultAttributeConfiguration::DefaultAttributeConfiguration(const char* pathnam
     static const char URL_ENCODING_PROP_VALUE[] = "URL";
     const char SCOPE_DELIMITER_PROP_DEFAULT[] = "@";
 
+    m_urlEncoding = false;
+    m_exportDuplicates = true;
+
     // Populate "built-in" mappings.
     for (const string& name : {"Shib-Application-ID", "Shib-Session-ID", "Shib-Session-Expires", "Shib-Session-Inactivity", "REMOTE_USER"}) {
         m_mappings[name] = name;
     }
 
-    if (!pathname) {
-        return;
-    }
-
-    ini_parser::read_ini(pathname, m_pt);
-
     boost::optional<ptree&> settings = m_pt.get_child_optional(SETTINGS_PROP_SECTION_NAME);
     if (settings) {
         // The load is a convenience, but all the settings are captured here in the c'tor.
@@ -163,6 +180,11 @@ DefaultAttributeConfiguration::DefaultAttributeConfiguration(const char* pathnam
     }
 }
 
+unique_ptr<AttributeConfiguration> AttributeConfiguration::newAttributeConfiguration(const ptree& pt)
+{
+    return unique_ptr<AttributeConfiguration>(new DefaultAttributeConfiguration(pt));
+}
+
 unique_ptr<AttributeConfiguration> AttributeConfiguration::newAttributeConfiguration(const char* pathname)
 {
     return unique_ptr<AttributeConfiguration>(new DefaultAttributeConfiguration(pathname));
diff --git a/shibsp/impl/DefaultAgent.cpp b/shibsp/impl/DefaultAgent.cpp
index 665168b9..76888db1 100644
--- a/shibsp/impl/DefaultAgent.cpp
+++ b/shibsp/impl/DefaultAgent.cpp
@@ -229,7 +229,7 @@ void DefaultAgent::doHandlerConfigurations()
         return;
     }
 
-    boost::optional<ptree&> child = m_pt.get_child_optional("handlers");
+    boost::optional<ptree&> child = m_pt.get_child_optional("handler-configurations");
     if (child) {
         for (const auto& keys : *child) {
             boost::optional<string> path = keys.second.get_value_optional<string>();
@@ -239,7 +239,7 @@ void DefaultAgent::doHandlerConfigurations()
             }
             AgentConfig::getConfig().getPathResolver().resolve(*path, PathResolver::SHIBSP_CFG_FILE);
             m_handlerConfigurations[keys.first] = HandlerConfiguration::newHandlerConfiguration(path->c_str());
-            m_log.info("installed '%s' HandlerConfiguration from %s", keys.first.c_str(), path->c_str());
+            m_log.info("installed HandlerConfiguration '%s' from %s", keys.first.c_str(), path->c_str());
         }
     } else {
         string path("handlers.ini");
@@ -256,27 +256,20 @@ void DefaultAgent::doAttributeConfigurations()
         return;
     }
 
-    boost::optional<ptree&> child = m_pt.get_child_optional("attributes");
+    m_attributeConfigurations["default"] = AttributeConfiguration::newAttributeConfiguration(m_pt);
+    m_log.info("installed 'default' AttributeConfiguration");
+
+    boost::optional<ptree&> child = m_pt.get_child_optional("attribute-configurations");
     if (child) {
         for (const auto& keys : *child) {
             boost::optional<string> path = keys.second.get_value_optional<string>();
             if (!path) {
-                m_log.warn("skipping property key with no value in [attributes] section");
+                m_log.warn("skipping property key with no value in [attribute-configurations] section");
                 continue;
             }
             AgentConfig::getConfig().getPathResolver().resolve(*path, PathResolver::SHIBSP_CFG_FILE);
             m_attributeConfigurations[keys.first] = AttributeConfiguration::newAttributeConfiguration(path->c_str());
-            m_log.info("installed '%s' AttributeConfiguration from %s", keys.first.c_str(), path->c_str());
-        }
-    } else {
-        string path("attributes.ini");
-        AgentConfig::getConfig().getPathResolver().resolve(path, PathResolver::SHIBSP_CFG_FILE);
-        if (FileSupport::exists(path.c_str())) {
-            m_attributeConfigurations["default"] = AttributeConfiguration::newAttributeConfiguration(path.c_str());
-            m_log.info("installed 'default' AttributeConfiguration from %s", path.c_str());
-        } else {
-            m_attributeConfigurations["default"] = AttributeConfiguration::newAttributeConfiguration(nullptr);
-            m_log.info("installed empty 'default' AttributeConfiguration");
+            m_log.info("installed AttributeConfiguration '%s' from %s", keys.first.c_str(), path->c_str());
         }
     }
 }
diff --git a/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp b/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
index 8595671d..1b4b407c 100644
--- a/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
@@ -47,7 +47,7 @@ const char AbstractHTTPRemotingService::CA_FILE_PROP_NAME[] = "tlsCAFile";
 const char AbstractHTTPRemotingService::REVOCATION_CHECK_PROP_NAME[] = "revocationCheck";
 
 const char AbstractHTTPRemotingService::SECRET_SOURCE_TYPE_PROP_DEFAULT[] = FILE_SECRET_SOURCE;
-const char AbstractHTTPRemotingService::BASE_URL_PROP_DEFAULT[] = "http://localhost/idp/profile/sp";
+const char AbstractHTTPRemotingService::BASE_URL_PROP_DEFAULT[] = "http://localhost:8080/idp/profile/sp";
 const char AbstractHTTPRemotingService::AUTH_METHOD_PROP_DEFAULT[] = "none";
 const char AbstractHTTPRemotingService::AUTH_CACHING_COOKIE_PROP_DEFAULT[] = "__Host-JSESSIONID";
 unsigned int AbstractHTTPRemotingService::CONNECT_TIMEOUT_PROP_DEFAULT = 3;
diff --git a/tests/data/attribute/impl/attributes.ini b/tests/data/attribute/impl/attributes.ini
index 3e23f37b..d3e707b2 100644
--- a/tests/data/attribute/impl/attributes.ini
+++ b/tests/data/attribute/impl/attributes.ini
@@ -1,4 +1,4 @@
-[settings]
+[attribute-settings]
 scopeDelimiter = /
 exportDuplicateValues = false
 caseInsensitiveAttributes = foo bar
@@ -7,5 +7,5 @@ caseInsensitiveAttributes = foo bar
 # Set to URL to apply URL encoding on export
 encoding = URL
 
-[mappings]
+[attribute-mappings]
 foo = foo

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


More information about the commits mailing list