summaryrefslogtreecommitdiff
path: root/redfish-core/lib/account_service.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'redfish-core/lib/account_service.hpp')
-rw-r--r--redfish-core/lib/account_service.hpp102
1 files changed, 55 insertions, 47 deletions
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index aab116e6b1..972512b145 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -829,56 +829,62 @@ inline void
if (auth.basicAuth)
{
-#ifndef BMCWEB_ENABLE_BASIC_AUTHENTICATION
- messages::actionNotSupported(
- asyncResp->res,
- "Setting BasicAuth when basic-auth feature is disabled");
- return;
-#endif
+ if constexpr (!BMCWEB_BASIC_AUTH)
+ {
+ messages::actionNotSupported(
+ asyncResp->res,
+ "Setting BasicAuth when basic-auth feature is disabled");
+ return;
+ }
+
authMethodsConfig.basic = *auth.basicAuth;
}
if (auth.cookie)
{
-#ifndef BMCWEB_ENABLE_COOKIE_AUTHENTICATION
- messages::actionNotSupported(
- asyncResp->res,
- "Setting Cookie when cookie-auth feature is disabled");
- return;
-#endif
+ if constexpr (!BMCWEB_COOKIE_AUTH)
+ {
+ messages::actionNotSupported(
+ asyncResp->res,
+ "Setting Cookie when cookie-auth feature is disabled");
+ return;
+ }
authMethodsConfig.cookie = *auth.cookie;
}
if (auth.sessionToken)
{
-#ifndef BMCWEB_ENABLE_SESSION_AUTHENTICATION
- messages::actionNotSupported(
- asyncResp->res,
- "Setting SessionToken when session-auth feature is disabled");
- return;
-#endif
+ if constexpr (!BMCWEB_SESSION_AUTH)
+ {
+ messages::actionNotSupported(
+ asyncResp->res,
+ "Setting SessionToken when session-auth feature is disabled");
+ return;
+ }
authMethodsConfig.sessionToken = *auth.sessionToken;
}
if (auth.xToken)
{
-#ifndef BMCWEB_ENABLE_XTOKEN_AUTHENTICATION
- messages::actionNotSupported(
- asyncResp->res,
- "Setting XToken when xtoken-auth feature is disabled");
- return;
-#endif
+ if constexpr (!BMCWEB_XTOKEN_AUTH)
+ {
+ messages::actionNotSupported(
+ asyncResp->res,
+ "Setting XToken when xtoken-auth feature is disabled");
+ return;
+ }
authMethodsConfig.xtoken = *auth.xToken;
}
if (auth.tls)
{
-#ifndef BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION
- messages::actionNotSupported(
- asyncResp->res,
- "Setting TLS when mutual-tls-auth feature is disabled");
- return;
-#endif
+ if constexpr (!BMCWEB_MUTUAL_TLS_AUTH)
+ {
+ messages::actionNotSupported(
+ asyncResp->res,
+ "Setting TLS when mutual-tls-auth feature is disabled");
+ return;
+ }
authMethodsConfig.tls = *auth.tls;
}
@@ -1705,11 +1711,13 @@ inline void
boost::beast::http::field::link,
"</redfish/v1/JsonSchemas/ManagerAccount/ManagerAccount.json>; rel=describedby");
-#ifdef BMCWEB_INSECURE_DISABLE_AUTHENTICATION
- // If authentication is disabled, there are no user accounts
- messages::resourceNotFound(asyncResp->res, "ManagerAccount", accountName);
- return;
-#endif // BMCWEB_INSECURE_DISABLE_AUTHENTICATION
+ if constexpr (BMCWEB_INSECURE_DISABLE_AUTH)
+ {
+ // If authentication is disabled, there are no user accounts
+ messages::resourceNotFound(asyncResp->res, "ManagerAccount",
+ accountName);
+ return;
+ }
if (req.session == nullptr)
{
@@ -1882,12 +1890,12 @@ inline void
return;
}
-#ifdef BMCWEB_INSECURE_DISABLE_AUTHENTICATION
- // If authentication is disabled, there are no user accounts
- messages::resourceNotFound(asyncResp->res, "ManagerAccount", username);
- return;
-
-#endif // BMCWEB_INSECURE_DISABLE_AUTHENTICATION
+ if constexpr (BMCWEB_INSECURE_DISABLE_AUTH)
+ {
+ // If authentication is disabled, there are no user accounts
+ messages::resourceNotFound(asyncResp->res, "ManagerAccount", username);
+ return;
+ }
sdbusplus::message::object_path tempObjPath(rootUserDbusPath);
tempObjPath /= username;
const std::string userPath(tempObjPath);
@@ -1916,12 +1924,12 @@ inline void
{
return;
}
-#ifdef BMCWEB_INSECURE_DISABLE_AUTHENTICATION
- // If authentication is disabled, there are no user accounts
- messages::resourceNotFound(asyncResp->res, "ManagerAccount", username);
- return;
-
-#endif // BMCWEB_INSECURE_DISABLE_AUTHENTICATION
+ if constexpr (BMCWEB_INSECURE_DISABLE_AUTH)
+ {
+ // If authentication is disabled, there are no user accounts
+ messages::resourceNotFound(asyncResp->res, "ManagerAccount", username);
+ return;
+ }
std::optional<std::string> newUserName;
std::optional<std::string> password;
std::optional<bool> enabled;