diff options
author | Borawski.Lukasz <lukasz.borawski@intel.com> | 2018-02-08 15:24:24 +0300 |
---|---|---|
committer | Ed Tanous <ed.tanous@intel.com> | 2018-03-28 00:02:27 +0300 |
commit | 5d27b854e5b99a9ab3d3f5ad9f99094252d19092 (patch) | |
tree | 21d8a6314caf088dda87832453d8d1726a19acfc /include/sessions.hpp | |
parent | 70141561266d944c1377109698935d129db84e3f (diff) | |
download | bmcweb-5d27b854e5b99a9ab3d3f5ad9f99094252d19092.tar.xz |
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/sessions.hpp')
-rw-r--r-- | include/sessions.hpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/include/sessions.hpp b/include/sessions.hpp index 90df93e427..15ff9cad38 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 |