summaryrefslogtreecommitdiff
path: root/include/sessions.hpp
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2020-07-18 23:51:21 +0300
committerEd Tanous <ed@tanous.net>2020-08-17 23:54:37 +0300
commit52cc112d962920b035c870127784bcbd98948fad (patch)
treecef270a89373ad55b15578d9a52c5956aa5d3f7e /include/sessions.hpp
parentd6c414f36c66b03f272f0cfc3a2e2d5dc0df1271 (diff)
downloadbmcweb-52cc112d962920b035c870127784bcbd98948fad.tar.xz
Remove middlewares
Middlewares, while kinda cool from an academic standpoint, make our build times even worse than they already are. Given that we only really use 1 real middleware today (token auth) and it needs to move into the parser mode anyway (for security limiting buffer sizes), we might as well use this as an opportunity to delete some code. Some other things that happen: 1. Persistent data now moves out of the crow namespace 2. App is no longer a template 3. All request_routes implementations no longer become templates. This should be a decent (unmeasured) win on compile times. This commit was part of a commit previously called "various cleanups". This separates ONLY the middleware deletion part of that. Note, this also deletes about 400 lines of hard to understand code. Change-Id: I4c19e25491a153a2aa2e4ef46fc797bcb5b3581a Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'include/sessions.hpp')
-rw-r--r--include/sessions.hpp41
1 files changed, 16 insertions, 25 deletions
diff --git a/include/sessions.hpp b/include/sessions.hpp
index 217ce95e73..3a787fc129 100644
--- a/include/sessions.hpp
+++ b/include/sessions.hpp
@@ -20,9 +20,6 @@
#include <ibm/locks.hpp>
#endif
-namespace crow
-{
-
namespace persistent_data
{
@@ -364,10 +361,6 @@ class SessionStore
return std::chrono::seconds(timeoutInMinutes).count();
};
- // Persistent data middleware needs to be able to serialize our authTokens
- // structure, which is private
- friend Middleware;
-
static SessionStore& getInstance()
{
static SessionStore sessionStore;
@@ -377,6 +370,16 @@ class SessionStore
SessionStore(const SessionStore&) = delete;
SessionStore& operator=(const SessionStore&) = delete;
+ std::unordered_map<std::string, std::shared_ptr<UserSession>,
+ std::hash<std::string>,
+ crow::utility::ConstantTimeCompare>
+ authTokens;
+
+ std::chrono::time_point<std::chrono::steady_clock> lastTimeoutUpdate;
+ bool needWrite{false};
+ std::chrono::minutes timeoutInMinutes;
+ AuthConfigMethods authMethodsConfig;
+
private:
SessionStore() : timeoutInMinutes(60)
{}
@@ -408,32 +411,20 @@ class SessionStore
}
}
}
-
- std::chrono::time_point<std::chrono::steady_clock> lastTimeoutUpdate;
- std::unordered_map<std::string, std::shared_ptr<UserSession>,
- std::hash<std::string>,
- crow::utility::ConstantTimeCompare>
- authTokens;
- bool needWrite{false};
- std::chrono::minutes timeoutInMinutes;
- AuthConfigMethods authMethodsConfig;
};
} // namespace persistent_data
-} // namespace crow
// to_json(...) definition for objects of UserSession type
namespace nlohmann
{
template <>
-struct adl_serializer<std::shared_ptr<crow::persistent_data::UserSession>>
+struct adl_serializer<std::shared_ptr<persistent_data::UserSession>>
{
- static void
- to_json(nlohmann::json& j,
- const std::shared_ptr<crow::persistent_data::UserSession>& p)
+ static void to_json(nlohmann::json& j,
+ const std::shared_ptr<persistent_data::UserSession>& p)
{
- if (p->persistence !=
- crow::persistent_data::PersistenceType::SINGLE_REQUEST)
+ if (p->persistence != persistent_data::PersistenceType::SINGLE_REQUEST)
{
#ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE
j = nlohmann::json{
@@ -452,10 +443,10 @@ struct adl_serializer<std::shared_ptr<crow::persistent_data::UserSession>>
};
template <>
-struct adl_serializer<crow::persistent_data::AuthConfigMethods>
+struct adl_serializer<persistent_data::AuthConfigMethods>
{
static void to_json(nlohmann::json& j,
- const crow::persistent_data::AuthConfigMethods& c)
+ const persistent_data::AuthConfigMethods& c)
{
j = nlohmann::json{{"XToken", c.xtoken},
{"Cookie", c.cookie},