Redacted apiKey values
This commit is contained in:
@@ -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 += "}, ";
|
||||||
|
|||||||
Reference in New Issue
Block a user