[cpp-sp] branch main updated: Allow export of unmapped data into variables only.

Scott Cantor cantor.2 at osu.edu
Wed Apr 23 19:03:19 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=1caf4d02169249a7a4829b51af9431733f023496

The following commit(s) were added to refs/heads/main by this push:
     new 1caf4d02 Allow export of unmapped data into variables only.
1caf4d02 is described below

commit 1caf4d02169249a7a4829b51af9431733f023496
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Apr 23 15:03:15 2025 -0400

    Allow export of unmapped data into variables only.
---
 .../impl/DefaultAttributeConfiguration.cpp         | 26 ++++++++++++++--------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp b/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
index 0d4e5c2a..b484d5f9 100644
--- a/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
+++ b/shibsp/attribute/impl/DefaultAttributeConfiguration.cpp
@@ -236,14 +236,18 @@ void DefaultAttributeConfiguration::exportAttributes(SPRequest& request, const S
     if (m_exportDuplicates) {
         for (const auto& a : session.getAttributes()) {
 
+            const string* headerNameToUse = &(a.first);
             const auto& headerMapping = m_mappings.find(a.first);
             if (headerMapping == m_mappings.end()) {
-                // TODO: Check for use of headers, then log this...no mapping for attribute...
-                // If headers not used, we'd export it as is.
-                continue;
+                if (request.isUseHeaders()) {
+                    // No mapping, so cannot be supplied as a header.
+                    continue;
+                }
+            } else {
+                headerNameToUse = &(headerMapping->second);
             }
 
-            string header(request.getSecureHeader(headerMapping->second.c_str()));
+            string header(request.getSecureHeader(headerNameToUse->c_str()));
 
             DDF vals = a.second; // cheap copy drops const qualifier
             DDF v = vals.first();
@@ -270,7 +274,7 @@ void DefaultAttributeConfiguration::exportAttributes(SPRequest& request, const S
 
                 v = vals.next();
             }
-            request.setHeader(headerMapping->second.c_str(), header.c_str());
+            request.setHeader(headerNameToUse->c_str(), header.c_str());
         }
     }
     else {
@@ -278,16 +282,20 @@ void DefaultAttributeConfiguration::exportAttributes(SPRequest& request, const S
         map<string,set<string>> valueMap;
         for (const auto& a : session.getAttributes()) {
 
+            const string* headerNameToUse = &(a.first);
             const auto& headerMapping = m_mappings.find(a.first);
             if (headerMapping == m_mappings.end()) {
-                // TODO: Check for use of headers, then log this...no mapping for attribute...
-                // If headers not used, we'd export it as is.
-                continue;
+                if (request.isUseHeaders()) {
+                    // No mapping, so cannot be supplied as a header.
+                    continue;
+                }
+            } else {
+                headerNameToUse = &(headerMapping->second);
             }
 
             DDF vals = a.second; // cheap copy drops const qualifier
             DDF v = vals.first();
-            set<string>& targetSet = valueMap[headerMapping->first];
+            set<string>& targetSet = valueMap[*headerNameToUse];
             while (vals.isnull()) {
                 targetSet.insert(v.string());
                 v = vals.next();

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


More information about the commits mailing list