Ignore charset for /login attempts
bmcweb fails when attempting to login with a Content header of
application/json; charset=utf8. This is because of an exact string
compare. This commit changes the check to only check the begining of
the string, and adds some logging to make it more clear when we hit this
in the future.
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: I972a80c174a18295205340271b781c9d6693ee17
diff --git a/include/token_authorization_middleware.hpp b/include/token_authorization_middleware.hpp
index ee34d00..2ff3879 100644
--- a/include/token_authorization_middleware.hpp
+++ b/include/token_authorization_middleware.hpp
@@ -283,12 +283,13 @@
// within it are not destroyed before we can use them
nlohmann::json loginCredentials;
// Check if auth was provided by a payload
- if (contentType == "application/json")
+ if (boost::starts_with(contentType, "application/json"))
{
loginCredentials =
nlohmann::json::parse(req.body, nullptr, false);
if (loginCredentials.is_discarded())
{
+ BMCWEB_LOG_DEBUG << "Bad json in request";
res.result(boost::beast::http::status::bad_request);
res.end();
return;
@@ -424,6 +425,7 @@
}
else
{
+ BMCWEB_LOG_DEBUG << "Couldn't interpret password";
res.result(boost::beast::http::status::bad_request);
}
res.end();