[cpp-sp] branch main updated: Extend exception properties and logging.

Codeberg noreply at shibboleth.net
Wed Feb 11 14:53:55 UTC 2026


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

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

View the commit online:
https://codeberg.org/Shibboleth/cpp-sp/commit/15ba55333aa1ca426b157ab298b77e1b51f995fa

The following commit(s) were added to refs/heads/main by this push:
     new 15ba5533 Extend exception properties and logging.
15ba5533 is described below

commit 15ba55333aa1ca426b157ab298b77e1b51f995fa
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Feb 11 09:53:42 2026 -0500

    Extend exception properties and logging.
---
 shibsp/Agent.cpp      | 25 ++++++++++++-------------
 shibsp/exceptions.cpp | 12 +++++++++++-
 shibsp/exceptions.h   |  6 ++++++
 3 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/shibsp/Agent.cpp b/shibsp/Agent.cpp
index 7029992c..8b86f68d 100644
--- a/shibsp/Agent.cpp
+++ b/shibsp/Agent.cpp
@@ -78,30 +78,28 @@ long Agent::handleError(SPRequest& request, const Session* session, exception* e
         if (!richEx->getProperty("target")) {
             richEx->addProperty("target", request.getRequestURL());
         }
+        if (session) {
+            richEx->addProperty("session", session->getID());
+        }
+        if (request.getRequestID()) {
+            richEx->addProperty("txid", request.getRequestID());
+        }
         richEx->log(request);
     }
     else if (ex) {
         request.error(ex->what());
     }
 
-    // Now look for settings in the request map.
-    try {
-        RequestMapper::Settings settings = request.getRequestSettings();
-        // Not using this yet, probably TBD.
-        externalParameters = settings.first->getBool("externalParameters", false);
-        if (mayRedirect)
-            redirectErrors = settings.first->getString(RequestMapper::REDIRECT_ERRORS_PROP_NAME);
-    }
-    catch (const exception& nested) {
-        request.error(nested.what());
+    // Check for redirection on errors.
+
+    if (mayRedirect) {
+        redirectErrors = request.getRequestSettings().first->getString(RequestMapper::REDIRECT_ERRORS_PROP_NAME);
     }
 
-    // Check for redirection on errors.
     if (mayRedirect && redirectErrors) {
         string loc(redirectErrors);
         request.absolutize(loc);
         if (richEx) {
-            // TODO: alter how this works or what's included.
             loc = loc + '?' + richEx->toQueryString();
         }
         return request.sendRedirect(loc.c_str());
@@ -113,7 +111,8 @@ long Agent::handleError(SPRequest& request, const Session* session, exception* e
     // so Apache can surface them using its error redirection feature.
 
     istringstream msg("Internal Server Error. Please contact the site administrator.");
-    return request.sendResponse(msg, richEx ? richEx->getStatusCode() : HTTPResponse::SHIBSP_HTTP_STATUS_ERROR);
+    return request.sendResponse(msg, (richEx && richEx->getStatusCode() != 0) ? richEx->getStatusCode() :
+        HTTPResponse::SHIBSP_HTTP_STATUS_ERROR);
 }
 
 pair<bool,long> Agent::doAuthentication(SPRequest& request, bool handler) const
diff --git a/shibsp/exceptions.cpp b/shibsp/exceptions.cpp
index e7395b5b..bcde4083 100644
--- a/shibsp/exceptions.cpp
+++ b/shibsp/exceptions.cpp
@@ -27,6 +27,7 @@
 #include "util/URLEncoder.h"
 
 #include <sstream>
+#include <boost/lexical_cast.hpp>
 
 using namespace shibsp;
 using namespace std;
@@ -92,10 +93,19 @@ void AgentException::addProperty(const char* name, const char* value)
 string AgentException::toQueryString() const
 {
     string q;
+
+    if (m_status != 0) {
+        if (!q.empty()) {
+            q += '&';
+        }
+        q += boost::lexical_cast<string>(m_status);
+    }
+
     const URLEncoder& enc = AgentConfig::getConfig().getURLEncoder();
     for (const auto& p : m_props) {
-        if (!q.empty())
+        if (!q.empty()) {
             q += '&';
+        }
         q = q + p.first + '=' + enc.encode(p.second.c_str());
     }
     return q;
diff --git a/shibsp/exceptions.h b/shibsp/exceptions.h
index c820c848..a5eaa679 100644
--- a/shibsp/exceptions.h
+++ b/shibsp/exceptions.h
@@ -114,6 +114,9 @@ namespace shibsp {
         /**
          * Attach a set of named properties to the exception.
          * 
+         * <p>Property data MAY be passed along to error handling resources and/or be
+         * visible in the client, so sensitive data should not be included.</p>
+         * 
          * @param params properties to attach
          */
         void addProperties(const std::unordered_map<std::string,std::string>& props);
@@ -121,6 +124,9 @@ namespace shibsp {
         /**
          * Attach a single named property.
          * 
+         * <p>Property data MAY be passed along to error handling resources and/or be
+         * visible in the client, so sensitive data should not be included.</p>
+         * 
          * @param name  the property name
          * @param value the property value
          */

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


More information about the commits mailing list