[cpp-sp] branch main updated: Rework additional logging calls.

Codeberg noreply at shibboleth.net
Fri Dec 5 21:26:06 UTC 2025


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/64db53d06f401aa3c81a2360faf94abc67a844c6

The following commit(s) were added to refs/heads/main by this push:
     new 64db53d0 Rework additional logging calls.
64db53d0 is described below

commit 64db53d06f401aa3c81a2360faf94abc67a844c6
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Dec 5 16:25:52 2025 -0500

    Rework additional logging calls.
---
 shibsp/AbstractSPRequest.cpp                    |  4 +--
 shibsp/Agent.cpp                                | 34 ++++++++++---------------
 shibsp/Agent.h                                  |  1 -
 shibsp/handler/impl/AttributeCheckerHandler.cpp |  2 +-
 shibsp/handler/impl/SecuredHandler.cpp          |  2 +-
 5 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/shibsp/AbstractSPRequest.cpp b/shibsp/AbstractSPRequest.cpp
index 533643d7..55b985aa 100644
--- a/shibsp/AbstractSPRequest.cpp
+++ b/shibsp/AbstractSPRequest.cpp
@@ -373,7 +373,7 @@ void AbstractSPRequest::limitRedirect(const char* url) const
             redirectLimit = REDIRECT_LIMIT_ALLOW;
         }
         else {
-            m_log.error("unrecognized redirectLimit setting (%s), falling back to 'exact' ", prop);
+            error("unrecognized redirectLimit setting (%s), falling back to 'exact' ", prop);
         }
         prop = getRequestSettings().first->getString("redirectAllow");
         if (prop) {
@@ -423,7 +423,7 @@ void AbstractSPRequest::limitRedirect(const char* url) const
             }
         }
 
-        m_log.warn("redirectLimit policy enforced, blocked redirect to (%s)", url);
+        warn("redirectLimit policy enforced, blocked redirect to (%s)", url);
         throw AgentException("Blocked unacceptable redirect location.");
     }
 }
diff --git a/shibsp/Agent.cpp b/shibsp/Agent.cpp
index 91711137..0ca0503f 100644
--- a/shibsp/Agent.cpp
+++ b/shibsp/Agent.cpp
@@ -67,7 +67,7 @@ Agent::~Agent()
 {
 }
 
-long Agent::handleError(Category& log, SPRequest& request, const Session* session, exception* ex, bool mayRedirect) const
+long Agent::handleError(SPRequest& request, const Session* session, exception* ex, bool mayRedirect) const
 {
     bool externalParameters = false;
     const char* redirectErrors = nullptr;
@@ -118,8 +118,6 @@ long Agent::handleError(Category& log, SPRequest& request, const Session* sessio
 
 pair<bool,long> Agent::doAuthentication(SPRequest& request, bool handler) const
 {
-    Category& log = Category::getInstance(SHIBSP_LOGCAT ".Agent");
-
     string targetURL = request.getRequestURL();
 
     try {
@@ -140,7 +138,7 @@ pair<bool,long> Agent::doAuthentication(SPRequest& request, bool handler) const
                 }
                 else {
                     AgentException ex("Access via unencrypted HTTP was blocked.");
-                    return make_pair(true, handleError(log, request, nullptr, &ex, false));
+                    return make_pair(true, handleError(request, nullptr, &ex, false));
                 }
             }
         }
@@ -186,7 +184,7 @@ pair<bool,long> Agent::doAuthentication(SPRequest& request, bool handler) const
             // Lock will release here.
         }
         catch (const exception& e) {
-            log.warn("error during session lookup: %s", e.what());
+            request.warn("error during session lookup: %s", e.what());
             // If it's not a retryable session failure, we throw to the outer handler for reporting.
             if (dynamic_cast<const SessionValidationException*>(&e) == nullptr) {
                 throw;
@@ -242,18 +240,16 @@ pair<bool,long> Agent::doAuthentication(SPRequest& request, bool handler) const
 
         // We're done.  Everything is okay.  Nothing to report.  Nothing to do..
         // Let the caller decide how to proceed.
-        log.debug("doAuthentication succeeded");
+        request.debug("doAuthentication succeeded");
         return make_pair(false,0L);
     }
     catch (exception& e) {
-        return make_pair(true, handleError(log, request, nullptr, &e));
+        return make_pair(true, handleError(request, nullptr, &e));
     }
 }
 
 pair<bool,long> Agent::doAuthorization(SPRequest& request) const
 {
-    Category& log = Category::getInstance(SHIBSP_LOGCAT ".Agent");
-
     unique_lock<Session> session;
     string targetURL = request.getRequestURL();
 
@@ -279,7 +275,7 @@ pair<bool,long> Agent::doAuthorization(SPRequest& request) const
                 session = request.getSession(false, false);  // ignore timeout and do not cache
             }
             catch (const exception& e) {
-                log.warn("unable to obtain session to pass to access control provider: %s", e.what());
+                request.warn("unable to obtain session to pass to access control provider: %s", e.what());
             }
 
 #ifdef HAVE_CXX14
@@ -287,15 +283,15 @@ pair<bool,long> Agent::doAuthorization(SPRequest& request) const
 #endif
             switch (settings.second->authorized(request, session.mutex())) {
                 case AccessControl::shib_acl_true:
-                    log.debug("access control provider granted access");
+                    request.debug("access control provider granted access");
                     return make_pair(true, request.returnOK());
 
                 case AccessControl::shib_acl_false:
                 {
-                    log.warn("access control provider denied access");
+                    request.warn("access control provider denied access");
                     AgentException ex("Access to resource denied.");
                     ex.setStatusCode(HTTPResponse::SHIBSP_HTTP_STATUS_FORBIDDEN);
-                    return make_pair(true, handleError(log, request, session.mutex(), &ex, false));
+                    return make_pair(true, handleError(request, session.mutex(), &ex, false));
                 }
 
                 default:
@@ -308,14 +304,12 @@ pair<bool,long> Agent::doAuthorization(SPRequest& request) const
         }
     }
     catch (exception& e) {
-        return make_pair(true, handleError(log, request, nullptr, &e));
+        return make_pair(true, handleError(request, nullptr, &e));
     }
 }
 
 pair<bool,long> Agent::doExport(SPRequest& request, bool requireSession) const
 {
-    Category& log = Category::getInstance(SHIBSP_LOGCAT ".Agent");
-
     unique_lock<Session> session;
     string targetURL = request.getRequestURL();
 
@@ -326,7 +320,7 @@ pair<bool,long> Agent::doExport(SPRequest& request, bool requireSession) const
             session = request.getSession(false, false);  // ignore timeout and do not cache
         }
         catch (const exception& e) {
-            log.warn("unable to obtain session to export to request: %s", e.what());
+            request.warn("unable to obtain session to export to request: %s", e.what());
         	// If we have to have a session, then this is a fatal error.
         	if (requireSession) {
         		throw;
@@ -361,14 +355,12 @@ pair<bool,long> Agent::doExport(SPRequest& request, bool requireSession) const
         return make_pair(false,0L);
     }
     catch (exception& e) {
-        return make_pair(true, handleError(log, request, session.mutex(), &e));
+        return make_pair(true, handleError(request, session.mutex(), &e));
     }
 }
 
 pair<bool,long> Agent::doHandler(SPRequest& request) const
 {
-    Category& log = Category::getInstance(SHIBSP_LOGCAT ".Agent");
-
     const char* targetURL = request.getRequestURL();
 
     try {
@@ -427,6 +419,6 @@ pair<bool,long> Agent::doHandler(SPRequest& request) const
         }
         catch (const exception&) {
         }
-        return make_pair(true, handleError(log, request, session.mutex(), &e));
+        return make_pair(true, handleError(request, session.mutex(), &e));
     }
 }
diff --git a/shibsp/Agent.h b/shibsp/Agent.h
index 576164ac..3f5a8a8f 100644
--- a/shibsp/Agent.h
+++ b/shibsp/Agent.h
@@ -183,7 +183,6 @@ namespace shibsp {
 
     private:
         long handleError(
-            Category& log,
             SPRequest& request,
             const Session* session=nullptr,
             std::exception* ex=nullptr,
diff --git a/shibsp/handler/impl/AttributeCheckerHandler.cpp b/shibsp/handler/impl/AttributeCheckerHandler.cpp
index 69b40d22..8aab8dfc 100644
--- a/shibsp/handler/impl/AttributeCheckerHandler.cpp
+++ b/shibsp/handler/impl/AttributeCheckerHandler.cpp
@@ -129,7 +129,7 @@ pair<bool,long> AttributeCheckerHandler::run(SPRequest& request, bool isHandler)
         }
     }
     catch (const exception& ex) {
-        request.warn(string("AttributeChecker caught exception accessing session immediately after creation: ") + ex.what());
+        request.warn("AttributeChecker caught exception accessing session immediately after creation: %s", ex.what());
     }
 
     bool checked = false;
diff --git a/shibsp/handler/impl/SecuredHandler.cpp b/shibsp/handler/impl/SecuredHandler.cpp
index d97d87b9..3c0512e8 100644
--- a/shibsp/handler/impl/SecuredHandler.cpp
+++ b/shibsp/handler/impl/SecuredHandler.cpp
@@ -70,7 +70,7 @@ pair<bool,long> SecuredHandler::run(SPRequest& request, bool isHandler) const
         };
 
         if (find_if(m_acl.begin(), m_acl.end(), contains) == m_acl.end()) {
-            request.log(Priority::SHIB_WARN, string("handler request blocked from invalid address (") + request.getRemoteAddr() + ')');
+            request.warn("handler request blocked from invalid address (%s)", request.getRemoteAddr().c_str());
             istringstream msg("Access Denied");
             return make_pair(true, request.sendResponse(msg, HTTPResponse::SHIBSP_HTTP_STATUS_FORBIDDEN));
         }

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


More information about the commits mailing list