diff options
| author | James Feist <james.feist@linux.intel.com> | 2019-11-04 21:19:48 +0000 |
|---|---|---|
| committer | James Feist <james.feist@linux.intel.com> | 2019-11-04 21:25:46 +0000 |
| commit | eecd51a46e6d44ae3408d889ed037f4e4270d653 (patch) | |
| tree | a0cbbd26cf1adc0d9c73623cf9b5df3a67b1bbe9 /include | |
| parent | 2ad9c2f694b9a75b5f14f485ebab28bd32d0f575 (diff) | |
| download | bmcweb-eecd51a46e6d44ae3408d889ed037f4e4270d653.tar.gz bmcweb-eecd51a46e6d44ae3408d889ed037f4e4270d653.zip | |
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>
Diffstat (limited to 'include')
| -rw-r--r-- | include/persistent_data_middleware.hpp | 7 | ||||
| -rw-r--r-- | include/sessions.hpp | 61 | ||||
| -rw-r--r-- | include/token_authorization_middleware.hpp | 17 |
3 files changed, 4 insertions, 81 deletions
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 @@ class Middleware 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 @@ class Middleware 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 UserSession } }; -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 @@ class SessionStore return ret; } - void updateAuthMethodsConfig(const AuthConfigMethods& config) - { - authMethodsConfig = config; - needWrite = true; - } - - AuthConfigMethods& getAuthMethodsConfig() - { - return authMethodsConfig; - } - bool needsWrite() { return needWrite; @@ -549,7 +501,6 @@ class SessionStore std::random_device rd; bool needWrite{false}; std::chrono::minutes timeoutInMinutes; - AuthConfigMethods authMethodsConfig; }; } // namespace persistent_data @@ -575,16 +526,4 @@ struct adl_serializer<std::shared_ptr<crow::persistent_data::UserSession>> } } }; - -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 @@ class Middleware 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 @@ class Middleware 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); } |

