[cpp-sp] branch main updated: Factor out more constants.
Codeberg
noreply at shibboleth.net
Fri Dec 19 00:54: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/606dcf1a61bc56dbc297dcae400aebef94c00ed4
The following commit(s) were added to refs/heads/main by this push:
new 606dcf1a Factor out more constants.
606dcf1a is described below
commit 606dcf1a61bc56dbc297dcae400aebef94c00ed4
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Dec 18 19:53:46 2025 -0500
Factor out more constants.
---
shibsp/AbstractSPRequest.cpp | 37 ++++++++++++++++++++++++-------------
shibsp/RequestMapper.h | 7 +++++++
shibsp/impl/XMLRequestMapper.cpp | 7 +++++++
3 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/shibsp/AbstractSPRequest.cpp b/shibsp/AbstractSPRequest.cpp
index 9e035bae..738cbef8 100644
--- a/shibsp/AbstractSPRequest.cpp
+++ b/shibsp/AbstractSPRequest.cpp
@@ -183,11 +183,13 @@ const std::map<std::string,std::string>& AbstractSPRequest::getCookies() const
const char* AbstractSPRequest::getHandlerURL(const char* resource) const
{
- if (!resource)
+ if (!resource) {
resource = getRequestURL();
+ }
- if (!m_handlerURL.empty() && resource && !strcmp(getRequestURL(), resource))
+ if (!m_handlerURL.empty() && resource && !strcmp(getRequestURL(), resource)) {
return m_handlerURL.c_str();
+ }
// Check for relative URL.
string stackresource;
@@ -206,8 +208,10 @@ const char* AbstractSPRequest::getHandlerURL(const char* resource) const
throw ConfigurationException("Target resource was not an absolute URL.");
}
- bool ssl_only = getRequestSettings().first->getBool("handlerSSL", true);
- const char* handler = getRequestSettings().first->getString("handlerURL", "/Shibboleth.sso");
+ bool ssl_only = getRequestSettings().first->getBool(
+ RequestMapper::HANDLER_SSL_PROP_NAME, RequestMapper::HANDLER_SSL_PROP_DEFAULT);
+ const char* handler = getRequestSettings().first->getString(
+ RequestMapper::HANDLER_URL_PROP_NAME, RequestMapper::HANDLER_URL_PROP_DEFAULT);
if (*handler != '/' && strncmp(handler,"http:",5) && strncmp(handler,"https:",6)) {
throw ConfigurationException(string("Invalid handlerURL property: ") + handler);
@@ -242,14 +246,17 @@ const char* AbstractSPRequest::getHandlerURL(const char* resource) const
const char* colon = strchr(prot, ':');
colon += 3;
const char* slash = strchr(colon, '/');
- if (!path)
+ if (!path) {
path = slash;
+ }
// Compute the actual protocol and store in member.
- if (ssl_only)
+ if (ssl_only) {
m_handlerURL.assign("https://");
- else
+ }
+ else {
m_handlerURL.assign(prot, colon-prot);
+ }
// create the "host" from either the colon/slash or from the target string
// If prot == handler then we're in either #1 or #2, else #3.
@@ -273,8 +280,9 @@ string AbstractSPRequest::getNotificationURL(bool front, unsigned int index) con
vector<string> locs;
split_to_container(locs, rawlocs);
- if (index >= locs.size())
+ if (index >= locs.size()) {
return string();
+ }
const char* resource = getRequestURL();
if (!resource || (strncasecmp(resource,"http://", 7) && strncasecmp(resource,"https://", 8))) {
@@ -315,8 +323,9 @@ string AbstractSPRequest::getNotificationURL(bool front, unsigned int index) con
const char* colon=strchr(prot,':');
colon += 3;
const char* slash=strchr(colon,'/');
- if (!path)
+ if (!path) {
path = slash;
+ }
// Compute the actual protocol and store.
string notifyURL(prot, colon-prot);
@@ -338,8 +347,9 @@ string AbstractSPRequest::getNotificationURL(bool front, unsigned int index) con
void AbstractSPRequest::limitRedirect(const char* url) const
{
- if (!url || *url == '/')
+ if (!url || *url == '/') {
return;
+ }
enum {
REDIRECT_LIMIT_NONE,
@@ -352,7 +362,8 @@ void AbstractSPRequest::limitRedirect(const char* url) const
// Derive the active rule.
vector<string> redirectAllow;
- const char* prop = getRequestSettings().first->getString("redirectLimit", "exact");
+ const char* prop = getRequestSettings().first->getString(
+ RequestMapper::REDIRECT_LIMIT_PROP_NAME, RequestMapper::REDIRECT_LIMIT_PROP_DEFAULT);
if (!strcmp(prop, "none")) {
redirectLimit = REDIRECT_LIMIT_NONE;
}
@@ -375,7 +386,7 @@ void AbstractSPRequest::limitRedirect(const char* url) const
else {
error("unrecognized redirectLimit setting (%s), falling back to 'exact' ", prop);
}
- prop = getRequestSettings().first->getString("redirectAllow");
+ prop = getRequestSettings().first->getString(RequestMapper::REDIRECT_ALLOW_PROP_NAME);
if (prop) {
split_to_container(redirectAllow, prop);
}
@@ -423,7 +434,7 @@ void AbstractSPRequest::limitRedirect(const char* url) const
}
}
- warn("redirectLimit policy enforced, blocked redirect to (%s)", url);
+ warn("%s policy enforced, blocked redirect to (%s)", RequestMapper::REDIRECT_LIMIT_PROP_NAME, url);
throw AgentException("Blocked unacceptable redirect location.");
}
}
diff --git a/shibsp/RequestMapper.h b/shibsp/RequestMapper.h
index d81b91dd..88095ea9 100644
--- a/shibsp/RequestMapper.h
+++ b/shibsp/RequestMapper.h
@@ -56,11 +56,15 @@ namespace shibsp {
static const char COOKIE_MAXAGE_PROP_NAME[];
static const char EXPIRE_REDIRECTS_PROP_NAME[];
static const char HANDLER_CONFIG_ID_PROP_NAME[];
+ static const char HANDLER_SSL_PROP_NAME[];
+ static const char HANDLER_URL_PROP_NAME[];
static const char HOME_URL_PROP_NAME[];
static const char LIFETIME_PROP_NAME[];
static const char PRESERVE_POST_DATA_PROP_NAME[];
static const char POST_LIMIT_PROP_NAME[];
+ static const char REDIRECT_ALLOW_PROP_NAME[];
static const char REDIRECT_ERRORS_PROP_NAME[];
+ static const char REDIRECT_LIMIT_PROP_NAME[];
static const char REDIRECT_TO_SSL_PROP_NAME[];
static const char REMOTE_USER_PROP_NAME[];
static const char REQUIRE_SESSION_PROP_NAME[];
@@ -76,10 +80,13 @@ namespace shibsp {
static const char ATTRIBUTE_VALUE_DELIMITER_PROP_DEFAULT[];
static bool CONSISTENT_ADDRESS_PROP_DEFAULT;
static bool EXPIRE_REDIRECTS_PROP_DEFAULT;
+ static bool HANDLER_SSL_PROP_DEFAULT;
+ static const char HANDLER_URL_PROP_DEFAULT[];
static const char HOME_URL_PROP_DEFAULT[];
static unsigned int LIFETIME_PROP_DEFAULT;
static bool PRESERVE_POST_DATA_PROP_DEFAULT;
static unsigned int POST_LIMIT_PROP_DEFAULT;
+ static const char REDIRECT_LIMIT_PROP_DEFAULT[];
static bool REQUIRE_SESSION_PROP_DEFAULT;
static unsigned int TIMEOUT_PROP_DEFAULT;
static bool USE_HEADERS_PROP_DEFAULT;
diff --git a/shibsp/impl/XMLRequestMapper.cpp b/shibsp/impl/XMLRequestMapper.cpp
index 05453ba6..d8022621 100644
--- a/shibsp/impl/XMLRequestMapper.cpp
+++ b/shibsp/impl/XMLRequestMapper.cpp
@@ -174,12 +174,16 @@ const char RequestMapper::AUTH_TYPE_PROP_NAME[] = "authType";
const char RequestMapper::CONSISTENT_ADDRESS_PROP_NAME[] = "consistentAddress";
const char RequestMapper::COOKIE_MAXAGE_PROP_NAME[] = "cookieMaxAge";
const char RequestMapper::HANDLER_CONFIG_ID_PROP_NAME[] = "handlerConfigId";
+const char RequestMapper::HANDLER_SSL_PROP_NAME[] = "handlerSSL";
+const char RequestMapper::HANDLER_URL_PROP_NAME[] = "handlerURL";
const char RequestMapper::HOME_URL_PROP_NAME[] = "homeURL";
const char RequestMapper::EXPIRE_REDIRECTS_PROP_NAME[] = "expireRedirects";
const char RequestMapper::LIFETIME_PROP_NAME[] = "lifetime";
const char RequestMapper::PRESERVE_POST_DATA_PROP_NAME[] = "preservePostData";
const char RequestMapper::POST_LIMIT_PROP_NAME[] = "postLimit";
+const char RequestMapper::REDIRECT_ALLOW_PROP_NAME[] = "redirectAllow";
const char RequestMapper::REDIRECT_ERRORS_PROP_NAME[] = "redirectErrors";
+const char RequestMapper::REDIRECT_LIMIT_PROP_NAME[] = "redirectLimit";
const char RequestMapper::REDIRECT_TO_SSL_PROP_NAME[] = "redirectToSSL";
const char RequestMapper::REMOTE_USER_PROP_NAME[] = "REMOTE_USER";
const char RequestMapper::REQUIRE_LOGOUT_WITH_PROP_NAME[] = "requireLogoutWith";
@@ -195,10 +199,13 @@ const char RequestMapper::APPLICATION_ID_PROP_DEFAULT[] = "default";
const char RequestMapper::ATTRIBUTE_VALUE_DELIMITER_PROP_DEFAULT[] = ";";
bool RequestMapper::CONSISTENT_ADDRESS_PROP_DEFAULT = true;
bool RequestMapper::EXPIRE_REDIRECTS_PROP_DEFAULT = true;
+bool RequestMapper::HANDLER_SSL_PROP_DEFAULT = true;
+const char RequestMapper::HANDLER_URL_PROP_DEFAULT[] = "/Shibboleth.sso";
const char RequestMapper::HOME_URL_PROP_DEFAULT[] = "/";
unsigned int RequestMapper::LIFETIME_PROP_DEFAULT = 3600 * 8;
bool RequestMapper::PRESERVE_POST_DATA_PROP_DEFAULT = false;
unsigned int RequestMapper::POST_LIMIT_PROP_DEFAULT = 1024 * 1024;
+const char RequestMapper::REDIRECT_LIMIT_PROP_DEFAULT[] = "exact";
bool RequestMapper::REQUIRE_SESSION_PROP_DEFAULT = false;
unsigned int RequestMapper::TIMEOUT_PROP_DEFAULT = 3600;
bool RequestMapper::USE_HEADERS_PROP_DEFAULT = false;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list