blob: 6e00778d65188f753c0a31ca49390978e6a82b02 [file] [log] [blame]
Ed Tanous40e9b922024-09-10 13:50:16 -07001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright OpenBMC Authors
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +01003#pragma once
4
Ed Tanousd7857202025-01-28 15:32:26 -08005#include "bmcweb_config.h"
6
Ed Tanous04e438c2020-10-03 08:06:26 -07007#include "logging.hpp"
Ed Tanous2c6ffdb2023-06-28 11:28:38 -07008#include "ossl_random.hpp"
Ed Tanous3ccb3ad2023-01-13 17:40:03 -08009#include "utils/ip_utils.hpp"
Ed Tanousfc76b8a2020-09-28 17:21:52 -070010
Ed Tanousd7857202025-01-28 15:32:26 -080011#include <boost/asio/ip/address.hpp>
Ed Tanous1abe55e2018-09-05 08:30:59 -070012#include <nlohmann/json.hpp>
Ratan Gupta12c04ef2019-04-03 10:08:11 +053013
Ed Tanousd7857202025-01-28 15:32:26 -080014#include <chrono>
Gunnar Mills1214b7e2020-06-04 10:11:30 -050015#include <csignal>
Ed Tanousd7857202025-01-28 15:32:26 -080016#include <cstddef>
17#include <cstdint>
18#include <functional>
Ed Tanous89cda632024-04-16 08:45:54 -070019#include <memory>
Ed Tanousbb759e32022-08-02 17:07:54 -070020#include <optional>
Ed Tanousb7f3a822024-06-05 08:45:25 -070021#include <string>
Ed Tanousd7857202025-01-28 15:32:26 -080022#include <string_view>
23#include <unordered_map>
Ed Tanous89cda632024-04-16 08:45:54 -070024#include <vector>
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +010025
Ed Tanous1abe55e2018-09-05 08:30:59 -070026namespace persistent_data
27{
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +010028
Ed Tanous51dae672018-09-05 16:07:32 -070029// entropy: 20 characters, 62 possibilities. log2(62^20) = 119 bits of
30// entropy. OWASP recommends at least 64
31// https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#session-id-entropy
32constexpr std::size_t sessionTokenSize = 20;
33
Ed Tanous89cda632024-04-16 08:45:54 -070034enum class SessionType
Ed Tanous1abe55e2018-09-05 08:30:59 -070035{
Ed Tanous89cda632024-04-16 08:45:54 -070036 None,
37 Basic,
38 Session,
39 Cookie,
40 MutualTLS
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +010041};
42
Ed Tanous1abe55e2018-09-05 08:30:59 -070043struct UserSession
44{
45 std::string uniqueId;
46 std::string sessionToken;
47 std::string username;
48 std::string csrfToken;
Ed Tanousbb759e32022-08-02 17:07:54 -070049 std::optional<std::string> clientId;
Sunitha Harish92f68222020-05-28 05:09:09 -050050 std::string clientIp;
Ed Tanous1abe55e2018-09-05 08:30:59 -070051 std::chrono::time_point<std::chrono::steady_clock> lastUpdated;
Ed Tanous89cda632024-04-16 08:45:54 -070052 SessionType sessionType{SessionType::None};
Ed Tanous7e9c08e2023-06-16 11:29:37 -070053 bool cookieAuth = false;
Joseph Reynolds3bf4e632020-02-06 14:44:32 -060054 bool isConfigureSelfOnly = false;
Ed Tanous47f29342024-03-19 12:18:06 -070055 std::string userRole;
56 std::vector<std::string> userGroups;
Joseph Reynolds3bf4e632020-02-06 14:44:32 -060057
58 // There are two sources of truth for isConfigureSelfOnly:
59 // 1. When pamAuthenticateUser() returns PAM_NEW_AUTHTOK_REQD.
60 // 2. D-Bus User.Manager.GetUserInfo property UserPasswordExpired.
61 // These should be in sync, but the underlying condition can change at any
62 // time. For example, a password can expire or be changed outside of
63 // bmcweb. The value stored here is updated at the start of each
64 // operation and used as the truth within bmcweb.
Kowalski, Kamil5cef0f72018-02-15 15:26:51 +010065
Ed Tanous1abe55e2018-09-05 08:30:59 -070066 /**
67 * @brief Fills object with data from UserSession's JSON representation
68 *
69 * This replaces nlohmann's from_json to ensure no-throw approach
70 *
71 * @param[in] j JSON object from which data should be loaded
72 *
73 * @return a shared pointer if data has been loaded properly, nullptr
74 * otherwise
75 */
Ed Tanous0bdda662023-08-03 17:27:34 -070076 static std::shared_ptr<UserSession>
77 fromJson(const nlohmann::json::object_t& j)
Ed Tanous1abe55e2018-09-05 08:30:59 -070078 {
79 std::shared_ptr<UserSession> userSession =
80 std::make_shared<UserSession>();
Ed Tanous0bdda662023-08-03 17:27:34 -070081 for (const auto& element : j)
Ed Tanous1abe55e2018-09-05 08:30:59 -070082 {
83 const std::string* thisValue =
Ed Tanous0bdda662023-08-03 17:27:34 -070084 element.second.get_ptr<const std::string*>();
Ed Tanous1abe55e2018-09-05 08:30:59 -070085 if (thisValue == nullptr)
86 {
Ed Tanous62598e32023-07-17 17:06:25 -070087 BMCWEB_LOG_ERROR(
88 "Error reading persistent store. Property {} was not of type string",
Ed Tanous0bdda662023-08-03 17:27:34 -070089 element.first);
Ed Tanousdc511aa2020-10-21 12:33:42 -070090 continue;
Ed Tanous1abe55e2018-09-05 08:30:59 -070091 }
Ed Tanous0bdda662023-08-03 17:27:34 -070092 if (element.first == "unique_id")
Ed Tanous1abe55e2018-09-05 08:30:59 -070093 {
94 userSession->uniqueId = *thisValue;
95 }
Ed Tanous0bdda662023-08-03 17:27:34 -070096 else if (element.first == "session_token")
Ed Tanous1abe55e2018-09-05 08:30:59 -070097 {
98 userSession->sessionToken = *thisValue;
99 }
Ed Tanous0bdda662023-08-03 17:27:34 -0700100 else if (element.first == "csrf_token")
Ed Tanous1abe55e2018-09-05 08:30:59 -0700101 {
102 userSession->csrfToken = *thisValue;
103 }
Ed Tanous0bdda662023-08-03 17:27:34 -0700104 else if (element.first == "username")
Ed Tanous1abe55e2018-09-05 08:30:59 -0700105 {
106 userSession->username = *thisValue;
107 }
Ed Tanous0bdda662023-08-03 17:27:34 -0700108 else if (element.first == "client_id")
Sunitha Harish08bdcc72020-05-12 05:17:57 -0500109 {
110 userSession->clientId = *thisValue;
111 }
Ed Tanous0bdda662023-08-03 17:27:34 -0700112 else if (element.first == "client_ip")
Sunitha Harish92f68222020-05-28 05:09:09 -0500113 {
114 userSession->clientIp = *thisValue;
115 }
116
Ed Tanous1abe55e2018-09-05 08:30:59 -0700117 else
118 {
Ed Tanous62598e32023-07-17 17:06:25 -0700119 BMCWEB_LOG_ERROR(
120 "Got unexpected property reading persistent file: {}",
Ed Tanous0bdda662023-08-03 17:27:34 -0700121 element.first);
Ed Tanousdc511aa2020-10-21 12:33:42 -0700122 continue;
Ed Tanous1abe55e2018-09-05 08:30:59 -0700123 }
124 }
Ed Tanousdc511aa2020-10-21 12:33:42 -0700125 // If any of these fields are missing, we can't restore the session, as
126 // we don't have enough information. These 4 fields have been present
127 // in every version of this file in bmcwebs history, so any file, even
128 // on upgrade, should have these present
129 if (userSession->uniqueId.empty() || userSession->username.empty() ||
130 userSession->sessionToken.empty() || userSession->csrfToken.empty())
131 {
Ed Tanous62598e32023-07-17 17:06:25 -0700132 BMCWEB_LOG_DEBUG("Session missing required security "
133 "information, refusing to restore");
Ed Tanousdc511aa2020-10-21 12:33:42 -0700134 return nullptr;
135 }
Ed Tanous1abe55e2018-09-05 08:30:59 -0700136
137 // For now, sessions that were persisted through a reboot get their idle
138 // timer reset. This could probably be overcome with a better
139 // understanding of wall clock time and steady timer time, possibly
140 // persisting values with wall clock time instead of steady timer, but
141 // the tradeoffs of all the corner cases involved are non-trivial, so
142 // this is done temporarily
143 userSession->lastUpdated = std::chrono::steady_clock::now();
Ed Tanous89cda632024-04-16 08:45:54 -0700144 userSession->sessionType = SessionType::Session;
Ed Tanous1abe55e2018-09-05 08:30:59 -0700145
146 return userSession;
Kowalski, Kamil5cef0f72018-02-15 15:26:51 +0100147 }
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +0100148};
149
Ed Tanous3ce36882024-06-09 10:58:16 -0700150enum class MTLSCommonNameParseMode
151{
152 Invalid = 0,
153 // This section approximately matches Redfish AccountService
154 // CertificateMappingAttribute, plus bmcweb defined OEM ones.
155 // Note, IDs in this enum must be maintained between versions, as they are
156 // persisted to disk
157 Whole = 1,
158 CommonName = 2,
159 UserPrincipalName = 3,
160
161 // Intentional gap for future DMTF-defined enums
162
163 // OEM parsing modes for various OEMs
164 Meta = 100,
165};
166
167inline MTLSCommonNameParseMode getMTLSCommonNameParseMode(std::string_view name)
168{
169 if (name == "CommonName")
170 {
171 return MTLSCommonNameParseMode::CommonName;
172 }
173 if (name == "Whole")
174 {
175 // Not yet supported
176 // return MTLSCommonNameParseMode::Whole;
177 }
178 if (name == "UserPrincipalName")
179 {
180 // Not yet supported
181 // return MTLSCommonNameParseMode::UserPrincipalName;
182 }
183 if constexpr (BMCWEB_META_TLS_COMMON_NAME_PARSING)
184 {
185 if (name == "Meta")
186 {
187 return MTLSCommonNameParseMode::Meta;
188 }
189 }
190 return MTLSCommonNameParseMode::Invalid;
191}
192
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100193struct AuthConfigMethods
194{
Ed Tanous3281bcf2024-06-25 16:02:05 -0700195 // Authentication paths
Ed Tanous25b54db2024-04-17 15:40:31 -0700196 bool basic = BMCWEB_BASIC_AUTH;
197 bool sessionToken = BMCWEB_SESSION_AUTH;
198 bool xtoken = BMCWEB_XTOKEN_AUTH;
199 bool cookie = BMCWEB_COOKIE_AUTH;
200 bool tls = BMCWEB_MUTUAL_TLS_AUTH;
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100201
Ed Tanous3281bcf2024-06-25 16:02:05 -0700202 // Whether or not unauthenticated TLS should be accepted
203 // true = reject connections if mutual tls is not provided
204 // false = allow connection, and allow user to use other auth method
205 // Always default to false, because root certificates will not
206 // be provisioned at startup
207 bool tlsStrict = false;
208
Ed Tanous3ce36882024-06-09 10:58:16 -0700209 MTLSCommonNameParseMode mTLSCommonNameParsingMode =
210 getMTLSCommonNameParseMode(
211 BMCWEB_MUTUAL_TLS_COMMON_NAME_PARSING_DEFAULT);
212
Ed Tanous0bdda662023-08-03 17:27:34 -0700213 void fromJson(const nlohmann::json::object_t& j)
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100214 {
Ed Tanous0bdda662023-08-03 17:27:34 -0700215 for (const auto& element : j)
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100216 {
Ed Tanous0bdda662023-08-03 17:27:34 -0700217 const bool* value = element.second.get_ptr<const bool*>();
Ed Tanous3ce36882024-06-09 10:58:16 -0700218 if (value != nullptr)
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100219 {
Ed Tanous3ce36882024-06-09 10:58:16 -0700220 if (element.first == "XToken")
221 {
222 xtoken = *value;
223 }
224 else if (element.first == "Cookie")
225 {
226 cookie = *value;
227 }
228 else if (element.first == "SessionToken")
229 {
230 sessionToken = *value;
231 }
232 else if (element.first == "BasicAuth")
233 {
234 basic = *value;
235 }
236 else if (element.first == "TLS")
237 {
238 tls = *value;
239 }
Ed Tanous3281bcf2024-06-25 16:02:05 -0700240 else if (element.first == "TLSStrict")
241 {
242 tlsStrict = *value;
243 }
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100244 }
Ed Tanous3ce36882024-06-09 10:58:16 -0700245 const uint64_t* intValue =
246 element.second.get_ptr<const uint64_t*>();
247 if (intValue != nullptr)
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100248 {
Ed Tanous3ce36882024-06-09 10:58:16 -0700249 if (element.first == "MTLSCommonNameParseMode")
250 {
251 if (*intValue <= 2 || *intValue == 100)
252 {
253 mTLSCommonNameParsingMode =
254 static_cast<MTLSCommonNameParseMode>(*intValue);
255 }
256 else
257 {
258 BMCWEB_LOG_ERROR(
259 "Json value of {} was out of range of the enum. Ignoring",
260 *intValue);
261 }
262 }
Zbigniew Kurzynski501f1e52019-10-02 11:22:11 +0200263 }
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100264 }
265 }
266};
267
Ed Tanous1abe55e2018-09-05 08:30:59 -0700268class SessionStore
269{
270 public:
271 std::shared_ptr<UserSession> generateUserSession(
Ed Tanous26ccae32023-02-16 10:28:44 -0800272 std::string_view username, const boost::asio::ip::address& clientIp,
Ed Tanous89cda632024-04-16 08:45:54 -0700273 const std::optional<std::string>& clientId, SessionType sessionType,
Sunitha Harishd3239222021-02-24 15:33:29 +0530274 bool isConfigureSelfOnly = false)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700275 {
Ed Tanous1abe55e2018-09-05 08:30:59 -0700276 // Only need csrf tokens for cookie based auth, token doesn't matter
Ed Tanousb7f3a822024-06-05 08:45:25 -0700277 std::string sessionToken =
278 bmcweb::getRandomIdOfLength(sessionTokenSize);
279 std::string csrfToken = bmcweb::getRandomIdOfLength(sessionTokenSize);
280 std::string uniqueId = bmcweb::getRandomIdOfLength(10);
Ed Tanous1abe55e2018-09-05 08:30:59 -0700281
Ed Tanousb7f3a822024-06-05 08:45:25 -0700282 //
283 if (sessionToken.empty() || csrfToken.empty() || uniqueId.empty())
Ed Tanous1abe55e2018-09-05 08:30:59 -0700284 {
Ed Tanousb7f3a822024-06-05 08:45:25 -0700285 BMCWEB_LOG_ERROR("Failed to generate session tokens");
286 return nullptr;
Ed Tanous1abe55e2018-09-05 08:30:59 -0700287 }
Jiaqing Zhao41d61c82021-12-07 13:21:47 +0800288
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400289 auto session = std::make_shared<UserSession>(UserSession{
290 uniqueId,
291 sessionToken,
292 std::string(username),
293 csrfToken,
294 clientId,
295 redfish::ip_util::toString(clientIp),
296 std::chrono::steady_clock::now(),
297 sessionType,
298 false,
299 isConfigureSelfOnly,
300 "",
301 {}});
Patrick Williams41713dd2022-09-28 06:48:07 -0500302 auto it = authTokens.emplace(sessionToken, session);
Ed Tanous1abe55e2018-09-05 08:30:59 -0700303 // Only need to write to disk if session isn't about to be destroyed.
Ed Tanous89cda632024-04-16 08:45:54 -0700304 needWrite = sessionType != SessionType::Basic &&
305 sessionType != SessionType::MutualTLS;
Ed Tanous1abe55e2018-09-05 08:30:59 -0700306 return it.first->second;
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +0100307 }
Ed Tanous1abe55e2018-09-05 08:30:59 -0700308
Ed Tanous26ccae32023-02-16 10:28:44 -0800309 std::shared_ptr<UserSession> loginSessionByToken(std::string_view token)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700310 {
311 applySessionTimeouts();
Ed Tanous51dae672018-09-05 16:07:32 -0700312 if (token.size() != sessionTokenSize)
313 {
314 return nullptr;
315 }
Ed Tanous1abe55e2018-09-05 08:30:59 -0700316 auto sessionIt = authTokens.find(std::string(token));
317 if (sessionIt == authTokens.end())
318 {
319 return nullptr;
320 }
321 std::shared_ptr<UserSession> userSession = sessionIt->second;
322 userSession->lastUpdated = std::chrono::steady_clock::now();
323 return userSession;
324 }
325
Ed Tanous26ccae32023-02-16 10:28:44 -0800326 std::shared_ptr<UserSession> getSessionByUid(std::string_view uid)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700327 {
328 applySessionTimeouts();
329 // TODO(Ed) this is inefficient
330 auto sessionIt = authTokens.begin();
331 while (sessionIt != authTokens.end())
332 {
333 if (sessionIt->second->uniqueId == uid)
334 {
335 return sessionIt->second;
336 }
337 sessionIt++;
338 }
339 return nullptr;
340 }
341
Ed Tanousb5a76932020-09-29 16:16:58 -0700342 void removeSession(const std::shared_ptr<UserSession>& session)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700343 {
344 authTokens.erase(session->sessionToken);
345 needWrite = true;
346 }
347
Ed Tanous89cda632024-04-16 08:45:54 -0700348 std::vector<std::string> getAllUniqueIds()
Ed Tanous1abe55e2018-09-05 08:30:59 -0700349 {
350 applySessionTimeouts();
Ed Tanous89cda632024-04-16 08:45:54 -0700351 std::vector<std::string> ret;
Ed Tanous1abe55e2018-09-05 08:30:59 -0700352 ret.reserve(authTokens.size());
353 for (auto& session : authTokens)
354 {
Ed Tanous89cda632024-04-16 08:45:54 -0700355 ret.push_back(session.second->uniqueId);
356 }
357 return ret;
358 }
359
360 std::vector<std::string> getUniqueIdsBySessionType(SessionType type)
361 {
362 applySessionTimeouts();
363
364 std::vector<std::string> ret;
365 ret.reserve(authTokens.size());
366 for (auto& session : authTokens)
367 {
368 if (type == session.second->sessionType)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700369 {
Ed Tanous89cda632024-04-16 08:45:54 -0700370 ret.push_back(session.second->uniqueId);
Ed Tanous1abe55e2018-09-05 08:30:59 -0700371 }
372 }
373 return ret;
374 }
375
Ed Tanous89cda632024-04-16 08:45:54 -0700376 std::vector<std::shared_ptr<UserSession>> getSessions()
377 {
378 std::vector<std::shared_ptr<UserSession>> sessions;
379 sessions.reserve(authTokens.size());
380 for (auto& session : authTokens)
381 {
382 sessions.push_back(session.second);
383 }
384 return sessions;
385 }
386
Xie Ning9fa06f12022-06-29 18:27:47 +0800387 void removeSessionsByUsername(std::string_view username)
388 {
389 std::erase_if(authTokens, [username](const auto& value) {
390 if (value.second == nullptr)
391 {
392 return false;
393 }
394 return value.second->username == username;
395 });
396 }
397
Ravi Tejae518ef32024-05-16 10:33:08 -0500398 void removeSessionsByUsernameExceptSession(
399 std::string_view username, const std::shared_ptr<UserSession>& session)
400 {
401 std::erase_if(authTokens, [username, session](const auto& value) {
402 if (value.second == nullptr)
403 {
404 return false;
405 }
406
407 return value.second->username == username &&
408 value.second->uniqueId != session->uniqueId;
409 });
410 }
411
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100412 void updateAuthMethodsConfig(const AuthConfigMethods& config)
413 {
Zbigniew Kurzynski009c2a42019-11-14 13:37:15 +0100414 bool isTLSchanged = (authMethodsConfig.tls != config.tls);
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100415 authMethodsConfig = config;
416 needWrite = true;
Zbigniew Kurzynski009c2a42019-11-14 13:37:15 +0100417 if (isTLSchanged)
418 {
419 // recreate socket connections with new settings
Myung Bae92e11bf2025-01-31 09:22:23 -0500420 // NOLINTNEXTLINE(misc-include-cleaner)
Zbigniew Kurzynski009c2a42019-11-14 13:37:15 +0100421 std::raise(SIGHUP);
422 }
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100423 }
424
425 AuthConfigMethods& getAuthMethodsConfig()
426 {
427 return authMethodsConfig;
428 }
429
Ed Tanous9eb808c2022-01-25 10:19:23 -0800430 bool needsWrite() const
Ed Tanous1abe55e2018-09-05 08:30:59 -0700431 {
432 return needWrite;
433 }
Ed Tanous271584a2019-07-09 16:24:22 -0700434 int64_t getTimeoutInSeconds() const
Ed Tanous1abe55e2018-09-05 08:30:59 -0700435 {
Manojkiran Edaf2a4a602020-08-27 16:04:26 +0530436 return std::chrono::seconds(timeoutInSeconds).count();
437 }
438
439 void updateSessionTimeout(std::chrono::seconds newTimeoutInSeconds)
440 {
441 timeoutInSeconds = newTimeoutInSeconds;
442 needWrite = true;
Ed Tanous23a21a12020-07-25 04:45:05 +0000443 }
Ed Tanous1abe55e2018-09-05 08:30:59 -0700444
Ed Tanous1abe55e2018-09-05 08:30:59 -0700445 static SessionStore& getInstance()
446 {
447 static SessionStore sessionStore;
448 return sessionStore;
449 }
450
Ed Tanous1abe55e2018-09-05 08:30:59 -0700451 void applySessionTimeouts()
452 {
453 auto timeNow = std::chrono::steady_clock::now();
Manojkiran Edaf2a4a602020-08-27 16:04:26 +0530454 if (timeNow - lastTimeoutUpdate > std::chrono::seconds(1))
Ed Tanous1abe55e2018-09-05 08:30:59 -0700455 {
456 lastTimeoutUpdate = timeNow;
457 auto authTokensIt = authTokens.begin();
458 while (authTokensIt != authTokens.end())
459 {
460 if (timeNow - authTokensIt->second->lastUpdated >=
Manojkiran Edaf2a4a602020-08-27 16:04:26 +0530461 timeoutInSeconds)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700462 {
463 authTokensIt = authTokens.erase(authTokensIt);
Ratan Gupta07386c62019-12-14 14:06:09 +0530464
Ed Tanous1abe55e2018-09-05 08:30:59 -0700465 needWrite = true;
466 }
467 else
468 {
469 authTokensIt++;
470 }
471 }
472 }
473 }
Gunnar Mills83cf8182020-11-11 15:37:34 -0600474
475 SessionStore(const SessionStore&) = delete;
476 SessionStore& operator=(const SessionStore&) = delete;
Ed Tanousecd6a3a2022-01-07 09:18:40 -0800477 SessionStore(SessionStore&&) = delete;
478 SessionStore& operator=(const SessionStore&&) = delete;
479 ~SessionStore() = default;
Gunnar Mills83cf8182020-11-11 15:37:34 -0600480
481 std::unordered_map<std::string, std::shared_ptr<UserSession>,
Ed Tanous724985f2024-06-05 09:19:06 -0700482 std::hash<std::string>, bmcweb::ConstantTimeCompare>
Gunnar Mills83cf8182020-11-11 15:37:34 -0600483 authTokens;
484
485 std::chrono::time_point<std::chrono::steady_clock> lastTimeoutUpdate;
486 bool needWrite{false};
487 std::chrono::seconds timeoutInSeconds;
488 AuthConfigMethods authMethodsConfig;
489
490 private:
Patrick Williams89492a12023-05-10 07:51:34 -0500491 SessionStore() : timeoutInSeconds(1800) {}
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +0100492};
493
Ed Tanous1abe55e2018-09-05 08:30:59 -0700494} // namespace persistent_data