Fix the build without the mutual TLS auth support
The build with `-DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION=OFF` fails
with a message about unused parameters in `performTLSAuth` function.
This commit wraps the `performTLSAuth` call in an ifdef statement to
fix the build.
Change-Id: I08a6f8a8708fd14401894db6c058405154e92aa1
Signed-off-by: Alexander Filippov <a.filippov@yadro.com>
diff --git a/include/authorization.hpp b/include/authorization.hpp
index 524064e..24dbb7b 100644
--- a/include/authorization.hpp
+++ b/include/authorization.hpp
@@ -162,11 +162,11 @@
return session;
}
+#ifdef BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION
static const std::shared_ptr<persistent_data::UserSession>
performTLSAuth(const crow::Request& req, Response& res,
std::weak_ptr<persistent_data::UserSession> session)
{
-#ifdef BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION
if (auto sp = session.lock())
{
// set cookie only if this is req from the browser.
@@ -196,9 +196,9 @@
}
}
}
-#endif
return nullptr;
}
+#endif
// checks if request can be forwarded without authentication
static bool isOnWhitelist(const crow::Request& req)
@@ -234,8 +234,9 @@
return false;
}
-static void authenticate(crow::Request& req, Response& res,
- std::weak_ptr<persistent_data::UserSession> session)
+static void authenticate(
+ crow::Request& req, Response& res,
+ [[maybe_unused]] std::weak_ptr<persistent_data::UserSession> session)
{
if (isOnWhitelist(req))
{
@@ -245,10 +246,12 @@
const persistent_data::AuthConfigMethods& authMethodsConfig =
persistent_data::SessionStore::getInstance().getAuthMethodsConfig();
+#ifdef BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION
if (req.session == nullptr && authMethodsConfig.tls)
{
req.session = performTLSAuth(req, res, session);
}
+#endif
if (req.session == nullptr && authMethodsConfig.xtoken)
{
req.session = performXtokenAuth(req);