blob: 33d9c5b7fa61a538e39fc85f90bf4136a30a094d [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// misc-include-cleaner complains if this isn't included,
12// modernize-deprecated-headers complains if it is included.
13// NOLINTNEXTLINE(modernize-deprecated-headers)
14#include <signal.h>
15
16#include <boost/asio/ip/address.hpp>
Ed Tanous1abe55e2018-09-05 08:30:59 -070017#include <nlohmann/json.hpp>
Ratan Gupta12c04ef2019-04-03 10:08:11 +053018
Ed Tanousd7857202025-01-28 15:32:26 -080019#include <chrono>
Gunnar Mills1214b7e2020-06-04 10:11:30 -050020#include <csignal>
Ed Tanousd7857202025-01-28 15:32:26 -080021#include <cstddef>
22#include <cstdint>
23#include <functional>
Ed Tanous89cda632024-04-16 08:45:54 -070024#include <memory>
Ed Tanousbb759e32022-08-02 17:07:54 -070025#include <optional>
Ed Tanousb7f3a822024-06-05 08:45:25 -070026#include <string>
Ed Tanousd7857202025-01-28 15:32:26 -080027#include <string_view>
28#include <unordered_map>
Ed Tanous89cda632024-04-16 08:45:54 -070029#include <vector>
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +010030
Ed Tanous1abe55e2018-09-05 08:30:59 -070031namespace persistent_data
32{
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +010033
Ed Tanous51dae672018-09-05 16:07:32 -070034// entropy: 20 characters, 62 possibilities. log2(62^20) = 119 bits of
35// entropy. OWASP recommends at least 64
36// https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#session-id-entropy
37constexpr std::size_t sessionTokenSize = 20;
38
Ed Tanous89cda632024-04-16 08:45:54 -070039enum class SessionType
Ed Tanous1abe55e2018-09-05 08:30:59 -070040{
Ed Tanous89cda632024-04-16 08:45:54 -070041 None,
42 Basic,
43 Session,
44 Cookie,
45 MutualTLS
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +010046};
47
Ed Tanous1abe55e2018-09-05 08:30:59 -070048struct UserSession
49{
50 std::string uniqueId;
51 std::string sessionToken;
52 std::string username;
53 std::string csrfToken;
Ed Tanousbb759e32022-08-02 17:07:54 -070054 std::optional<std::string> clientId;
Sunitha Harish92f68222020-05-28 05:09:09 -050055 std::string clientIp;
Ed Tanous1abe55e2018-09-05 08:30:59 -070056 std::chrono::time_point<std::chrono::steady_clock> lastUpdated;
Ed Tanous89cda632024-04-16 08:45:54 -070057 SessionType sessionType{SessionType::None};
Ed Tanous7e9c08e2023-06-16 11:29:37 -070058 bool cookieAuth = false;
Joseph Reynolds3bf4e632020-02-06 14:44:32 -060059 bool isConfigureSelfOnly = false;
Ed Tanous47f29342024-03-19 12:18:06 -070060 std::string userRole;
61 std::vector<std::string> userGroups;
Joseph Reynolds3bf4e632020-02-06 14:44:32 -060062
63 // There are two sources of truth for isConfigureSelfOnly:
64 // 1. When pamAuthenticateUser() returns PAM_NEW_AUTHTOK_REQD.
65 // 2. D-Bus User.Manager.GetUserInfo property UserPasswordExpired.
66 // These should be in sync, but the underlying condition can change at any
67 // time. For example, a password can expire or be changed outside of
68 // bmcweb. The value stored here is updated at the start of each
69 // operation and used as the truth within bmcweb.
Kowalski, Kamil5cef0f72018-02-15 15:26:51 +010070
Ed Tanous1abe55e2018-09-05 08:30:59 -070071 /**
72 * @brief Fills object with data from UserSession's JSON representation
73 *
74 * This replaces nlohmann's from_json to ensure no-throw approach
75 *
76 * @param[in] j JSON object from which data should be loaded
77 *
78 * @return a shared pointer if data has been loaded properly, nullptr
79 * otherwise
80 */
Ed Tanous0bdda662023-08-03 17:27:34 -070081 static std::shared_ptr<UserSession>
82 fromJson(const nlohmann::json::object_t& j)
Ed Tanous1abe55e2018-09-05 08:30:59 -070083 {
84 std::shared_ptr<UserSession> userSession =
85 std::make_shared<UserSession>();
Ed Tanous0bdda662023-08-03 17:27:34 -070086 for (const auto& element : j)
Ed Tanous1abe55e2018-09-05 08:30:59 -070087 {
88 const std::string* thisValue =
Ed Tanous0bdda662023-08-03 17:27:34 -070089 element.second.get_ptr<const std::string*>();
Ed Tanous1abe55e2018-09-05 08:30:59 -070090 if (thisValue == nullptr)
91 {
Ed Tanous62598e32023-07-17 17:06:25 -070092 BMCWEB_LOG_ERROR(
93 "Error reading persistent store. Property {} was not of type string",
Ed Tanous0bdda662023-08-03 17:27:34 -070094 element.first);
Ed Tanousdc511aa2020-10-21 12:33:42 -070095 continue;
Ed Tanous1abe55e2018-09-05 08:30:59 -070096 }
Ed Tanous0bdda662023-08-03 17:27:34 -070097 if (element.first == "unique_id")
Ed Tanous1abe55e2018-09-05 08:30:59 -070098 {
99 userSession->uniqueId = *thisValue;
100 }
Ed Tanous0bdda662023-08-03 17:27:34 -0700101 else if (element.first == "session_token")
Ed Tanous1abe55e2018-09-05 08:30:59 -0700102 {
103 userSession->sessionToken = *thisValue;
104 }
Ed Tanous0bdda662023-08-03 17:27:34 -0700105 else if (element.first == "csrf_token")
Ed Tanous1abe55e2018-09-05 08:30:59 -0700106 {
107 userSession->csrfToken = *thisValue;
108 }
Ed Tanous0bdda662023-08-03 17:27:34 -0700109 else if (element.first == "username")
Ed Tanous1abe55e2018-09-05 08:30:59 -0700110 {
111 userSession->username = *thisValue;
112 }
Ed Tanous0bdda662023-08-03 17:27:34 -0700113 else if (element.first == "client_id")
Sunitha Harish08bdcc72020-05-12 05:17:57 -0500114 {
115 userSession->clientId = *thisValue;
116 }
Ed Tanous0bdda662023-08-03 17:27:34 -0700117 else if (element.first == "client_ip")
Sunitha Harish92f68222020-05-28 05:09:09 -0500118 {
119 userSession->clientIp = *thisValue;
120 }
121
Ed Tanous1abe55e2018-09-05 08:30:59 -0700122 else
123 {
Ed Tanous62598e32023-07-17 17:06:25 -0700124 BMCWEB_LOG_ERROR(
125 "Got unexpected property reading persistent file: {}",
Ed Tanous0bdda662023-08-03 17:27:34 -0700126 element.first);
Ed Tanousdc511aa2020-10-21 12:33:42 -0700127 continue;
Ed Tanous1abe55e2018-09-05 08:30:59 -0700128 }
129 }
Ed Tanousdc511aa2020-10-21 12:33:42 -0700130 // If any of these fields are missing, we can't restore the session, as
131 // we don't have enough information. These 4 fields have been present
132 // in every version of this file in bmcwebs history, so any file, even
133 // on upgrade, should have these present
134 if (userSession->uniqueId.empty() || userSession->username.empty() ||
135 userSession->sessionToken.empty() || userSession->csrfToken.empty())
136 {
Ed Tanous62598e32023-07-17 17:06:25 -0700137 BMCWEB_LOG_DEBUG("Session missing required security "
138 "information, refusing to restore");
Ed Tanousdc511aa2020-10-21 12:33:42 -0700139 return nullptr;
140 }
Ed Tanous1abe55e2018-09-05 08:30:59 -0700141
142 // For now, sessions that were persisted through a reboot get their idle
143 // timer reset. This could probably be overcome with a better
144 // understanding of wall clock time and steady timer time, possibly
145 // persisting values with wall clock time instead of steady timer, but
146 // the tradeoffs of all the corner cases involved are non-trivial, so
147 // this is done temporarily
148 userSession->lastUpdated = std::chrono::steady_clock::now();
Ed Tanous89cda632024-04-16 08:45:54 -0700149 userSession->sessionType = SessionType::Session;
Ed Tanous1abe55e2018-09-05 08:30:59 -0700150
151 return userSession;
Kowalski, Kamil5cef0f72018-02-15 15:26:51 +0100152 }
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +0100153};
154
Ed Tanous3ce36882024-06-09 10:58:16 -0700155enum class MTLSCommonNameParseMode
156{
157 Invalid = 0,
158 // This section approximately matches Redfish AccountService
159 // CertificateMappingAttribute, plus bmcweb defined OEM ones.
160 // Note, IDs in this enum must be maintained between versions, as they are
161 // persisted to disk
162 Whole = 1,
163 CommonName = 2,
164 UserPrincipalName = 3,
165
166 // Intentional gap for future DMTF-defined enums
167
168 // OEM parsing modes for various OEMs
169 Meta = 100,
170};
171
172inline MTLSCommonNameParseMode getMTLSCommonNameParseMode(std::string_view name)
173{
174 if (name == "CommonName")
175 {
176 return MTLSCommonNameParseMode::CommonName;
177 }
178 if (name == "Whole")
179 {
180 // Not yet supported
181 // return MTLSCommonNameParseMode::Whole;
182 }
183 if (name == "UserPrincipalName")
184 {
185 // Not yet supported
186 // return MTLSCommonNameParseMode::UserPrincipalName;
187 }
188 if constexpr (BMCWEB_META_TLS_COMMON_NAME_PARSING)
189 {
190 if (name == "Meta")
191 {
192 return MTLSCommonNameParseMode::Meta;
193 }
194 }
195 return MTLSCommonNameParseMode::Invalid;
196}
197
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100198struct AuthConfigMethods
199{
Ed Tanous3281bcf2024-06-25 16:02:05 -0700200 // Authentication paths
Ed Tanous25b54db2024-04-17 15:40:31 -0700201 bool basic = BMCWEB_BASIC_AUTH;
202 bool sessionToken = BMCWEB_SESSION_AUTH;
203 bool xtoken = BMCWEB_XTOKEN_AUTH;
204 bool cookie = BMCWEB_COOKIE_AUTH;
205 bool tls = BMCWEB_MUTUAL_TLS_AUTH;
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100206
Ed Tanous3281bcf2024-06-25 16:02:05 -0700207 // Whether or not unauthenticated TLS should be accepted
208 // true = reject connections if mutual tls is not provided
209 // false = allow connection, and allow user to use other auth method
210 // Always default to false, because root certificates will not
211 // be provisioned at startup
212 bool tlsStrict = false;
213
Ed Tanous3ce36882024-06-09 10:58:16 -0700214 MTLSCommonNameParseMode mTLSCommonNameParsingMode =
215 getMTLSCommonNameParseMode(
216 BMCWEB_MUTUAL_TLS_COMMON_NAME_PARSING_DEFAULT);
217
Ed Tanous0bdda662023-08-03 17:27:34 -0700218 void fromJson(const nlohmann::json::object_t& j)
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100219 {
Ed Tanous0bdda662023-08-03 17:27:34 -0700220 for (const auto& element : j)
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100221 {
Ed Tanous0bdda662023-08-03 17:27:34 -0700222 const bool* value = element.second.get_ptr<const bool*>();
Ed Tanous3ce36882024-06-09 10:58:16 -0700223 if (value != nullptr)
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100224 {
Ed Tanous3ce36882024-06-09 10:58:16 -0700225 if (element.first == "XToken")
226 {
227 xtoken = *value;
228 }
229 else if (element.first == "Cookie")
230 {
231 cookie = *value;
232 }
233 else if (element.first == "SessionToken")
234 {
235 sessionToken = *value;
236 }
237 else if (element.first == "BasicAuth")
238 {
239 basic = *value;
240 }
241 else if (element.first == "TLS")
242 {
243 tls = *value;
244 }
Ed Tanous3281bcf2024-06-25 16:02:05 -0700245 else if (element.first == "TLSStrict")
246 {
247 tlsStrict = *value;
248 }
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100249 }
Ed Tanous3ce36882024-06-09 10:58:16 -0700250 const uint64_t* intValue =
251 element.second.get_ptr<const uint64_t*>();
252 if (intValue != nullptr)
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100253 {
Ed Tanous3ce36882024-06-09 10:58:16 -0700254 if (element.first == "MTLSCommonNameParseMode")
255 {
256 if (*intValue <= 2 || *intValue == 100)
257 {
258 mTLSCommonNameParsingMode =
259 static_cast<MTLSCommonNameParseMode>(*intValue);
260 }
261 else
262 {
263 BMCWEB_LOG_ERROR(
264 "Json value of {} was out of range of the enum. Ignoring",
265 *intValue);
266 }
267 }
Zbigniew Kurzynski501f1e52019-10-02 11:22:11 +0200268 }
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100269 }
270 }
271};
272
Ed Tanous1abe55e2018-09-05 08:30:59 -0700273class SessionStore
274{
275 public:
276 std::shared_ptr<UserSession> generateUserSession(
Ed Tanous26ccae32023-02-16 10:28:44 -0800277 std::string_view username, const boost::asio::ip::address& clientIp,
Ed Tanous89cda632024-04-16 08:45:54 -0700278 const std::optional<std::string>& clientId, SessionType sessionType,
Sunitha Harishd3239222021-02-24 15:33:29 +0530279 bool isConfigureSelfOnly = false)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700280 {
Ed Tanous1abe55e2018-09-05 08:30:59 -0700281 // Only need csrf tokens for cookie based auth, token doesn't matter
Ed Tanousb7f3a822024-06-05 08:45:25 -0700282 std::string sessionToken =
283 bmcweb::getRandomIdOfLength(sessionTokenSize);
284 std::string csrfToken = bmcweb::getRandomIdOfLength(sessionTokenSize);
285 std::string uniqueId = bmcweb::getRandomIdOfLength(10);
Ed Tanous1abe55e2018-09-05 08:30:59 -0700286
Ed Tanousb7f3a822024-06-05 08:45:25 -0700287 //
288 if (sessionToken.empty() || csrfToken.empty() || uniqueId.empty())
Ed Tanous1abe55e2018-09-05 08:30:59 -0700289 {
Ed Tanousb7f3a822024-06-05 08:45:25 -0700290 BMCWEB_LOG_ERROR("Failed to generate session tokens");
291 return nullptr;
Ed Tanous1abe55e2018-09-05 08:30:59 -0700292 }
Jiaqing Zhao41d61c82021-12-07 13:21:47 +0800293
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400294 auto session = std::make_shared<UserSession>(UserSession{
295 uniqueId,
296 sessionToken,
297 std::string(username),
298 csrfToken,
299 clientId,
300 redfish::ip_util::toString(clientIp),
301 std::chrono::steady_clock::now(),
302 sessionType,
303 false,
304 isConfigureSelfOnly,
305 "",
306 {}});
Patrick Williams41713dd2022-09-28 06:48:07 -0500307 auto it = authTokens.emplace(sessionToken, session);
Ed Tanous1abe55e2018-09-05 08:30:59 -0700308 // Only need to write to disk if session isn't about to be destroyed.
Ed Tanous89cda632024-04-16 08:45:54 -0700309 needWrite = sessionType != SessionType::Basic &&
310 sessionType != SessionType::MutualTLS;
Ed Tanous1abe55e2018-09-05 08:30:59 -0700311 return it.first->second;
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +0100312 }
Ed Tanous1abe55e2018-09-05 08:30:59 -0700313
Ed Tanous26ccae32023-02-16 10:28:44 -0800314 std::shared_ptr<UserSession> loginSessionByToken(std::string_view token)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700315 {
316 applySessionTimeouts();
Ed Tanous51dae672018-09-05 16:07:32 -0700317 if (token.size() != sessionTokenSize)
318 {
319 return nullptr;
320 }
Ed Tanous1abe55e2018-09-05 08:30:59 -0700321 auto sessionIt = authTokens.find(std::string(token));
322 if (sessionIt == authTokens.end())
323 {
324 return nullptr;
325 }
326 std::shared_ptr<UserSession> userSession = sessionIt->second;
327 userSession->lastUpdated = std::chrono::steady_clock::now();
328 return userSession;
329 }
330
Ed Tanous26ccae32023-02-16 10:28:44 -0800331 std::shared_ptr<UserSession> getSessionByUid(std::string_view uid)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700332 {
333 applySessionTimeouts();
334 // TODO(Ed) this is inefficient
335 auto sessionIt = authTokens.begin();
336 while (sessionIt != authTokens.end())
337 {
338 if (sessionIt->second->uniqueId == uid)
339 {
340 return sessionIt->second;
341 }
342 sessionIt++;
343 }
344 return nullptr;
345 }
346
Ed Tanousb5a76932020-09-29 16:16:58 -0700347 void removeSession(const std::shared_ptr<UserSession>& session)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700348 {
349 authTokens.erase(session->sessionToken);
350 needWrite = true;
351 }
352
Ed Tanous89cda632024-04-16 08:45:54 -0700353 std::vector<std::string> getAllUniqueIds()
Ed Tanous1abe55e2018-09-05 08:30:59 -0700354 {
355 applySessionTimeouts();
Ed Tanous89cda632024-04-16 08:45:54 -0700356 std::vector<std::string> ret;
Ed Tanous1abe55e2018-09-05 08:30:59 -0700357 ret.reserve(authTokens.size());
358 for (auto& session : authTokens)
359 {
Ed Tanous89cda632024-04-16 08:45:54 -0700360 ret.push_back(session.second->uniqueId);
361 }
362 return ret;
363 }
364
365 std::vector<std::string> getUniqueIdsBySessionType(SessionType type)
366 {
367 applySessionTimeouts();
368
369 std::vector<std::string> ret;
370 ret.reserve(authTokens.size());
371 for (auto& session : authTokens)
372 {
373 if (type == session.second->sessionType)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700374 {
Ed Tanous89cda632024-04-16 08:45:54 -0700375 ret.push_back(session.second->uniqueId);
Ed Tanous1abe55e2018-09-05 08:30:59 -0700376 }
377 }
378 return ret;
379 }
380
Ed Tanous89cda632024-04-16 08:45:54 -0700381 std::vector<std::shared_ptr<UserSession>> getSessions()
382 {
383 std::vector<std::shared_ptr<UserSession>> sessions;
384 sessions.reserve(authTokens.size());
385 for (auto& session : authTokens)
386 {
387 sessions.push_back(session.second);
388 }
389 return sessions;
390 }
391
Xie Ning9fa06f12022-06-29 18:27:47 +0800392 void removeSessionsByUsername(std::string_view username)
393 {
394 std::erase_if(authTokens, [username](const auto& value) {
395 if (value.second == nullptr)
396 {
397 return false;
398 }
399 return value.second->username == username;
400 });
401 }
402
Ravi Tejae518ef32024-05-16 10:33:08 -0500403 void removeSessionsByUsernameExceptSession(
404 std::string_view username, const std::shared_ptr<UserSession>& session)
405 {
406 std::erase_if(authTokens, [username, session](const auto& value) {
407 if (value.second == nullptr)
408 {
409 return false;
410 }
411
412 return value.second->username == username &&
413 value.second->uniqueId != session->uniqueId;
414 });
415 }
416
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100417 void updateAuthMethodsConfig(const AuthConfigMethods& config)
418 {
Zbigniew Kurzynski009c2a42019-11-14 13:37:15 +0100419 bool isTLSchanged = (authMethodsConfig.tls != config.tls);
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100420 authMethodsConfig = config;
421 needWrite = true;
Zbigniew Kurzynski009c2a42019-11-14 13:37:15 +0100422 if (isTLSchanged)
423 {
424 // recreate socket connections with new settings
425 std::raise(SIGHUP);
426 }
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100427 }
428
429 AuthConfigMethods& getAuthMethodsConfig()
430 {
431 return authMethodsConfig;
432 }
433
Ed Tanous9eb808c2022-01-25 10:19:23 -0800434 bool needsWrite() const
Ed Tanous1abe55e2018-09-05 08:30:59 -0700435 {
436 return needWrite;
437 }
Ed Tanous271584a2019-07-09 16:24:22 -0700438 int64_t getTimeoutInSeconds() const
Ed Tanous1abe55e2018-09-05 08:30:59 -0700439 {
Manojkiran Edaf2a4a602020-08-27 16:04:26 +0530440 return std::chrono::seconds(timeoutInSeconds).count();
441 }
442
443 void updateSessionTimeout(std::chrono::seconds newTimeoutInSeconds)
444 {
445 timeoutInSeconds = newTimeoutInSeconds;
446 needWrite = true;
Ed Tanous23a21a12020-07-25 04:45:05 +0000447 }
Ed Tanous1abe55e2018-09-05 08:30:59 -0700448
Ed Tanous1abe55e2018-09-05 08:30:59 -0700449 static SessionStore& getInstance()
450 {
451 static SessionStore sessionStore;
452 return sessionStore;
453 }
454
Ed Tanous1abe55e2018-09-05 08:30:59 -0700455 void applySessionTimeouts()
456 {
457 auto timeNow = std::chrono::steady_clock::now();
Manojkiran Edaf2a4a602020-08-27 16:04:26 +0530458 if (timeNow - lastTimeoutUpdate > std::chrono::seconds(1))
Ed Tanous1abe55e2018-09-05 08:30:59 -0700459 {
460 lastTimeoutUpdate = timeNow;
461 auto authTokensIt = authTokens.begin();
462 while (authTokensIt != authTokens.end())
463 {
464 if (timeNow - authTokensIt->second->lastUpdated >=
Manojkiran Edaf2a4a602020-08-27 16:04:26 +0530465 timeoutInSeconds)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700466 {
467 authTokensIt = authTokens.erase(authTokensIt);
Ratan Gupta07386c62019-12-14 14:06:09 +0530468
Ed Tanous1abe55e2018-09-05 08:30:59 -0700469 needWrite = true;
470 }
471 else
472 {
473 authTokensIt++;
474 }
475 }
476 }
477 }
Gunnar Mills83cf8182020-11-11 15:37:34 -0600478
479 SessionStore(const SessionStore&) = delete;
480 SessionStore& operator=(const SessionStore&) = delete;
Ed Tanousecd6a3a2022-01-07 09:18:40 -0800481 SessionStore(SessionStore&&) = delete;
482 SessionStore& operator=(const SessionStore&&) = delete;
483 ~SessionStore() = default;
Gunnar Mills83cf8182020-11-11 15:37:34 -0600484
485 std::unordered_map<std::string, std::shared_ptr<UserSession>,
Ed Tanous724985f2024-06-05 09:19:06 -0700486 std::hash<std::string>, bmcweb::ConstantTimeCompare>
Gunnar Mills83cf8182020-11-11 15:37:34 -0600487 authTokens;
488
489 std::chrono::time_point<std::chrono::steady_clock> lastTimeoutUpdate;
490 bool needWrite{false};
491 std::chrono::seconds timeoutInSeconds;
492 AuthConfigMethods authMethodsConfig;
493
494 private:
Patrick Williams89492a12023-05-10 07:51:34 -0500495 SessionStore() : timeoutInSeconds(1800) {}
Kowalski, Kamil2b7981f2018-01-31 13:24:59 +0100496};
497
Ed Tanous1abe55e2018-09-05 08:30:59 -0700498} // namespace persistent_data