Redacted apiKey values

This commit is contained in:
emeric
2025-05-09 12:50:56 +02:00
parent 2069d0cb21
commit 7502bf6885
+13 -9
View File
@@ -87,27 +87,31 @@ namespace lms::api::subsonic
std::string parameterMapToDebugString(const Wt::Http::ParameterMap& parameterMap) std::string parameterMapToDebugString(const Wt::Http::ParameterMap& parameterMap)
{ {
auto censorValue = [](const std::string& type, const std::string& value) -> std::string { constexpr std::string_view redactedStr{ "*REDACTED*" };
if (type == "p" || type == "password") auto redactValueIfNeeded = [redactedStr](const std::string& type, const std::string& value) -> std::string_view {
return "*REDACTED*"; if (type == "p" || type == "password" || type == "apiKey")
return redactedStr;
return value; return value;
}; };
std::string res; std::string res;
for (const auto& params : parameterMap) for (const auto& [type, values] : parameterMap)
{ {
res += "{" + params.first + "="; res += "{" + type + "=";
if (params.second.size() == 1) if (values.size() == 1)
{ {
res += censorValue(params.first, params.second.front()); res += redactValueIfNeeded(type, values.front());
} }
else else
{ {
res += "{"; res += "{";
for (const std::string& param : params.second) for (const std::string& value : values)
res += censorValue(params.first, param) + ","; {
res += redactValueIfNeeded(type, value);
res += ',';
}
res += "}"; res += "}";
} }
res += "}, "; res += "}, ";