Revert "Auth methods configuration"
This reverts commit 0ff64dc2cd3a15b4204a477ad2eb5219d66e6110.
Reason for revert: <breaks redfish validator, <edmx:Reference Uri="/redfish/v1/schema/OemAccountService_v1.xml"> but the file name unversioned static/redfish/v1/schema/OemAccountService.xml>
Change-Id: I696dd09bf519e364f5f529a674e047a8eeead578
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/persistent_data_middleware.hpp b/include/persistent_data_middleware.hpp
index 348079b..c368ab2 100644
--- a/include/persistent_data_middleware.hpp
+++ b/include/persistent_data_middleware.hpp
@@ -100,12 +100,6 @@
systemUuid = *jSystemUuid;
}
}
- else if (item.key() == "auth_config")
- {
- SessionStore::getInstance()
- .getAuthMethodsConfig()
- .fromJson(item.value());
- }
else if (item.key() == "sessions")
{
for (const auto& elem : item.value())
@@ -169,7 +163,6 @@
nlohmann::json data{
{"sessions", SessionStore::getInstance().authTokens},
- {"auth_config", SessionStore::getInstance().getAuthMethodsConfig()},
{"system_uuid", systemUuid},
{"revision", jsonRevision}};
persistentFile << data;
diff --git a/include/sessions.hpp b/include/sessions.hpp
index 7493494..df65d61 100644
--- a/include/sessions.hpp
+++ b/include/sessions.hpp
@@ -339,43 +339,6 @@
}
};
-struct AuthConfigMethods
-{
- bool xtoken = true;
- bool cookie = true;
- bool sessionToken = true;
- bool basic = true;
-
- void fromJson(const nlohmann::json& j)
- {
- for (const auto& element : j.items())
- {
- const bool* value = element.value().get_ptr<const bool*>();
- if (value == nullptr)
- {
- continue;
- }
-
- if (element.key() == "XToken")
- {
- xtoken = *value;
- }
- else if (element.key() == "Cookie")
- {
- cookie = *value;
- }
- else if (element.key() == "SessionToken")
- {
- sessionToken = *value;
- }
- else if (element.key() == "BasicAuth")
- {
- basic = *value;
- }
- }
- }
-};
-
class Middleware;
class SessionStore
@@ -482,17 +445,6 @@
return ret;
}
- void updateAuthMethodsConfig(const AuthConfigMethods& config)
- {
- authMethodsConfig = config;
- needWrite = true;
- }
-
- AuthConfigMethods& getAuthMethodsConfig()
- {
- return authMethodsConfig;
- }
-
bool needsWrite()
{
return needWrite;
@@ -549,7 +501,6 @@
std::random_device rd;
bool needWrite{false};
std::chrono::minutes timeoutInMinutes;
- AuthConfigMethods authMethodsConfig;
};
} // namespace persistent_data
@@ -575,16 +526,4 @@
}
}
};
-
-template <> struct adl_serializer<crow::persistent_data::AuthConfigMethods>
-{
- static void to_json(nlohmann::json& j,
- const crow::persistent_data::AuthConfigMethods& c)
- {
- j = nlohmann::json{{"XToken", c.xtoken},
- {"Cookie", c.cookie},
- {"SessionToken", c.sessionToken},
- {"BasicAuth", c.basic}};
- }
-};
} // namespace nlohmann
diff --git a/include/token_authorization_middleware.hpp b/include/token_authorization_middleware.hpp
index 7e4e3bb..0a44050 100644
--- a/include/token_authorization_middleware.hpp
+++ b/include/token_authorization_middleware.hpp
@@ -31,15 +31,8 @@
return;
}
- const crow::persistent_data::AuthConfigMethods& authMethodsConfig =
- crow::persistent_data::SessionStore::getInstance()
- .getAuthMethodsConfig();
-
- if (req.session == nullptr && authMethodsConfig.xtoken)
- {
- req.session = performXtokenAuth(req);
- }
- if (req.session == nullptr && authMethodsConfig.cookie)
+ req.session = performXtokenAuth(req);
+ if (req.session == nullptr)
{
req.session = performCookieAuth(req);
}
@@ -49,13 +42,11 @@
if (!authHeader.empty())
{
// Reject any kind of auth other than basic or token
- if (boost::starts_with(authHeader, "Token ") &&
- authMethodsConfig.sessionToken)
+ if (boost::starts_with(authHeader, "Token "))
{
req.session = performTokenAuth(authHeader);
}
- else if (boost::starts_with(authHeader, "Basic ") &&
- authMethodsConfig.basic)
+ else if (boost::starts_with(authHeader, "Basic "))
{
req.session = performBasicAuth(authHeader);
}