Loading src/auth.cpp +0 −26 Changes for src/auth.cpp: 0 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -39,8 +39,6 @@ #include "auth.h" std::mutex blogi::Auth::_authCacheMutex; std::unordered_map<std::string, std::chrono::steady_clock::time_point> blogi::Auth::_authCache; #include "conf.h" #include "theme.h" #include "session.h" Loading Loading @@ -185,19 +183,6 @@ void blogi::Auth::Apilogin(const int tid,const char *username,const char *passwo } bool blogi::Auth::isLoggedIn(const int tid,const uuid::uuid &authid){ std::string key = authid.c_str(); // Check cache first — avoids network round-trip to authdb { std::lock_guard<std::mutex> lk(_authCacheMutex); auto it = _authCache.find(key); if (it != _authCache.end()) { if (std::chrono::steady_clock::now() <= it->second) return true; _authCache.erase(it); } } for(size_t i = 0; i < _config.getAuthSourceCount(); ++i){ const AuthSource &src = _config.getAuthSource(i); try { Loading @@ -216,17 +201,6 @@ bool blogi::Auth::isLoggedIn(const int tid,const uuid::uuid &authid){ } if(clt->ClientAuth() && clt->GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6")){ // Cache successful auth std::lock_guard<std::mutex> lk(_authCacheMutex); _authCache[key] = std::chrono::steady_clock::now() + std::chrono::seconds(AUTH_CACHE_TTL_SECONDS); if (_authCache.size() > 10000) { auto now = std::chrono::steady_clock::now(); for (auto ci = _authCache.begin(); ci != _authCache.end(); ) { if (now > ci->second) ci = _authCache.erase(ci); else ++ci; } } return true; } } catch(...) { Loading src/auth.h +0 −8 Changes for src/auth.h: 0 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -26,9 +26,6 @@ *******************************************************************************/ #include <cstdio> #include <chrono> #include <mutex> #include <unordered_map> #include <authdb/client.h> #include <uuidp.h> Loading Loading @@ -57,10 +54,5 @@ namespace blogi { uuid::uuid &authid, const int tid, const std::string *ssid); std::vector<std::unique_ptr<dbpp::Database>> &_dbconn; const blogi::Config &_config; // Cache auth results to avoid network round-trips on every check static constexpr int AUTH_CACHE_TTL_SECONDS = 300; static std::mutex _authCacheMutex; static std::unordered_map<std::string, std::chrono::steady_clock::time_point> _authCache; }; }; Loading
src/auth.cpp +0 −26 Changes for src/auth.cpp: 0 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -39,8 +39,6 @@ #include "auth.h" std::mutex blogi::Auth::_authCacheMutex; std::unordered_map<std::string, std::chrono::steady_clock::time_point> blogi::Auth::_authCache; #include "conf.h" #include "theme.h" #include "session.h" Loading Loading @@ -185,19 +183,6 @@ void blogi::Auth::Apilogin(const int tid,const char *username,const char *passwo } bool blogi::Auth::isLoggedIn(const int tid,const uuid::uuid &authid){ std::string key = authid.c_str(); // Check cache first — avoids network round-trip to authdb { std::lock_guard<std::mutex> lk(_authCacheMutex); auto it = _authCache.find(key); if (it != _authCache.end()) { if (std::chrono::steady_clock::now() <= it->second) return true; _authCache.erase(it); } } for(size_t i = 0; i < _config.getAuthSourceCount(); ++i){ const AuthSource &src = _config.getAuthSource(i); try { Loading @@ -216,17 +201,6 @@ bool blogi::Auth::isLoggedIn(const int tid,const uuid::uuid &authid){ } if(clt->ClientAuth() && clt->GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6")){ // Cache successful auth std::lock_guard<std::mutex> lk(_authCacheMutex); _authCache[key] = std::chrono::steady_clock::now() + std::chrono::seconds(AUTH_CACHE_TTL_SECONDS); if (_authCache.size() > 10000) { auto now = std::chrono::steady_clock::now(); for (auto ci = _authCache.begin(); ci != _authCache.end(); ) { if (now > ci->second) ci = _authCache.erase(ci); else ++ci; } } return true; } } catch(...) { Loading
src/auth.h +0 −8 Changes for src/auth.h: 0 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -26,9 +26,6 @@ *******************************************************************************/ #include <cstdio> #include <chrono> #include <mutex> #include <unordered_map> #include <authdb/client.h> #include <uuidp.h> Loading Loading @@ -57,10 +54,5 @@ namespace blogi { uuid::uuid &authid, const int tid, const std::string *ssid); std::vector<std::unique_ptr<dbpp::Database>> &_dbconn; const blogi::Config &_config; // Cache auth results to avoid network round-trips on every check static constexpr int AUTH_CACHE_TTL_SECONDS = 300; static std::mutex _authCacheMutex; static std::unordered_map<std::string, std::chrono::steady_clock::time_point> _authCache; }; };