[cpp-sp] branch main updated: Log validation errors from token-consumer operation.

Codeberg noreply at shibboleth.net
Tue Feb 10 19:17:46 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/c71136503a5b059f01b085f10cf0ac353178658f

The following commit(s) were added to refs/heads/main by this push:
     new c7113650 Log validation errors from token-consumer operation.
c7113650 is described below

commit c71136503a5b059f01b085f10cf0ac353178658f
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Feb 10 13:41:50 2026 -0500

    Log validation errors from token-consumer operation.
---
 shibsp/AbstractSPRequest.cpp          |  4 +++-
 shibsp/handler/impl/TokenConsumer.cpp | 27 ++++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/shibsp/AbstractSPRequest.cpp b/shibsp/AbstractSPRequest.cpp
index 704befd9..34cf6c29 100644
--- a/shibsp/AbstractSPRequest.cpp
+++ b/shibsp/AbstractSPRequest.cpp
@@ -473,7 +473,9 @@ void AbstractSPRequest::log(Priority::Value level, const exception& e) const
         msg << e.what() << " [";
 
         // Dump properties and status code.
-        msg << "status=" << rich_ex->getStatusCode();
+        if (rich_ex->getStatusCode() != 0) {
+            msg << "status=" << rich_ex->getStatusCode();
+        }
 
         for (const auto& prop : rich_ex->getProperties()) {
             msg << ", " << prop.first << '=' << prop.second;
diff --git a/shibsp/handler/impl/TokenConsumer.cpp b/shibsp/handler/impl/TokenConsumer.cpp
index 27da2f3b..50d2cf06 100644
--- a/shibsp/handler/impl/TokenConsumer.cpp
+++ b/shibsp/handler/impl/TokenConsumer.cpp
@@ -106,9 +106,34 @@ pair<bool,long> TokenConsumer::run(SPRequest& request, bool isHandler) const
         DDF wrapped = wrapRequest(request, m_remotedHeaders);
         input.add(wrapped);
 
-        DDF output = request.getAgent().getRemotingService()->send(input);
+        // Second parameter is false so we can capture any validation errors on
+        // an unsuccessful event result.
+        DDF output = request.getAgent().getRemotingService()->send(input, false);
         DDFJanitor outputJanitor(output);
 
+        // Check event coming back since we bypassed doing this automatically.
+        const char* event = output.getmember("event").string();
+        if (event && strcmp(event, "success")) {
+            DDF validation_errors = output.getmember("validation_errors");
+            if (validation_errors.islist()) {
+                DDF msg = validation_errors.first();
+                while (msg.isstring()) {
+                    if (msg.string()) {
+                        request.warn("token validation error: %s", msg.string());
+                    }
+                    msg = validation_errors.next();
+                }
+            }
+            OperationException ex(string("Remote operation (token-consumer) failed with event: ") + event);
+            ex.addProperty(AgentException::EVENT_PROP_NAME, event);
+            ex.addProperty("operation", input.name());
+            const char* target = output.getmember("target").string();
+            if (target) {
+                ex.addProperty(AgentException::TARGET_PROP_NAME, target);
+            }
+            throw ex;
+        }
+
         const char* s = output.getmember("http.redirect").string();
         if (s) {
             target = s;

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


More information about the commits mailing list