diff options
| author | Borawski.Lukasz <lukasz.borawski@intel.com> | 2018-02-08 13:24:24 +0100 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2018-03-27 21:02:27 +0000 |
| commit | 5d27b854e5b99a9ab3d3f5ad9f99094252d19092 (patch) | |
| tree | 21d8a6314caf088dda87832453d8d1726a19acfc /include | |
| parent | 70141561266d944c1377109698935d129db84e3f (diff) | |
| download | bmcweb-5d27b854e5b99a9ab3d3f5ad9f99094252d19092.tar.gz bmcweb-5d27b854e5b99a9ab3d3f5ad9f99094252d19092.zip | |
Redfish SessionService
- added node version of the SessionService implementation
- added a default timeout member and a get timeout method
to the SessionStore class
Change-Id: I532080789b3d687208510f8b748402735ed888d8
Signed-off-by: Borawski.Lukasz <lukasz.borawski@intel.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/redfish_v1.hpp | 22 | ||||
| -rw-r--r-- | include/sessions.hpp | 9 |
2 files changed, 7 insertions, 24 deletions
diff --git a/include/redfish_v1.hpp b/include/redfish_v1.hpp index aa6da06..99e0b3c 100644 --- a/include/redfish_v1.hpp +++ b/include/redfish_v1.hpp @@ -140,28 +140,6 @@ void request_routes(Crow<Middlewares...>& app) { res.end(); }); - CROW_ROUTE(app, "/redfish/v1/SessionService/") - .methods( - "GET"_method)([&](const crow::request& req, crow::response& res) { - res.json_value = { - {"@odata.context", - "/redfish/v1/$metadata#SessionService.SessionService"}, - {"@odata.id", "/redfish/v1/SessionService"}, - {"@odata.type", "#SessionService.v1_1_1.SessionService"}, - {"Id", "SessionService"}, - {"Name", "SessionService"}, - {"Description", "SessionService"}, - {"Status", - {{"State", "Enabled"}, {"Health", "OK"}, {"HealthRollup", "OK"}}}, - {"ServiceEnabled", true}, - // TODO(ed) converge with session timeouts once they exist - // Bogus number for now - {"SessionTimeout", 1800}}; - get_redfish_sub_routes(app, "/redfish/v1/AccountService", - res.json_value); - res.end(); - }); - CROW_ROUTE(app, "/redfish/v1/Managers/") .methods("GET"_method)( [&](const crow::request& req, crow::response& res) { diff --git a/include/sessions.hpp b/include/sessions.hpp index 90df93e..15ff9ca 100644 --- a/include/sessions.hpp +++ b/include/sessions.hpp @@ -86,6 +86,7 @@ class Middleware; class SessionStore { public: + SessionStore() : timeout_in_minutes(60) {} const UserSession& generate_user_session( const std::string& username, PersistenceType persistence = PersistenceType::TIMEOUT) { @@ -175,6 +176,9 @@ class SessionStore { } bool needs_write() { return need_write_; } + int get_timeout_in_seconds() const { + return std::chrono::seconds(timeout_in_minutes).count(); + }; // Persistent data middleware needs to be able to serialize our auth_tokens // structure, which is private @@ -182,13 +186,13 @@ class SessionStore { private: void apply_session_timeouts() { - std::chrono::minutes timeout(60); auto time_now = std::chrono::steady_clock::now(); if (time_now - last_timeout_update > std::chrono::minutes(1)) { last_timeout_update = time_now; auto auth_tokens_it = auth_tokens.begin(); while (auth_tokens_it != auth_tokens.end()) { - if (time_now - auth_tokens_it->second.last_updated >= timeout) { + if (time_now - auth_tokens_it->second.last_updated >= + timeout_in_minutes) { auth_tokens_it = auth_tokens.erase(auth_tokens_it); need_write_ = true; } else { @@ -201,6 +205,7 @@ class SessionStore { boost::container::flat_map<std::string, UserSession> auth_tokens; std::random_device rd; bool need_write_{false}; + std::chrono::minutes timeout_in_minutes; }; } // namespaec PersistentData |

