[cpp-sp] branch main updated: Initial CookieManager impl, removal of legacy code.
Scott Cantor
cantor.2 at osu.edu
Mon May 5 19:57:05 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:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=a2145f3d6dacdae47fa4585a1a15513b73bf06a2
The following commit(s) were added to refs/heads/main by this push:
new a2145f3d Initial CookieManager impl, removal of legacy code.
a2145f3d is described below
commit a2145f3d6dacdae47fa4585a1a15513b73bf06a2
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon May 5 15:57:00 2025 -0400
Initial CookieManager impl, removal of legacy code.
---
configs/shibboleth.ini | 3 +-
shibsp/AbstractSPRequest.cpp | 97 ++++++----------------
shibsp/AbstractSPRequest.h | 6 +-
shibsp/Agent.cpp | 7 --
shibsp/Agent.h | 10 +++
shibsp/Makefile.am | 2 +
shibsp/SPRequest.h | 18 ----
.../impl/DefaultAttributeConfiguration.cpp | 2 +-
shibsp/handler/AbstractHandler.h | 66 ---------------
shibsp/handler/impl/AbstractHandler.cpp | 5 +-
shibsp/handler/impl/StatusHandler.cpp | 4 +
shibsp/impl/DefaultAgent.cpp | 14 ++++
shibsp/io/HTTPRequest.h | 26 +-----
shibsp/io/HTTPResponse.h | 44 ----------
shibsp/io/impl/HTTPRequest.cpp | 44 ----------
shibsp/io/impl/HTTPResponse.cpp | 55 ------------
.../remoting/impl/AbstractHTTPRemotingService.cpp | 11 ---
shibsp/remoting/impl/AbstractHTTPRemotingService.h | 3 -
shibsp/remoting/impl/CurlHTTPRemotingService.cpp | 6 +-
tests/data/console-shibboleth.ini | 1 +
tests/data/fatal-exts-shibboleth.ini | 1 +
tests/data/impl/console-shibboleth.ini | 1 +
tests/data/nonfatal-exts-shibboleth.ini | 1 +
tests/data/platform/iis/console-shibboleth.ini | 1 +
tests/data/remoting/impl/shibboleth.ini | 2 +-
tests/data/syslog-shibboleth.ini | 1 +
.../util/reloadablefile/console-shibboleth.ini | 1 +
27 files changed, 73 insertions(+), 359 deletions(-)
diff --git a/configs/shibboleth.ini b/configs/shibboleth.ini
index bbca9770..63ca0238 100644
--- a/configs/shibboleth.ini
+++ b/configs/shibboleth.ini
@@ -1,5 +1,5 @@
[global]
-
+agentID = sp.example.org
[logging]
@@ -12,7 +12,6 @@
[remoting]
baseURL = https://localhost/idp/profile/sp/
-agentID = sp.example.org
authMethod = basic
authCachingCookie = __Host-JSESSIONID
tlsCAFile = trustfile.pem
diff --git a/shibsp/AbstractSPRequest.cpp b/shibsp/AbstractSPRequest.cpp
index f2340145..610de8ff 100644
--- a/shibsp/AbstractSPRequest.cpp
+++ b/shibsp/AbstractSPRequest.cpp
@@ -28,8 +28,9 @@
#include "util/CGIParser.h"
#include "util/Misc.h"
-#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/tokenizer.hpp>
#ifndef HAVE_STRCASECMP
# define strncasecmp _strnicmp
@@ -164,50 +165,30 @@ vector<const char*>::size_type AbstractSPRequest::getParameters(const char* name
return values.size();
}
-string AbstractSPRequest::getCookieName(const char* prefix, time_t* lifetime) const
-{
- if (lifetime) {
- *lifetime = getRequestSettings().first->getUnsignedInt("cookieLifetime", 0);
- }
-
- if (!prefix)
- prefix = "";
-
- const char* p = getRequestSettings().first->getString("cookieName");
- if (p) {
- return string(prefix) + p;
- }
-
- return string(prefix); // + getHash(); TODO: uniqueify the cookie name
-}
-
-pair<string,const char*> AbstractSPRequest::getCookieNameProps(const char* prefix, time_t* lifetime) const
+const std::map<std::string,std::string>& AbstractSPRequest::getCookies() const
{
- static const char* defProps="; path=/; HttpOnly";
- static const char* sslProps="; path=/; secure; HttpOnly";
-
- if (lifetime) {
- *lifetime = getRequestSettings().first->getUnsignedInt("cookieLifetime", 0);
- }
-
- if (!prefix)
- prefix = "";
-
- const char* cookieProps = getRequestSettings().first->getString("cookieProps");
- if (!cookieProps || !strcasecmp(cookieProps, "http")) {
- cookieProps = defProps;
- }
- else if (!strcasecmp(cookieProps, "https")) {
- cookieProps = sslProps;
- }
-
- const char* cookieName = getRequestSettings().first->getString("cookieName");
- if (cookieName) {
- return make_pair(string(prefix) + cookieName, cookieProps);
+ if (m_cookieMap.empty()) {
+ // Split cookie name/value pairs on semicolon using tokenizer for iteration.
+ string cookies = getHeader("Cookie");
+ if (!cookies.empty()) {
+ boost::tokenizer<boost::char_separator<char>> nvpairs(cookies, boost::char_separator<char>(";"));
+
+ // Holds each cookie name/value pair while splitting.
+ vector<string> nvpair;
+
+ for (const auto& cookie : nvpairs) {
+ // Split on '=' to separate name/value.
+ nvpair.clear();
+ boost::split(nvpair, cookie, boost::is_any_of("="));
+
+ if (nvpair.size() == 2) {
+ boost::trim(nvpair[0]);
+ m_cookieMap[nvpair[0]] = nvpair[1];
+ }
+ }
+ }
}
-
- // TODO: uniqueify the cookie name
- return make_pair(string(prefix) /* + getHash() */, cookieProps);
+ return m_cookieMap;
}
const char* AbstractSPRequest::getHandlerURL(const char* resource) const
@@ -467,36 +448,6 @@ void AbstractSPRequest::setAuthType(const char* authtype)
}
-const char* AbstractSPRequest::getCookie(const char* name) const
-{
- bool sameSiteFallback = getRequestSettings().first->getBool("sameSiteFallback", false);
- return HTTPRequest::getCookie(name, sameSiteFallback);
-}
-
-void AbstractSPRequest::setCookie(const char* name, const char* value, time_t expires, samesite_t sameSite)
-{
- bool sameSiteFallback = false;
- if (sameSite == SAMESITE_NONE) {
- sameSiteFallback = getRequestSettings().first->getBool("sameSiteFallback", false);
- }
-
- static const char* defProps="; path=/; HttpOnly";
- static const char* sslProps="; path=/; secure; HttpOnly";
-
- const char* cookieProps = getRequestSettings().first->getString("cookieProps", defProps);
- if (!strcmp(cookieProps, "https"))
- cookieProps = sslProps;
- else if (!strcmp(cookieProps, "http"))
- cookieProps = defProps;
-
- string decoratedValue(value ? value : "");
- if (!value) {
- decoratedValue += "; expires=Mon, 01 Jan 2001 00:00:00 GMT";
- }
- decoratedValue += cookieProps;
- HTTPResponse::setCookie(name, decoratedValue.c_str(), expires, sameSite, sameSiteFallback);
-}
-
void AbstractSPRequest::log(Priority::Value level, const std::string& msg) const
{
m_log.log(level, msg);
diff --git a/shibsp/AbstractSPRequest.h b/shibsp/AbstractSPRequest.h
index dd12adf2..52f38671 100644
--- a/shibsp/AbstractSPRequest.h
+++ b/shibsp/AbstractSPRequest.h
@@ -68,16 +68,13 @@ namespace shibsp {
std::string getRemoteAddr() const;
const char* getParameter(const char* name) const;
std::vector<const char*>::size_type getParameters(const char* name, std::vector<const char*>& values) const;
- std::string getCookieName(const char* prefix, time_t* lifetime) const;
- std::pair<std::string,const char*> getCookieNameProps(const char* prefix, time_t* lifetime) const;
+ const std::map<std::string,std::string>& getCookies() const;
const char* getHandlerURL(const char* resource=nullptr) const;
std::string getNotificationURL(bool front, unsigned int index) const;
void limitRedirect(const char* url) const;
std::string getSecureHeader(const char* name) const;
- const char* getCookie(const char* name) const;
void setAuthType(const char* authtype);
- void setCookie(const char* name, const char* value, time_t expires = 0, samesite_t sameSite = SAMESITE_ABSENT);
void log(Priority::Value level, const std::string& msg) const;
bool isPriorityEnabled(Priority::Value level) const;
@@ -101,6 +98,7 @@ namespace shibsp {
mutable std::string m_url;
mutable std::string m_handlerURL;
mutable std::unique_ptr<CGIParser> m_parser;
+ mutable std::map<std::string,std::string> m_cookieMap;
};
#if defined (_MSC_VER)
diff --git a/shibsp/Agent.cpp b/shibsp/Agent.cpp
index f7234e4e..54adddf0 100644
--- a/shibsp/Agent.cpp
+++ b/shibsp/Agent.cpp
@@ -367,13 +367,6 @@ pair<bool,long> Agent::doExport(SPRequest& request, bool requireSession) const
request.setHeader( "Shib-Session-Inactivity", boost::lexical_cast<string>(session->getLastAccess() + timeout).c_str());
}
- // Check for export of algorithmically-derived portion of cookie names.
- bool exportCookie = settings.first->getBool("exportCookie", false);
- if (exportCookie) {
- pair<string,const char*> cookieprops = request.getCookieNameProps(nullptr);
- request.setHeader("Shib-Cookie-Name", cookieprops.first.c_str());
- }
-
// Export the attributes.
request.getAgent().getAttributeConfiguration(
request.getRequestSettings().first->getString("attributeConfigID")
diff --git a/shibsp/Agent.h b/shibsp/Agent.h
index 6328f9ba..53e37d09 100644
--- a/shibsp/Agent.h
+++ b/shibsp/Agent.h
@@ -66,6 +66,16 @@ namespace shibsp {
*/
virtual void init()=0;
+ /**
+ * Gets the unique ID for this agent.
+ *
+ * <p>Agent IDs are essentially provisoned by the operator of the corresponding "hub"
+ * supporting them.</p>
+ *
+ * @return agent ID
+ */
+ virtual const char* getID() const=0;
+
/**
* Returns a SessionCache instance.
*
diff --git a/shibsp/Makefile.am b/shibsp/Makefile.am
index e9cb3969..4f8c1c1e 100644
--- a/shibsp/Makefile.am
+++ b/shibsp/Makefile.am
@@ -49,6 +49,7 @@ handinclude_HEADERS = \
handler/SecuredHandler.h
ioinclude_HEADERS = \
+ io/CookieManager.h \
io/GenericRequest.h \
io/GenericResponse.h \
io/HTTPRequest.h \
@@ -118,6 +119,7 @@ libshibsp_la_SOURCES = \
impl/ChainingAccessControl.cpp \
impl/XMLAccessControl.cpp \
impl/XMLRequestMapper.cpp \
+ io/impl/CookieManager.cpp \
io/impl/HTTPRequest.cpp \
io/impl/HTTPResponse.cpp \
logging/impl/AbstractLoggingService.cpp \
diff --git a/shibsp/SPRequest.h b/shibsp/SPRequest.h
index 781e5041..5182bae5 100644
--- a/shibsp/SPRequest.h
+++ b/shibsp/SPRequest.h
@@ -92,24 +92,6 @@ namespace shibsp {
*/
virtual Session* getSession(bool checkTimeout=true, bool ignoreAddress=false, bool cache=true)=0;
- /**
- * Returns the cookies name to use for this request.
- *
- * @param prefix a value to prepend to the base cookie name
- * @param lifetime if non-null, will be populated with a suggested lifetime for the cookie, or 0 if session-bound
- * @return the assigned cookie name to use
- */
- virtual std::string getCookieName(const char* prefix, time_t* lifetime=nullptr) const=0;
-
- /**
- * Returns the name and cookie properties to use for this request.
- *
- * @param prefix a value to prepend to the base cookie name
- * @param lifetime if non-null, will be populated with a suggested lifetime for the cookie, or 0 if session-bound
- * @return a pair containing the cookie name and the string to append to the cookie value
- */
- virtual std::pair<std::string,const char*> getCookieNameProps(const char* prefix, time_t* lifetime=nullptr) const=0;
-
/**
* Returns the effective base Handler URL for a resource,
* or the current request URL.
diff --git a/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp b/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
index b484d5f9..c879044f 100644
--- a/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
+++ b/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
@@ -95,7 +95,7 @@ DefaultAttributeConfiguration::DefaultAttributeConfiguration(const char* pathnam
: m_log(Category::getInstance(SHIBSP_LOGCAT ".AttributeConfiguration")), m_urlEncoding(false), m_exportDuplicates(true)
{
// Populate "built-in" mappings.
- for (const string& name : {"Shib-Application-ID", "Shib-Session-ID", "Shib-Session-Expires", "Shib-Session-Inactivity", "Shib-Cookie-Name", "REMOTE_USER"}) {
+ for (const string& name : {"Shib-Application-ID", "Shib-Session-ID", "Shib-Session-Expires", "Shib-Session-Inactivity", "REMOTE_USER"}) {
m_mappings[name] = name;
}
diff --git a/shibsp/handler/AbstractHandler.h b/shibsp/handler/AbstractHandler.h
index 5b473072..7c04ffa3 100644
--- a/shibsp/handler/AbstractHandler.h
+++ b/shibsp/handler/AbstractHandler.h
@@ -77,72 +77,6 @@ namespace shibsp {
*/
virtual std::pair<bool,long> unwrapResponse(SPRequest& request, DDF& wrappedResponse) const;
- /**
- * Prevents unused relay state from building up by cleaning old state from the client.
- *
- * <p>Handlers that generate relay state should call this method as a house cleaning
- * step.
- *
- * @param application the associated Application
- * @param request SP request
- */
- virtual void cleanRelayState(SPRequest& request) const;
-
- /**
- * Implements various mechanisms to preserve RelayState,
- * such as cookies or StorageService-backed keys.
- *
- * <p>If a supported mechanism can be identified, the input parameter will be
- * replaced with a suitable state key.
- *
- * @param response outgoing HTTP response
- * @param relayState RelayState token to supply with message
- */
- virtual void preserveRelayState(SPRequest& response, std::string& relayState) const;
-
- /**
- * Implements various mechanisms to recover RelayState,
- * such as cookies or StorageService-backed keys.
- *
- * <p>If a supported mechanism can be identified, the input parameter will be
- * replaced with the recovered state information.
- *
- * @param request SP request
- * @param relayState RelayState token supplied with message
- * @param clear true iff the token state should be cleared
- */
- virtual void recoverRelayState(SPRequest& request, std::string& relayState, bool clear=true) const;
-
- /**
- * Implements a mechanism to preserve form post data.
- *
- * @param request SP request
- * @param relayState relay state information attached to current sequence, if any
- */
- virtual void preservePostData(SPRequest& request, const char* relayState) const;
-
- /**
- * Implements storage service and cookie mechanism to recover PostData.
- *
- * <p>If a supported mechanism can be identified, the return value will be
- * the recovered state information.
- *
- * @param request incoming HTTP request
- * @param response outgoing HTTP response
- * @param relayState relay state information attached to current sequence, if any
- * @return recovered form post data associated with request as a DDF list of string members
- */
- virtual DDF recoverPostData(SPRequest& request, const char* relayState) const;
-
- /**
- * Post a redirect response with post data.
- *
- * @param response outgoing HTTP response
- * @param url action url for the form
- * @param postData list of parameters to load into the form, as DDF string members
- */
- virtual long sendPostResponse(HTTPResponse& response, const char* url, DDF& postData) const;
-
/**
* Bitmask of property sources to read from:
* (request query parameter, request mapper, fixed handler property).
diff --git a/shibsp/handler/impl/AbstractHandler.cpp b/shibsp/handler/impl/AbstractHandler.cpp
index 73822045..07843bea 100644
--- a/shibsp/handler/impl/AbstractHandler.cpp
+++ b/shibsp/handler/impl/AbstractHandler.cpp
@@ -188,7 +188,7 @@ pair<bool,long> AbstractHandler::unwrapResponse(SPRequest& request, DDF& wrapped
return make_pair(false, 0L);
}
-
+/*
void AbstractHandler::cleanRelayState(SPRequest& request) const
{
const char* mech = request.getRequestSettings().first->getString("relayState");
@@ -575,7 +575,6 @@ long AbstractHandler::sendPostResponse(HTTPResponse& httpResponse, const char* u
// TODO: this will require handling by the hub.
- /*
const PropertySet* props=application.getPropertySet("Sessions");
pair<bool,const char*> postTemplate = props ? props->getString("postTemplate") : pair<bool,const char*>(true,nullptr);
if (!postTemplate.first)
@@ -608,7 +607,6 @@ long AbstractHandler::sendPostResponse(HTTPResponse& httpResponse, const char* u
httpResponse.setResponseHeader("Pragma", "no-cache");
}
return httpResponse.sendResponse(str);
- */
return 0;
}
@@ -657,6 +655,7 @@ DDF AbstractHandler::getPostData(const SPRequest& request) const
}
return DDF();
}
+*/
bool AbstractHandler::getBool(
const char* name, const SPRequest& request, bool defaultValue, unsigned int type
diff --git a/shibsp/handler/impl/StatusHandler.cpp b/shibsp/handler/impl/StatusHandler.cpp
index 2300911a..a4283070 100644
--- a/shibsp/handler/impl/StatusHandler.cpp
+++ b/shibsp/handler/impl/StatusHandler.cpp
@@ -172,6 +172,9 @@ namespace {
string getHeader(const char* name) const {
return "";
}
+ const map<string,string>& getCookies() const {
+ return m_cookieMap;
+ }
private:
mutable unique_ptr<CGIParser> m_parser;
@@ -180,6 +183,7 @@ namespace {
const char* m_query;
int m_port;
string m_hostname,m_uri;
+ map<string,string> m_cookieMap;
};
};
diff --git a/shibsp/impl/DefaultAgent.cpp b/shibsp/impl/DefaultAgent.cpp
index cc5413f3..11601fb7 100644
--- a/shibsp/impl/DefaultAgent.cpp
+++ b/shibsp/impl/DefaultAgent.cpp
@@ -58,6 +58,12 @@ namespace {
void init();
+ static const char AGENT_ID_PROP_NAME[];
+
+ const char* getID() const {
+ return m_id.c_str();
+ }
+
// Agent services.
const RemotingService* getRemotingService(bool required = true) const {
@@ -109,6 +115,7 @@ namespace {
ptree& m_pt;
Category& m_log;
+ string m_id;
// The order of these members actually matters. If we want to rely on auto-destruction, then
// anything dependent on anything else has to come later in the object so it will pop first.
@@ -136,12 +143,19 @@ namespace shibsp {
}
};
+const char DefaultAgent::AGENT_ID_PROP_NAME[] = "agentID";
+
void DefaultAgent::init()
{
// First load "global" property tree as this PropertySet.
const boost::optional<ptree&> global = m_pt.get_child_optional("global");
if (global) {
load(global.get());
+ m_id = getString(AGENT_ID_PROP_NAME, "");
+ }
+
+ if (m_id.empty()) {
+ throw ConfigurationException(string("No ") + AGENT_ID_PROP_NAME + " property in [global] section of configuration.");
}
const char* prop = getString("allowedSchemes", "https http");
diff --git a/shibsp/io/HTTPRequest.h b/shibsp/io/HTTPRequest.h
index 9d74a159..3492a742 100644
--- a/shibsp/io/HTTPRequest.h
+++ b/shibsp/io/HTTPRequest.h
@@ -88,36 +88,12 @@ namespace shibsp {
*/
virtual std::string getHeader(const char* name) const=0;
- /**
- * Get a cookie value supplied by the client.
- *
- * @param name name of cookie
- * @return cookie value or nullptr
- */
- virtual const char* getCookie(const char* name) const;
-
- /**
- * Get a cookie value supplied by the client.
- *
- * The boolean flag enables the workaround for older clients with
- * broken SameSite support by looking for a second cookie with
- * a decorated name that would not carry the SameSite flag.
- *
- * @param name name of cookie
- * @param sameSiteFallback enables lookaside to fallback cookie name
- * @return cookie value or nullptr
- */
- virtual const char* getCookie(const char* name, bool sameSiteFallback) const;
-
/**
* Gets all the cookies supplied by the client.
*
* @return a map of cookie name/value pairs
*/
- virtual const std::map<std::string,std::string>& getCookies() const;
-
- private:
- mutable std::map<std::string,std::string> m_cookieMap;
+ virtual const std::map<std::string,std::string>& getCookies() const=0;
};
#if defined (_MSC_VER)
diff --git a/shibsp/io/HTTPResponse.h b/shibsp/io/HTTPResponse.h
index 0b7a6e52..e215f860 100644
--- a/shibsp/io/HTTPResponse.h
+++ b/shibsp/io/HTTPResponse.h
@@ -59,50 +59,6 @@ namespace shibsp {
*/
virtual void setResponseHeader(const char* name, const char* value, bool replace = false);
- /** Cookie SameSite values. */
- enum samesite_t {
- SAMESITE_ABSENT = 0,
- SAMESITE_NONE = 1,
- SAMESITE_LAX = 2,
- SAMESITE_STRICT = 3
- };
-
- /**
- * Sets or unsets a client cookie.
- *
- * <p>The boolean flag enables the workaround for older clients with
- * broken SameSite support by setting a second cookie with
- * a decorated name that would not carry the SameSite flag.</p>
- *
- * @param name cookie name
- * @param value value to set, or nullptr to clear
- * @param expires optional expiration time for the cookie, 0 means session
- * @param sameSiteValue the SameSite value to apply to the cookie
- * @param sameSiteFallback enables setting of a fallback cookie
- */
- virtual void setCookie(
- const char* name,
- const char* value,
- time_t expires,
- samesite_t sameSiteValue,
- bool sameSiteFallback);
-
- /**
- * Sets or unsets a client cookie.
- *
- * <p>Now defaults to calling the new version with a false flag.</p>
- *
- * @param name cookie name
- * @param value value to set, or nullptr to clear
- * @param expires optional expiration time for the cookie, 0 means session
- * @param sameSiteValue the SameSite value to apply to the cookie
- */
- virtual void setCookie(
- const char* name,
- const char* value,
- time_t expires = 0,
- samesite_t sameSiteValue = SAMESITE_ABSENT);
-
/**
* Redirect the client to the specified URL and complete the response.
*
diff --git a/shibsp/io/impl/HTTPRequest.cpp b/shibsp/io/impl/HTTPRequest.cpp
index c6ace2e2..2595a80d 100644
--- a/shibsp/io/impl/HTTPRequest.cpp
+++ b/shibsp/io/impl/HTTPRequest.cpp
@@ -81,47 +81,3 @@ bool HTTPRequest::isDefaultPort() const
else
return getPort() == 80;
}
-
-namespace {
- void handle_cookie_fn(map<string,string>& cookieMap, vector<string>& nvpair, const string& s) {
- nvpair.clear();
- split(nvpair, s, is_any_of("="));
- if (nvpair.size() == 2) {
- trim(nvpair[0]);
- if (ends_with(nvpair[0], "_fgwars")) {
- nvpair[0].erase(nvpair[0].end() - 7, nvpair[0].end());
- }
- cookieMap[nvpair[0]] = nvpair[1];
- }
- }
-}
-
-const map<string,string>& HTTPRequest::getCookies() const
-{
- if (m_cookieMap.empty()) {
- string cookies=getHeader("Cookie");
- vector<string> nvpair;
- tokenizer< char_separator<char> > nvpairs(cookies, char_separator<char>(";"));
- for_each(nvpairs.begin(), nvpairs.end(),
- boost::bind(handle_cookie_fn, boost::ref(m_cookieMap), boost::ref(nvpair), _1));
- }
- return m_cookieMap;
-}
-
-const char* HTTPRequest::getCookie(const char* name) const
-{
- return getCookie(name, false);
-}
-
-const char* HTTPRequest::getCookie(const char* name, bool) const
-{
- // The fallback support is implemented via the getCookies() load above
- // so we ignore it here.
-
- map<string,string>::const_iterator lookup = getCookies().find(name);
- if (lookup != m_cookieMap.end()) {
- return lookup->second.c_str();
- }
-
- return nullptr;
-}
diff --git a/shibsp/io/impl/HTTPResponse.cpp b/shibsp/io/impl/HTTPResponse.cpp
index 1ce5b5e2..bc6c3c39 100644
--- a/shibsp/io/impl/HTTPResponse.cpp
+++ b/shibsp/io/impl/HTTPResponse.cpp
@@ -81,61 +81,6 @@ void HTTPResponse::setContentType(const char* type)
setResponseHeader("Content-Type", type);
}
-void HTTPResponse::setCookie(const char* name, const char* value, time_t expires, samesite_t sameSiteValue)
-{
- setCookie(name, value, expires, sameSiteValue, false);
-}
-
-void HTTPResponse::setCookie(const char* name, const char* value, time_t expires, samesite_t sameSiteValue, bool sameSiteFallback)
-{
- string decoratedValue;
- if (!value) {
- decoratedValue += "; expires=Mon, 01 Jan 2001 00:00:00 GMT";
- }
- else {
- decoratedValue = value;
- if (expires > 0) {
- expires += time(nullptr);
-#ifndef HAVE_GMTIME_R
- struct tm* ptime = gmtime(&expires);
-#else
- struct tm res;
- struct tm* ptime = gmtime_r(&expires, &res);
-#endif
- char cookietimebuf[64];
- strftime(cookietimebuf, 64, "; expires=%a, %d %b %Y %H:%M:%S GMT", ptime);
- decoratedValue.append(cookietimebuf);
- }
- }
-
- if (sameSiteValue != SAMESITE_ABSENT) {
- // Add SameSite to the primary cookie and optionally set a fallback cookie without SameSite.
- switch (sameSiteValue) {
- case SAMESITE_NONE:
- if (sameSiteFallback) {
- string hackedName(name);
- setResponseHeader("Set-Cookie", hackedName.append("_fgwars=").append(decoratedValue).c_str());
- }
- decoratedValue.append("; SameSite=None");
- break;
- case SAMESITE_LAX:
- decoratedValue.append("; SameSite=Lax");
- break;
- case SAMESITE_STRICT:
- decoratedValue.append("; SameSite=Strict");
- break;
- default:
- throw invalid_argument("Invalid SameSite value supplied");
- }
- string header(name);
- setResponseHeader("Set-Cookie", header.append("=").append(decoratedValue).c_str());
- }
- else {
- string header(name);
- setResponseHeader("Set-Cookie", header.append("=").append(decoratedValue).c_str());
- }
-}
-
void HTTPResponse::setResponseHeader(const char* name, const char* value, bool)
{
if (name) {
diff --git a/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp b/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
index ee1ee77a..e97dd2ce 100644
--- a/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
@@ -39,7 +39,6 @@ using namespace std;
const char AbstractHTTPRemotingService::SECRET_SOURCE_TYPE_PROP_NAME[] = "secretSourceType";
const char AbstractHTTPRemotingService::BASE_URL_PROP_NAME[] = "baseURL";
const char AbstractHTTPRemotingService::USER_AGENT_PROP_NAME[] = "userAgent";
-const char AbstractHTTPRemotingService::AGENT_ID_PROP_NAME[] = "agentID";
const char AbstractHTTPRemotingService::AUTH_METHOD_PROP_NAME[] = "authMethod";
const char AbstractHTTPRemotingService::AUTH_CACHING_COOKIE_PROP_NAME[] = "authCachingCookie";
const char AbstractHTTPRemotingService::CONNECT_TIMEOUT_PROP_NAME[] = "connectTimeout";
@@ -60,11 +59,6 @@ AbstractHTTPRemotingService::AbstractHTTPRemotingService(ptree& pt)
BoostPropertySet props;
props.load(pt);
- m_agentID = props.getString(AGENT_ID_PROP_NAME, "");
- if (m_agentID.empty()) {
- throw ConfigurationException("Configuration is missing required agent ID.");
- }
-
m_secretSource.reset(AgentConfig::getConfig().SecretSourceManager.newPlugin(
props.getString(SECRET_SOURCE_TYPE_PROP_NAME, SECRET_SOURCE_TYPE_PROP_DEFAULT), pt, false)
);
@@ -144,11 +138,6 @@ const char* AbstractHTTPRemotingService::getBaseURL() const
return m_baseURL.c_str();
}
-const char* AbstractHTTPRemotingService::getAgentID() const
-{
- return m_agentID.c_str();
-}
-
const char* AbstractHTTPRemotingService::getUserAgent() const
{
return m_userAgent.c_str();
diff --git a/shibsp/remoting/impl/AbstractHTTPRemotingService.h b/shibsp/remoting/impl/AbstractHTTPRemotingService.h
index 56167626..01eb17fd 100644
--- a/shibsp/remoting/impl/AbstractHTTPRemotingService.h
+++ b/shibsp/remoting/impl/AbstractHTTPRemotingService.h
@@ -62,7 +62,6 @@ namespace shibsp {
const SecretSource* getSecretSource(bool required=true) const;
const char* getBaseURL() const;
- const char* getAgentID() const;
const char* getUserAgent() const;
void setUserAgent(const char* ua);
auth_t getAuthMethod() const;
@@ -75,7 +74,6 @@ namespace shibsp {
// Property names and defaults.
static const char SECRET_SOURCE_TYPE_PROP_NAME[];
static const char BASE_URL_PROP_NAME[];
- static const char AGENT_ID_PROP_NAME[];
static const char USER_AGENT_PROP_NAME[];
static const char AUTH_METHOD_PROP_NAME[];
static const char AUTH_CACHING_COOKIE_PROP_NAME[];
@@ -99,7 +97,6 @@ namespace shibsp {
std::unique_ptr<SecretSource> m_secretSource;
std::string m_baseURL;
- std::string m_agentID;
std::string m_userAgent;
std::string m_authCachingCookie;
mutable std::string m_authCachingValue;
diff --git a/shibsp/remoting/impl/CurlHTTPRemotingService.cpp b/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
index 02d1cecc..461beea3 100644
--- a/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
@@ -21,6 +21,8 @@
#include "internal.h"
#include "exceptions.h"
+#include "Agent.h"
+#include "AgentConfig.h"
#include "logging/Category.h"
#include "remoting/SecretSource.h"
#include "remoting/impl/AbstractHTTPRemotingService.h"
@@ -194,7 +196,7 @@ CurlHTTPRemotingService::CurlHTTPRemotingService(ptree& pt)
setUserAgent(useragent.c_str());
}
- m_log.info("CurlHTTP RemotingService installed for agent (%s), baseURL (%s)", getAgentID(), getBaseURL());
+ m_log.info("CurlHTTP RemotingService installed for agent (%s), baseURL (%s)", AgentConfig::getConfig().getAgent().getID(), getBaseURL());
}
CurlHTTPRemotingService::~CurlHTTPRemotingService()
@@ -278,7 +280,7 @@ CURL* CurlHTTPRemotingService::checkout() const
}
SHIB_CURL_SET(CURLOPT_HTTPAUTH, flag);
// Password will be acquired during call.
- SHIB_CURL_SET(CURLOPT_USERNAME, getAgentID());
+ SHIB_CURL_SET(CURLOPT_USERNAME, AgentConfig::getConfig().getAgent().getID());
attachCachedAuthentication(m_handle);
diff --git a/tests/data/console-shibboleth.ini b/tests/data/console-shibboleth.ini
index 6bcd5083..49b04e17 100644
--- a/tests/data/console-shibboleth.ini
+++ b/tests/data/console-shibboleth.ini
@@ -1,4 +1,5 @@
[global]
+agentID = sp.example.org
skipHandlers = true
skipAttributes = true
# Use "partial" for partial matching
diff --git a/tests/data/fatal-exts-shibboleth.ini b/tests/data/fatal-exts-shibboleth.ini
index 70a81156..db6e0de5 100644
--- a/tests/data/fatal-exts-shibboleth.ini
+++ b/tests/data/fatal-exts-shibboleth.ini
@@ -1,4 +1,5 @@
[global]
+agentID = sp.example.org
skipHandlers = true
skipAttributes = true
diff --git a/tests/data/impl/console-shibboleth.ini b/tests/data/impl/console-shibboleth.ini
index b841324a..ddf47a4a 100644
--- a/tests/data/impl/console-shibboleth.ini
+++ b/tests/data/impl/console-shibboleth.ini
@@ -1,4 +1,5 @@
[global]
+agentID = sp.example.org
skipHandlers = true
[logging]
diff --git a/tests/data/nonfatal-exts-shibboleth.ini b/tests/data/nonfatal-exts-shibboleth.ini
index e9ff5223..fd724735 100644
--- a/tests/data/nonfatal-exts-shibboleth.ini
+++ b/tests/data/nonfatal-exts-shibboleth.ini
@@ -1,4 +1,5 @@
[global]
+agentID = sp.example.org
skipHandlers = true
skipAttributes = true
diff --git a/tests/data/platform/iis/console-shibboleth.ini b/tests/data/platform/iis/console-shibboleth.ini
index bde240f9..493c1cd3 100644
--- a/tests/data/platform/iis/console-shibboleth.ini
+++ b/tests/data/platform/iis/console-shibboleth.ini
@@ -1,4 +1,5 @@
[global]
+agentID = sp.example.org
skipHandlers = true
skipAttributes = true
diff --git a/tests/data/remoting/impl/shibboleth.ini b/tests/data/remoting/impl/shibboleth.ini
index 8bd9c67c..b6384347 100644
--- a/tests/data/remoting/impl/shibboleth.ini
+++ b/tests/data/remoting/impl/shibboleth.ini
@@ -1,10 +1,10 @@
[global]
+agentID = sp.example.org
skipHandlers = true
skipAttributes = true
[remoting]
baseURL = https://localhost/idp/profile/sp
-agentID = sp.example.org
authMethod = basic
authCachingCookie = __Host-JSESSIONID
tlsCAFile = ./data/remoting/impl/trustfile.pem
diff --git a/tests/data/syslog-shibboleth.ini b/tests/data/syslog-shibboleth.ini
index c9e78ee2..ac76202b 100644
--- a/tests/data/syslog-shibboleth.ini
+++ b/tests/data/syslog-shibboleth.ini
@@ -1,4 +1,5 @@
[global]
+agentID = sp.example.org
skipHandlers = true
skipAttributes = true
diff --git a/tests/data/util/reloadablefile/console-shibboleth.ini b/tests/data/util/reloadablefile/console-shibboleth.ini
index 04d127d3..0d35377a 100644
--- a/tests/data/util/reloadablefile/console-shibboleth.ini
+++ b/tests/data/util/reloadablefile/console-shibboleth.ini
@@ -1,4 +1,5 @@
[global]
+agentID = sp.example.org
skipHandlers = true
skipAttributes = true
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list