[cpp-sp] branch main updated: Move agentID setting out of global section.

Scott Cantor cantor.2 at osu.edu
Mon Nov 3 21:02:49 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:
https://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=c9f4bd4015e070d63853b186ae8993328f0a41f7

The following commit(s) were added to refs/heads/main by this push:
     new c9f4bd40 Move agentID setting out of global section.
c9f4bd40 is described below

commit c9f4bd4015e070d63853b186ae8993328f0a41f7
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Nov 3 16:02:45 2025 -0500

    Move agentID setting out of global section.
---
 configs/agent.ini                                  | 14 ++++++--
 shibsp/Agent.h                                     | 10 ------
 shibsp/impl/AgentConfig.cpp                        |  1 +
 shibsp/impl/DefaultAgent.cpp                       | 13 +------
 shibsp/io/impl/CookieManager.cpp                   |  5 ++-
 .../remoting/impl/AbstractHTTPRemotingService.cpp  | 40 ++++++++++++----------
 shibsp/remoting/impl/AbstractHTTPRemotingService.h | 21 ++----------
 shibsp/remoting/impl/CurlHTTPRemotingService.cpp   |  4 +--
 shibsp/remoting/impl/WinHTTPRemotingService.cpp    |  4 +--
 tests/data/console-agent.ini                       |  1 -
 tests/data/remoting/impl/agent.ini                 |  2 +-
 tests/data/syslog-agent.ini                        |  1 -
 tests/session/impl/FilesystemSessionCacheTests.cpp |  4 +--
 tests/session/impl/MemorySessionCacheTests.cpp     |  4 +--
 14 files changed, 48 insertions(+), 76 deletions(-)

diff --git a/configs/agent.ini b/configs/agent.ini
index 05771eac..e9a2bf58 100644
--- a/configs/agent.ini
+++ b/configs/agent.ini
@@ -1,6 +1,3 @@
-[global]
-agentID = localhost
-
 [logging]
 defaultLevel = INFO
 
@@ -10,6 +7,7 @@ defaultLevel = INFO
 #Shibboleth.libcurl = DEBUG
 
 [remoting]
+agentID = localhost
 # For remote Hub, use https://, set authMethod to basic, and provide CA and secret
 baseURL = http://localhost:8080/idp/profile/sp/
 #authMethod = none
@@ -25,11 +23,21 @@ type = filesystem
 #fileCleanupTrackingFile = shibsp_cache_cleanup
 #fileCleanupInterval = 1800
 #fileTimeout = 28800
+
 # Defaults for memory buffering
 #cleanupInterval = 900
 #storageAccessInterval = 600
 #inprocTimeout = 900
 
+# Session cookie config
+#cookieName = __Host-shibsession
+#cookieSecure = true
+#cookieHttpOnly = true
+#cookiePath = /
+#cookieDomain =
+#cookieMaxAge = -1
+#cookieSameSite =
+
 [request-mapper]
 path = request-map.xml
 reloadChanges = true
diff --git a/shibsp/Agent.h b/shibsp/Agent.h
index 00d5f5d8..576164ac 100644
--- a/shibsp/Agent.h
+++ b/shibsp/Agent.h
@@ -66,16 +66,6 @@ namespace shibsp {
          */
         virtual void init()=0;
 
-        /**
-         * Gets the unique ID for this agent.
-         * 
-         * <p>Agent IDs are essentially provisoned by the operator of the corresponding "hub"
-         * supporting them.</p>
-         * 
-         * @return agent ID
-         */
-        virtual const char* getID() const=0;
-
         /**
          * Returns a SessionCache instance.
          * 
diff --git a/shibsp/impl/AgentConfig.cpp b/shibsp/impl/AgentConfig.cpp
index 127e6bb3..ff5a9649 100644
--- a/shibsp/impl/AgentConfig.cpp
+++ b/shibsp/impl/AgentConfig.cpp
@@ -273,6 +273,7 @@ bool AgentInternalConfig::_init(const char* inst_prefix, const char* config_file
         log.info("%s agent initialization complete", PACKAGE_STRING);
     }
     catch (const std::exception&) {
+        
         if (rethrow) {
             throw;
         }
diff --git a/shibsp/impl/DefaultAgent.cpp b/shibsp/impl/DefaultAgent.cpp
index eceda52e..53f7a52c 100644
--- a/shibsp/impl/DefaultAgent.cpp
+++ b/shibsp/impl/DefaultAgent.cpp
@@ -58,10 +58,6 @@ namespace {
 
         void init();
 
-        const char* getID() const {
-            return m_id.c_str();
-        }
-
         // Agent services.
 
         const RemotingService* getRemotingService(bool required = true) const {
@@ -113,7 +109,6 @@ namespace {
 
         ptree& m_pt;
         Category& m_log;
-        string m_id;
 
         // The order of these members actually matters. If we want to rely on auto-destruction, then
         // anything dependent on anything else has to come later in the object so it will pop first.
@@ -143,22 +138,16 @@ namespace shibsp {
 
 void DefaultAgent::init()
 {
-    static const char AGENT_ID_PROP_NAME[] = "agentID";
     static const char ALLOWED_SCHEMES_PROP_NAME[] = "allowedSchemes";
     static const char EXTRA_AUTH_TYPES_PROP_NAME[] = "extraAuthTypes";
 
     static const char AGENT_ID_PROP_DEFAULT[] = "localhost";
     static const char ALLOWED_SCHEMES_PROP_DEFAULT[] = "https http";
 
-        // First load "global" property tree as this PropertySet.
+    // First load "global" property tree as this PropertySet.
     const boost::optional<ptree&> global = m_pt.get_child_optional("global");
     if (global) {
         load(global.get());
-        m_id = getString(AGENT_ID_PROP_NAME, AGENT_ID_PROP_DEFAULT);
-    }
-
-    if (m_id.empty()) {
-        throw ConfigurationException(string("No ") + AGENT_ID_PROP_NAME + " property in [global] section of configuration.");
     }
 
     const char* prop = getString(ALLOWED_SCHEMES_PROP_NAME, ALLOWED_SCHEMES_PROP_DEFAULT);
diff --git a/shibsp/io/impl/CookieManager.cpp b/shibsp/io/impl/CookieManager.cpp
index 95d2aecb..23b9e923 100644
--- a/shibsp/io/impl/CookieManager.cpp
+++ b/shibsp/io/impl/CookieManager.cpp
@@ -125,11 +125,10 @@ string CookieManager::computeCookieName(const SPRequest& request) const
     string cookieName(request.getRequestSettings().first->getString(m_overrideProperty.c_str(), m_defaultName.c_str()));
 
     // This is just a hex-encode to avoid a dependency on a hashing API.
-    string encode(request.getAgent().getID());
-    encode += request.getRequestSettings().first->getString(
+    string decoration = request.getRequestSettings().first->getString(
         RequestMapper::APPLICATION_ID_PROP_NAME, RequestMapper::APPLICATION_ID_PROP_DEFAULT);
 
-    return cookieName + '_' + hex_encode(encode);
+    return cookieName + '_' + hex_encode(decoration);
 }
 
 void CookieManager::outputHeader(SPRequest& request, const char* value, int maxAge) const
diff --git a/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp b/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
index cbd74aae..e3ac29ac 100644
--- a/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
@@ -38,30 +38,34 @@ using namespace shibsp;
 using namespace boost::property_tree;
 using namespace std;
 
-const char AbstractHTTPRemotingService::SECRET_SOURCE_TYPE_PROP_NAME[] = "secretSourceType";
-const char AbstractHTTPRemotingService::BASE_URL_PROP_NAME[] = "baseURL";
-const char AbstractHTTPRemotingService::USER_AGENT_PROP_NAME[] = "userAgent";
-const char AbstractHTTPRemotingService::AUTH_METHOD_PROP_NAME[] = "authMethod";
-const char AbstractHTTPRemotingService::AUTH_CACHING_COOKIE_PROP_NAME[] = "authCachingCookie";
-const char AbstractHTTPRemotingService::CONNECT_TIMEOUT_PROP_NAME[] = "connectTimeout";
-const char AbstractHTTPRemotingService::TIMEOUT_PROP_NAME[] = "timeout";
-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: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;
-unsigned int AbstractHTTPRemotingService::TIMEOUT_PROP_DEFAULT = 10;
-const bool AbstractHTTPRemotingService::REVOCATION_CHECK_DEFAULT = false;
-
 AbstractHTTPRemotingService::AbstractHTTPRemotingService(ptree& pt)
     : AbstractRemotingService(pt), m_authMethod(agent_auth_none)
 {
     BoostPropertySet props;
     props.load(pt);
 
+    static const char AGENT_ID_PROP_NAME[] = "agentID";
+    static const char SECRET_SOURCE_TYPE_PROP_NAME[] = "secretSourceType";
+    static const char BASE_URL_PROP_NAME[] = "baseURL";
+    static const char USER_AGENT_PROP_NAME[] = "userAgent";
+    static const char AUTH_METHOD_PROP_NAME[] = "authMethod";
+    static const char AUTH_CACHING_COOKIE_PROP_NAME[] = "authCachingCookie";
+    static const char CONNECT_TIMEOUT_PROP_NAME[] = "connectTimeout";
+    static const char TIMEOUT_PROP_NAME[] = "timeout";
+    static const char CA_FILE_PROP_NAME[] = "tlsCAFile";
+    static const char REVOCATION_CHECK_PROP_NAME[] = "revocationCheck";
+
+    static const char AGENT_ID_PROP_DEFAULT[] = "localhost";
+    static const char SECRET_SOURCE_TYPE_PROP_DEFAULT[] = FILE_SECRET_SOURCE;
+    static const char BASE_URL_PROP_DEFAULT[] = "http://localhost:8080/idp/profile/sp/";
+    static const char AUTH_METHOD_PROP_DEFAULT[] = "none";
+    static const char AUTH_CACHING_COOKIE_PROP_DEFAULT[] = "__Host-JSESSIONID";
+    static unsigned int CONNECT_TIMEOUT_PROP_DEFAULT = 3;
+    static unsigned int TIMEOUT_PROP_DEFAULT = 10;
+    static const bool REVOCATION_CHECK_DEFAULT = false;
+
+
+    m_agentID = props.getString(AGENT_ID_PROP_NAME, AGENT_ID_PROP_DEFAULT);    
     m_userAgent = props.getString(USER_AGENT_PROP_NAME, "");
     m_baseURL = props.getString(BASE_URL_PROP_NAME, BASE_URL_PROP_DEFAULT);
     if (m_baseURL.back() != '/') {
diff --git a/shibsp/remoting/impl/AbstractHTTPRemotingService.h b/shibsp/remoting/impl/AbstractHTTPRemotingService.h
index a5017b26..abd822de 100644
--- a/shibsp/remoting/impl/AbstractHTTPRemotingService.h
+++ b/shibsp/remoting/impl/AbstractHTTPRemotingService.h
@@ -60,6 +60,7 @@ namespace shibsp {
             agent_auth_tls
         };
 
+        const char* getAgentID() const;
         const SecretSource* getSecretSource(bool required=true) const;
 
         /**
@@ -81,31 +82,13 @@ namespace shibsp {
         bool isRevocationCheck() const;
         const char* getCAFile() const;
 
-        // Property names and defaults.
-        static const char SECRET_SOURCE_TYPE_PROP_NAME[];
-        static const char BASE_URL_PROP_NAME[];
-        static const char USER_AGENT_PROP_NAME[];
-        static const char AUTH_METHOD_PROP_NAME[];
-        static const char AUTH_CACHING_COOKIE_PROP_NAME[];
-        static const char CONNECT_TIMEOUT_PROP_NAME[];
-        static const char TIMEOUT_PROP_NAME[];
-        static const char CA_FILE_PROP_NAME[];
-        static const char REVOCATION_CHECK_PROP_NAME[];
-
-        static const char SECRET_SOURCE_TYPE_PROP_DEFAULT[];
-        static const char BASE_URL_PROP_DEFAULT[];
-        static const char AUTH_METHOD_PROP_DEFAULT[];
-        static const char AUTH_CACHING_COOKIE_PROP_DEFAULT[];
-        static unsigned int CONNECT_TIMEOUT_PROP_DEFAULT;
-        static unsigned int TIMEOUT_PROP_DEFAULT;
-        static const bool REVOCATION_CHECK_DEFAULT;
-
     protected:
         AbstractHTTPRemotingService(boost::property_tree::ptree& pt);
 
     private:
         auth_t getAuthMethod(const char* method);
 
+        std::string m_agentID;
         std::unique_ptr<SecretSource> m_secretSource;
         std::string m_baseURL;
         std::string m_userAgent;
diff --git a/shibsp/remoting/impl/CurlHTTPRemotingService.cpp b/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
index 3f173d36..0e3144b3 100644
--- a/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
@@ -202,7 +202,7 @@ CurlHTTPRemotingService::CurlHTTPRemotingService(ptree& pt)
         setUserAgent(useragent.c_str());
     }
 
-    m_log.info("CurlHTTP RemotingService installed for agent (%s), baseURL (%s)", AgentConfig::getConfig().getAgent().getID(), getBaseURL());
+    m_log.info("CurlHTTP RemotingService installed for agent ID (%s), baseURL (%s)", getAgentID(), getBaseURL());
 
     m_traceFileBase = props.getString(TRACE_FILE_PROP_NAME, "");
     if (!m_traceFileBase.empty()) {
@@ -302,7 +302,7 @@ CURL* CurlHTTPRemotingService::checkout() const
     }
     SHIB_CURL_SET(CURLOPT_HTTPAUTH, flag);
     // Password will be acquired during call.
-    SHIB_CURL_SET(CURLOPT_USERNAME, AgentConfig::getConfig().getAgent().getID());
+    SHIB_CURL_SET(CURLOPT_USERNAME, getAgentID());
 
     attachCachedAuthentication(m_handle);
 
diff --git a/shibsp/remoting/impl/WinHTTPRemotingService.cpp b/shibsp/remoting/impl/WinHTTPRemotingService.cpp
index 5844aa27..147a51e8 100644
--- a/shibsp/remoting/impl/WinHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/WinHTTPRemotingService.cpp
@@ -241,7 +241,7 @@ WinHTTPRemotingService::WinHTTPRemotingService(ptree& pt)
 
     m_chunked = props.getBool(CHUNKED_PROP_NAME, defaultChunking);
     //m_ciphers = props.getString(CIPHER_LIST_PROP_NAME, "");
-    m_username = utf8ToUtf16(AgentConfig::getConfig().getAgent().getID());
+    m_username = utf8ToUtf16(getAgentID());
     switch (getAuthMethod()) {
         case agent_auth_basic:  m_authScheme = WINHTTP_AUTH_SCHEME_BASIC; break;
         case agent_auth_digest: m_authScheme = WINHTTP_AUTH_SCHEME_DIGEST; break;
@@ -327,7 +327,7 @@ WinHTTPRemotingService::WinHTTPRemotingService(ptree& pt)
         throw runtime_error("WinHHHTP failed to initialize: Could not connect");
     }
 
-    m_log.info("WinHTTP RemotingService installed for agent (%s), baseURL (%s)", AgentConfig::getConfig().getAgent().getID(), getBaseURL());
+    m_log.info("WinHTTP RemotingService installed for agent ID (%s), baseURL (%s)", getAgentID(), getBaseURL());
 }
 
 WinHTTPRemotingService::~WinHTTPRemotingService()
diff --git a/tests/data/console-agent.ini b/tests/data/console-agent.ini
index 49b04e17..6bcd5083 100644
--- a/tests/data/console-agent.ini
+++ b/tests/data/console-agent.ini
@@ -1,5 +1,4 @@
 [global]
-agentID = sp.example.org
 skipHandlers = true
 skipAttributes = true
 # Use "partial" for partial matching
diff --git a/tests/data/remoting/impl/agent.ini b/tests/data/remoting/impl/agent.ini
index b6384347..118d7458 100644
--- a/tests/data/remoting/impl/agent.ini
+++ b/tests/data/remoting/impl/agent.ini
@@ -1,9 +1,9 @@
 [global]
-agentID = sp.example.org
 skipHandlers = true
 skipAttributes = true
 
 [remoting]
+agentID = sp.example.org
 baseURL = https://localhost/idp/profile/sp
 authMethod = basic
 authCachingCookie = __Host-JSESSIONID
diff --git a/tests/data/syslog-agent.ini b/tests/data/syslog-agent.ini
index ac76202b..c9e78ee2 100644
--- a/tests/data/syslog-agent.ini
+++ b/tests/data/syslog-agent.ini
@@ -1,5 +1,4 @@
 [global]
-agentID = sp.example.org
 skipHandlers = true
 skipAttributes = true
 
diff --git a/tests/session/impl/FilesystemSessionCacheTests.cpp b/tests/session/impl/FilesystemSessionCacheTests.cpp
index c4bc56da..87e5f4e0 100644
--- a/tests/session/impl/FilesystemSessionCacheTests.cpp
+++ b/tests/session/impl/FilesystemSessionCacheTests.cpp
@@ -150,7 +150,7 @@ BOOST_FIXTURE_TEST_CASE(FilesystemSessionCache_tests, FilesystemFixture)
 
     BOOST_CHECK(obj["session"].isnull());
     BOOST_CHECK_EQUAL(key.c_str(), child.name());
-    string cookieName("__Host-shibsession_73702e6578616d706c652e6f7267637573746f6d");
+    string cookieName("__Host-shibsession_637573746f6d");
     string header(cookieName);
     header = header + '=' + key + ".1";
     header += "; Path=/; Secure=1; HttpOnly=1; SameSite=None";
@@ -211,7 +211,7 @@ BOOST_FIXTURE_TEST_CASE(FilesystemSessionCache_testUpdate, FilesystemFixture)
     BOOST_CHECK_EQUAL(key.c_str(), child.name());
 
     // Bind session to request with cookie.
-    string cookieName("__Host-shibsession_73702e6578616d706c652e6f7267637573746f6d");
+    string cookieName("__Host-shibsession_637573746f6d");
     string cookie(cookieName);
     cookie = cookie + '=' + key + ".1";
     request.m_requestHeaders["Cookie"] = cookie;
diff --git a/tests/session/impl/MemorySessionCacheTests.cpp b/tests/session/impl/MemorySessionCacheTests.cpp
index a538c2ac..4262a41d 100644
--- a/tests/session/impl/MemorySessionCacheTests.cpp
+++ b/tests/session/impl/MemorySessionCacheTests.cpp
@@ -90,7 +90,7 @@ BOOST_FIXTURE_TEST_CASE(MemorySessionCache_tests, MemoryFixture)
 
     BOOST_CHECK(obj["session"].isnull());
     BOOST_CHECK_EQUAL(key.c_str(), child.name());
-    string cookieName("__Host-shibsession_73702e6578616d706c652e6f7267637573746f6d");
+    string cookieName("__Host-shibsession_637573746f6d");
     string header(cookieName);
     header = header + '=' + key + ".1"; 
     header += "; Path=/; Secure=1; HttpOnly=1; SameSite=None";
@@ -151,7 +151,7 @@ BOOST_FIXTURE_TEST_CASE(MemorySessionCache_testUpdate, MemoryFixture)
     BOOST_CHECK_EQUAL(key.c_str(), child.name());
 
     // Bind session to request with cookie.
-    string cookieName("__Host-shibsession_73702e6578616d706c652e6f7267637573746f6d");
+    string cookieName("__Host-shibsession_637573746f6d");
     string cookie(cookieName);
     cookie = cookie + '=' + key + ".1";
     request.m_requestHeaders["Cookie"] = cookie;

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


More information about the commits mailing list