[cpp-sp] branch main updated: Port over Time-based AccessControl plugin.

Scott Cantor cantor.2 at osu.edu
Thu Oct 23 16:06:32 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=f22aca1916add34e663ce4f430b4496943afe32e

The following commit(s) were added to refs/heads/main by this push:
     new f22aca19 Port over Time-based AccessControl plugin.
f22aca19 is described below

commit f22aca1916add34e663ce4f430b4496943afe32e
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Oct 23 12:06:28 2025 -0400

    Port over Time-based AccessControl plugin.
---
 shibsp/AccessControl.h                |  3 +++
 shibsp/Makefile.am                    |  1 +
 shibsp/impl/ChainingAccessControl.cpp |  2 ++
 shibsp/util/Misc.cpp                  |  8 ++++++--
 shibsp/util/Misc.h                    | 18 +++++++++++++++++-
 5 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/shibsp/AccessControl.h b/shibsp/AccessControl.h
index 6c2f758f..e5f675ed 100644
--- a/shibsp/AccessControl.h
+++ b/shibsp/AccessControl.h
@@ -74,6 +74,9 @@ namespace shibsp {
     /** AccessControl based on rudimentary XML syntax. */
     #define XML_ACCESS_CONTROL      "XML"
 
+    /** AccessControl with time-based rules. */
+    #define TIME_ACCESS_CONTROL      "Time"
+
     /** Reserved for Apache-style .htaccess support. */
     #define HT_ACCESS_CONTROL       "htaccess"
 };
diff --git a/shibsp/Makefile.am b/shibsp/Makefile.am
index f73243f8..ab79e9e6 100644
--- a/shibsp/Makefile.am
+++ b/shibsp/Makefile.am
@@ -115,6 +115,7 @@ libshibsp_la_SOURCES = \
 	impl/AgentConfig.cpp \
 	impl/DefaultAgent.cpp \
 	impl/ChainingAccessControl.cpp \
+	impl/TimeAccessControl.cpp \
 	impl/XMLAccessControl.cpp \
 	impl/XMLRequestMapper.cpp \
 	io/impl/CookieManager.cpp \
diff --git a/shibsp/impl/ChainingAccessControl.cpp b/shibsp/impl/ChainingAccessControl.cpp
index 15650177..a1919914 100644
--- a/shibsp/impl/ChainingAccessControl.cpp
+++ b/shibsp/impl/ChainingAccessControl.cpp
@@ -37,6 +37,7 @@ using namespace std;
 
 namespace shibsp {
     extern AccessControl* SHIBSP_DLLLOCAL XMLAccessControlFactory(ptree& pt, bool deprecationSupport);
+    extern AccessControl* SHIBSP_DLLLOCAL TimeAccessControlFactory(ptree& pt, bool deprecationSupport);
 }
 
 AccessControl::AccessControl()
@@ -90,6 +91,7 @@ void SHIBSP_API shibsp::registerAccessControls()
     AgentConfig& conf=AgentConfig::getConfig();
     conf.AccessControlManager.registerFactory(CHAINING_ACCESS_CONTROL, ChainingAccessControlFactory);
     conf.AccessControlManager.registerFactory(XML_ACCESS_CONTROL, XMLAccessControlFactory);
+    conf.AccessControlManager.registerFactory(TIME_ACCESS_CONTROL, TimeAccessControlFactory);
 }
 
 ChainingAccessControl::ChainingAccessControl(ptree& pt, bool deprecationSupport) : m_op(OP_AND)
diff --git a/shibsp/util/Misc.cpp b/shibsp/util/Misc.cpp
index fdd23614..2cebe3dc 100644
--- a/shibsp/util/Misc.cpp
+++ b/shibsp/util/Misc.cpp
@@ -68,6 +68,10 @@ time_t shibsp::parseISODuration(const string& s)
     static regexp::regex notime_parser("P([[:d:]]+Y)?([[:d:]]+M)?([[:d:]]+D)?");
     static regexp::regex full_parser("P([[:d:]]+Y)?([[:d:]]+M)?([[:d:]]+D)?T([[:d:]]+H)?([[:d:]]+M)?([[:d:]]+S|[[:d:]]+\\.[[:d:]]+S)?");
     
+    if (s.empty()) {
+        return -1;
+    }
+
     regexp::smatch match;
 
     try {
@@ -79,11 +83,11 @@ time_t shibsp::parseISODuration(const string& s)
         }
     }
     catch (const regexp::regex_error& e) {
-        return 0;
+        return -1;
     }
 
     if (match.empty()) {
-        return 0;
+        return -1;
     }
 
     vector<double> vec = {0,0,0,0,0,0}; // years, months, days, hours, minutes, seconds
diff --git a/shibsp/util/Misc.h b/shibsp/util/Misc.h
index f6942699..6cb27a93 100644
--- a/shibsp/util/Misc.h
+++ b/shibsp/util/Misc.h
@@ -85,9 +85,25 @@ namespace shibsp {
     };
 
     /**
-     * ISO format parsers.
+     * Parses an ISO Duration into number of seconds.
+     * 
+     * <p>This does estimated processing when units like month or year
+     * are used, but is exact otherwise.</p>
+     * 
+     * @param s input string
+     * 
+     * @return the approximate or exact count of seconds, or -1 on error
      */
     SHIBSP_API time_t parseISODuration(const std::string& s);
+
+    /**
+     * Parses an ISO date/time expression that ends in a 'Z', signifying UTC time,
+     * and returns the corresponding epoch in seconds.
+     * 
+     * @param s input string
+     * 
+     * @return the epoch, or -1 if the parser detected an anomaly
+     */
     SHIBSP_API time_t parseISODateTime(const std::string& s);
 
     struct FileSupport {

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


More information about the commits mailing list