From 73c1b8cdebaa5ec61861e02f706a668f64a96c5c Mon Sep 17 00:00:00 2001 From: Elvin Sindrilaru Date: Tue, 7 Dec 2021 12:51:07 +0100 Subject: [PATCH] [XrdSciTokens] Avoid double slashes in the final path rule that can result from concatenating the base path with a path from a name_mapfile rule. Exmaple: /etc/xrootd/scitokens.cfg ------------------------- ... base_path=/ name_mapfile=/etc/xrootd/mapfile.json ... /etc/xrootd/mapfile.json ------------------------- [{"sub": "abbaabba", "path":/some/path", "response": "someuser"}] The resulting rule against which the maching will be attempeted will use the path "//some/path" which will will never match a legitimate path. --- src/XrdSciTokens/XrdSciTokensAccess.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/XrdSciTokens/XrdSciTokensAccess.cc b/src/XrdSciTokens/XrdSciTokensAccess.cc index 139108b2de4..29dcfacfb7b 100644 --- a/src/XrdSciTokens/XrdSciTokensAccess.cc +++ b/src/XrdSciTokens/XrdSciTokensAccess.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include "INIReader.h" #include "picojson.h" @@ -647,6 +648,8 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper for (auto path : config.m_base_paths) { auto path_rule = rule; path_rule.m_path_prefix = path + rule.m_path_prefix; + path_rule.m_path_prefix = std::regex_replace(path_rule.m_path_prefix, + std::regex("//"), "/"); map_rules.emplace_back(path_rule); } }