[cpp-sp] branch main updated: Code in Hub logout initiator operation.

Codeberg noreply at shibboleth.net
Wed Apr 8 17:11:17 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/c21a88e33449a72317cd075da7b6be58c84d4e94

The following commit(s) were added to refs/heads/main by this push:
     new c21a88e3 Code in Hub logout initiator operation.
c21a88e3 is described below

commit c21a88e33449a72317cd075da7b6be58c84d4e94
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Wed Apr 8 13:10:42 2026 -0400

    Code in Hub logout initiator operation.
---
 shibsp/handler/LogoutHandler.h          |  8 +++---
 shibsp/handler/SecuredHandler.h         |  2 +-
 shibsp/handler/impl/LogoutHandler.cpp   |  2 +-
 shibsp/handler/impl/LogoutInitiator.cpp | 47 ++++++++++++++++++++++++++++++++-
 shibsp/handler/impl/SessionHandler.cpp  |  2 +-
 shibsp/handler/impl/StatusHandler.cpp   |  2 +-
 6 files changed, 55 insertions(+), 8 deletions(-)

diff --git a/shibsp/handler/LogoutHandler.h b/shibsp/handler/LogoutHandler.h
index a52e8ac8..77b9fffd 100644
--- a/shibsp/handler/LogoutHandler.h
+++ b/shibsp/handler/LogoutHandler.h
@@ -21,12 +21,14 @@
 #ifndef __shibsp_logout_h__
 #define __shibsp_logout_h__
 
-#include <shibsp/handler/Handler.h>
+#include <shibsp/handler/AbstractHandler.h>
 
 #include <map>
 #include <string>
 #include <vector>
 
+#include <boost/property_tree/ptree_fwd.hpp>
+
 namespace shibsp {
 
 #if defined (_MSC_VER)
@@ -38,7 +40,7 @@ namespace shibsp {
      * Base class for logout-related handlers, both when initiating from the
      * Agent or processing incoming requests or responses from other systems.
      */
-    class SHIBSP_API LogoutHandler : public virtual Handler
+    class SHIBSP_API LogoutHandler : public virtual AbstractHandler
     {
     public:
         virtual ~LogoutHandler();
@@ -60,7 +62,7 @@ namespace shibsp {
         std::pair<bool,long> run(SPRequest& request, bool isHandler=true) const;
 
     protected:
-        LogoutHandler();
+        LogoutHandler(const boost::property_tree::ptree& pt);
         
         /** Flag indicating whether the subclass is acting as a LogoutInitiator. */
         bool m_initiator;
diff --git a/shibsp/handler/SecuredHandler.h b/shibsp/handler/SecuredHandler.h
index 17a4c53a..567cbcee 100644
--- a/shibsp/handler/SecuredHandler.h
+++ b/shibsp/handler/SecuredHandler.h
@@ -36,7 +36,7 @@ namespace shibsp {
     /**
      * Pluggable runtime functionality that is protected by simple access control.
      */
-    class SHIBSP_API SecuredHandler : public AbstractHandler
+    class SHIBSP_API SecuredHandler : public virtual AbstractHandler
     {
     protected:
         /**
diff --git a/shibsp/handler/impl/LogoutHandler.cpp b/shibsp/handler/impl/LogoutHandler.cpp
index ead053d7..5b0bb6ca 100644
--- a/shibsp/handler/impl/LogoutHandler.cpp
+++ b/shibsp/handler/impl/LogoutHandler.cpp
@@ -31,7 +31,7 @@
 using namespace shibsp;
 using namespace std;
 
-LogoutHandler::LogoutHandler() : m_initiator(true)
+LogoutHandler::LogoutHandler(const boost::property_tree::ptree& pt) : AbstractHandler(pt), m_initiator(true)
 {
 }
 
diff --git a/shibsp/handler/impl/LogoutInitiator.cpp b/shibsp/handler/impl/LogoutInitiator.cpp
index 855c6c94..7202905f 100644
--- a/shibsp/handler/impl/LogoutInitiator.cpp
+++ b/shibsp/handler/impl/LogoutInitiator.cpp
@@ -19,9 +19,12 @@
  */
 
 #include "internal.h"
+#include "exceptions.h"
 #include "Agent.h"
 #include "SPRequest.h"
 #include "handler/LogoutInitiator.h"
+#include "remoting/ddf.h"
+#include "remoting/RemotingService.h"
 #include "session/SessionCache.h"
 
 #include <boost/property_tree/ptree.hpp>
@@ -37,7 +40,7 @@ namespace shibsp {
     }
 }
 
-LogoutInitiator::LogoutInitiator(const ptree& pt)
+LogoutInitiator::LogoutInitiator(const ptree& pt) : AbstractHandler(pt), LogoutHandler(pt)
 {
 }
 
@@ -53,6 +56,8 @@ pair<bool,long> LogoutInitiator::run(SPRequest& request, bool isHandler) const
         return ret;
     }
 
+    bool localOnly = getBool("localOnly", false);
+
     unique_lock<Session> session;
     try {
         session = request.getSession(false, true);  // don't cache it and ignore all checks
@@ -61,7 +66,17 @@ pair<bool,long> LogoutInitiator::run(SPRequest& request, bool isHandler) const
         request.error("error accessing current session: %s", ex.what());
     }
 
+    DDF opaqueData;
     if (session) {
+        if (!localOnly) {
+            // Before disposing of session, we need to copy out the opaque portion for the Hub.
+            opaqueData = session.mutex()->getOpaqueData().copy();
+            if (opaqueData.isnull()) {
+                request.info("session (%s) contains no Hub-supplied data, bypassing non-local logout",
+                    session.mutex()->getID());
+                localOnly = true;
+            }
+        }
         request.info("logging out session (%s)", session.mutex()->getID());
         session.unlock();
         request.getAgent().getSessionCache()->remove(request);
@@ -69,6 +84,36 @@ pair<bool,long> LogoutInitiator::run(SPRequest& request, bool isHandler) const
 
     // Determine return location.
     const char* dest = request.getParameter("return");
+
+    if (!localOnly) {
+        DDF input = request.getAgent().getRemotingService()->build("logout-initiator", request);
+        DDFJanitor inputJanitor(input);
+        input.addmember("session").structure().add(opaqueData);
+        if (dest) {
+            input.addmember("target").unsafe_string(dest);
+        }
+        
+        static set<string> emptyHeaderSet;
+        DDF wrapped = wrapRequest(request, emptyHeaderSet, false);
+        input.add(wrapped);
+
+        try {
+            DDF output = request.getAgent().getRemotingService()->send(input);
+            DDFJanitor outputJanitor(output);
+            return unwrapResponse(request, output);
+        }
+        catch (exception& ex) {
+            AgentException* agent_ex = dynamic_cast<AgentException*>(&ex);
+            const char* event = agent_ex ? agent_ex->getProperty(AgentException::EVENT_PROP_NAME) : nullptr;
+            if (!event && strcmp(event, "NoPotentialFlow")) {
+                if (agent_ex) {
+                    agent_ex->addProperty(AgentException::HANDLER_TYPE_PROP_NAME, LOGOUT_INITIATOR_HANDLER);
+                }
+                throw;
+            }
+        }
+    }
+
     if (!dest) {
         dest = request.getRequestSettings().first->getString(RequestMapper::LOGOUT_URL_PROP_NAME);
         if (!dest) {
diff --git a/shibsp/handler/impl/SessionHandler.cpp b/shibsp/handler/impl/SessionHandler.cpp
index df2ac57e..2d4c678d 100644
--- a/shibsp/handler/impl/SessionHandler.cpp
+++ b/shibsp/handler/impl/SessionHandler.cpp
@@ -70,7 +70,7 @@ namespace shibsp {
 
 };
 
-SessionHandler::SessionHandler(const ptree& pt) : SecuredHandler(pt), m_values(false)
+SessionHandler::SessionHandler(const ptree& pt) : AbstractHandler(pt), SecuredHandler(pt), m_values(false)
 {
     static const char CONTENT_TYPE_PROP_NAME[] = "contentType";
     static const char SHOW_ATTRIBUTE_VALUES_PROP_NAME[] = "showAttributeValues";
diff --git a/shibsp/handler/impl/StatusHandler.cpp b/shibsp/handler/impl/StatusHandler.cpp
index f3cd8ed2..a56e7c77 100644
--- a/shibsp/handler/impl/StatusHandler.cpp
+++ b/shibsp/handler/impl/StatusHandler.cpp
@@ -198,7 +198,7 @@ namespace shibsp {
     }
 };
 
-StatusHandler::StatusHandler(const ptree& pt) : SecuredHandler(pt)
+StatusHandler::StatusHandler(const ptree& pt) : AbstractHandler(pt), SecuredHandler(pt)
 {
 }
 

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


More information about the commits mailing list