Code sanitizer output

This commit is contained in:
stephb9959
2022-03-25 14:57:35 -07:00
parent f59d3af832
commit ad894aeb17
31 changed files with 201 additions and 174 deletions

View File

@@ -48,6 +48,7 @@ set(BUILD_SHARED_LIBS 1)
add_definitions(-DTIP_SECURITY_SERVICE="1") add_definitions(-DTIP_SECURITY_SERVICE="1")
add_compile_options(-Wall -Wextra)
# add_compile_options(-fsanitize=address) # add_compile_options(-fsanitize=address)
# add_link_options(-fsanitize=address) # add_link_options(-fsanitize=address)

2
build
View File

@@ -1 +1 @@
27 31

View File

@@ -83,7 +83,8 @@ namespace OpenWifi {
if(StorageService()->UserTokenDB().GetToken(CallToken, WT, UserId, RevocationDate)) { if(StorageService()->UserTokenDB().GetToken(CallToken, WT, UserId, RevocationDate)) {
if(RevocationDate!=0) if(RevocationDate!=0)
return false; return false;
Expired = (WT.created_ + WT.expires_in_) < time(nullptr); auto now=OpenWifi::Now();
Expired = (WT.created_ + WT.expires_in_) < now;
if(StorageService()->UserDB().GetUserById(UserId,UInfo.userinfo)) { if(StorageService()->UserDB().GetUserById(UserId,UInfo.userinfo)) {
UInfo.webtoken = WT; UInfo.webtoken = WT;
SessionToken = CallToken; SessionToken = CallToken;
@@ -118,7 +119,8 @@ namespace OpenWifi {
if(StorageService()->SubTokenDB().GetToken(CallToken, WT, UserId, RevocationDate)) { if(StorageService()->SubTokenDB().GetToken(CallToken, WT, UserId, RevocationDate)) {
if(RevocationDate!=0) if(RevocationDate!=0)
return false; return false;
Expired = (WT.created_ + WT.expires_in_) < time(nullptr); auto now=OpenWifi::Now();
Expired = (WT.created_ + WT.expires_in_) < now;
if(StorageService()->SubDB().GetUserById(UserId,UInfo.userinfo)) { if(StorageService()->SubDB().GetUserById(UserId,UInfo.userinfo)) {
UInfo.webtoken = WT; UInfo.webtoken = WT;
SessionToken = CallToken; SessionToken = CallToken;
@@ -178,7 +180,7 @@ namespace OpenWifi {
} }
} }
void AuthService::Logout(const std::string &Token, bool EraseFromCache) { void AuthService::Logout(const std::string &Token,[[maybe_unused]] bool EraseFromCache) {
std::lock_guard Guard(Mutex_); std::lock_guard Guard(Mutex_);
try { try {
@@ -190,7 +192,7 @@ namespace OpenWifi {
} }
} }
void AuthService::SubLogout(const std::string &Token, bool EraseFromCache) { void AuthService::SubLogout(const std::string &Token, [[maybe_unused]] bool EraseFromCache) {
std::lock_guard Guard(Mutex_); std::lock_guard Guard(Mutex_);
try { try {
@@ -202,7 +204,7 @@ namespace OpenWifi {
} }
} }
[[nodiscard]] std::string AuthService::GenerateTokenHMAC(const std::string & UserName, ACCESS_TYPE Type) { [[nodiscard]] std::string AuthService::GenerateTokenHMAC(const std::string & UserName, [[maybe_unused]] ACCESS_TYPE Type) {
std::string Identity(UserName + ":" + fmt::format("{}",std::time(nullptr)) + ":" + std::to_string(rand())); std::string Identity(UserName + ":" + fmt::format("{}",std::time(nullptr)) + ":" + std::to_string(rand()));
HMAC_.update(Identity); HMAC_.update(Identity);
return Poco::DigestEngine::digestToHex(HMAC_.digest()); return Poco::DigestEngine::digestToHex(HMAC_.digest());
@@ -390,7 +392,7 @@ namespace OpenWifi {
return false; return false;
} }
UNAUTHORIZED_REASON AuthService::Authorize( std::string & UserName, const std::string & Password, const std::string & NewPassword, SecurityObjects::UserInfoAndPolicy & UInfo , bool & Expired ) UNAUTHORIZED_REASON AuthService::Authorize( std::string & UserName, const std::string & Password, const std::string & NewPassword, SecurityObjects::UserInfoAndPolicy & UInfo , [[maybe_unused]] bool & Expired )
{ {
std::lock_guard Guard(Mutex_); std::lock_guard Guard(Mutex_);
@@ -436,7 +438,7 @@ namespace OpenWifi {
return INVALID_CREDENTIALS; return INVALID_CREDENTIALS;
} }
UNAUTHORIZED_REASON AuthService::AuthorizeSub( std::string & UserName, const std::string & Password, const std::string & NewPassword, SecurityObjects::UserInfoAndPolicy & UInfo , bool & Expired ) UNAUTHORIZED_REASON AuthService::AuthorizeSub( std::string & UserName, const std::string & Password, const std::string & NewPassword, SecurityObjects::UserInfoAndPolicy & UInfo , [[maybe_unused]] bool & Expired )
{ {
std::lock_guard Guard(Mutex_); std::lock_guard Guard(Mutex_);
@@ -602,7 +604,7 @@ namespace OpenWifi {
if(StorageService()->UserTokenDB().GetToken(TToken, WT, UserId, RevocationDate)) { if(StorageService()->UserTokenDB().GetToken(TToken, WT, UserId, RevocationDate)) {
if(RevocationDate!=0) if(RevocationDate!=0)
return false; return false;
Expired = (WT.created_ + WT.expires_in_) < std::time(nullptr); Expired = (WT.created_ + WT.expires_in_) < OpenWifi::Now();
if(StorageService()->UserDB().GetUserById(UserId,UserInfo)) { if(StorageService()->UserDB().GetUserById(UserId,UserInfo)) {
WebToken = WT; WebToken = WT;
return true; return true;
@@ -622,7 +624,7 @@ namespace OpenWifi {
if(StorageService()->SubTokenDB().GetToken(TToken, WT, UserId, RevocationDate)) { if(StorageService()->SubTokenDB().GetToken(TToken, WT, UserId, RevocationDate)) {
if(RevocationDate!=0) if(RevocationDate!=0)
return false; return false;
Expired = (WT.created_ + WT.expires_in_) < std::time(nullptr); Expired = (WT.created_ + WT.expires_in_) < OpenWifi::Now();
if(StorageService()->SubDB().GetUserById(UserId,UserInfo)) { if(StorageService()->SubDB().GetUserById(UserId,UserInfo)) {
WebToken = WT; WebToken = WT;
return true; return true;

View File

@@ -56,13 +56,9 @@ namespace OpenWifi {
return instance_; return instance_;
} }
void Daemon::initialize() { void Daemon::PostInitialization([[maybe_unused]] Poco::Util::Application &self) {
AssetDir_ = MicroService::instance().ConfigPath("openwifi.restapi.wwwassets"); AssetDir_ = MicroService::instance().ConfigPath("openwifi.restapi.wwwassets");
} }
void MicroServicePostInitialization() {
Daemon()->initialize();
}
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {

View File

@@ -24,11 +24,11 @@
namespace OpenWifi { namespace OpenWifi {
static const char * vDAEMON_PROPERTIES_FILENAME = "owsec.properties"; [[maybe_unused]] static const char * vDAEMON_PROPERTIES_FILENAME = "owsec.properties";
static const char * vDAEMON_ROOT_ENV_VAR = "OWSEC_ROOT"; [[maybe_unused]] static const char * vDAEMON_ROOT_ENV_VAR = "OWSEC_ROOT";
static const char * vDAEMON_CONFIG_ENV_VAR = "OWSEC_CONFIG"; [[maybe_unused]] static const char * vDAEMON_CONFIG_ENV_VAR = "OWSEC_CONFIG";
static const char * vDAEMON_APP_NAME = uSERVICE_SECURITY.c_str(); [[maybe_unused]] static const char * vDAEMON_APP_NAME = uSERVICE_SECURITY.c_str();
static const uint64_t vDAEMON_BUS_TIMER = 5000; [[maybe_unused]] static const uint64_t vDAEMON_BUS_TIMER = 5000;
class Daemon : public MicroService { class Daemon : public MicroService {
public: public:
@@ -40,7 +40,7 @@ namespace OpenWifi {
const SubSystemVec & SubSystems) : const SubSystemVec & SubSystems) :
MicroService( PropFile, RootEnv, ConfigEnv, AppName, BusTimer, SubSystems) {}; MicroService( PropFile, RootEnv, ConfigEnv, AppName, BusTimer, SubSystems) {};
void initialize(); void PostInitialization(Poco::Util::Application &self);
static Daemon *instance(); static Daemon *instance();
inline const std::string & AssetDir() { return AssetDir_; } inline const std::string & AssetDir() { return AssetDir_; }
private: private:
@@ -49,6 +49,9 @@ namespace OpenWifi {
}; };
inline Daemon * Daemon() { return Daemon::instance(); } inline Daemon * Daemon() { return Daemon::instance(); }
inline void DaemonPostInitialization(Poco::Util::Application &self) {
Daemon()->PostInitialization(self);
}
} }
#endif //UCENTRALSEC_DAEMON_H #endif //UCENTRALSEC_DAEMON_H

View File

@@ -67,13 +67,13 @@ namespace OpenWifi {
auto Password1 = Form.get("password1","bla"); auto Password1 = Form.get("password1","bla");
auto Password2 = Form.get("password2","blu"); auto Password2 = Form.get("password2","blu");
auto Id = Form.get("id",""); auto Id = Form.get("id","");
auto Now = std::time(nullptr); auto now = OpenWifi::Now();
SecurityObjects::ActionLink Link; SecurityObjects::ActionLink Link;
if(!StorageService()->ActionLinksDB().GetActionLink(Id,Link)) if(!StorageService()->ActionLinksDB().GetActionLink(Id,Link))
return DoReturnA404(); return DoReturnA404();
if(Now > Link.expires) { if(now > Link.expires) {
StorageService()->ActionLinksDB().CancelAction(Id); StorageService()->ActionLinksDB().CancelAction(Id);
return DoReturnA404(); return DoReturnA404();
} }
@@ -138,14 +138,14 @@ namespace OpenWifi {
auto Password1 = Form.get("password1","bla"); auto Password1 = Form.get("password1","bla");
auto Password2 = Form.get("password2","blu"); auto Password2 = Form.get("password2","blu");
auto Id = Form.get("id",""); auto Id = Form.get("id","");
auto Now = std::time(nullptr); auto now = OpenWifi::Now();
SecurityObjects::ActionLink Link; SecurityObjects::ActionLink Link;
if(!StorageService()->ActionLinksDB().GetActionLink(Id,Link)) { if(!StorageService()->ActionLinksDB().GetActionLink(Id,Link)) {
return DoReturnA404(); return DoReturnA404();
} }
if(Now > Link.expires) { if(now > Link.expires) {
StorageService()->ActionLinksDB().CancelAction(Id); StorageService()->ActionLinksDB().CancelAction(Id);
return DoReturnA404(); return DoReturnA404();
} }
@@ -218,9 +218,9 @@ namespace OpenWifi {
} }
void RESTAPI_action_links::DoEmailVerification(SecurityObjects::ActionLink &Link) { void RESTAPI_action_links::DoEmailVerification(SecurityObjects::ActionLink &Link) {
auto Now = std::time(nullptr); auto now = OpenWifi::Now();
if(Now > Link.expires) { if(now > Link.expires) {
StorageService()->ActionLinksDB().CancelAction(Link.id); StorageService()->ActionLinksDB().CancelAction(Link.id);
return DoReturnA404(); return DoReturnA404();
} }

View File

@@ -24,7 +24,7 @@ namespace OpenWifi {
std::string FileType_; std::string FileType_;
std::string Name_; std::string Name_;
std::string Id_; std::string Id_;
Poco::Logger &Logger_; [[maybe_unused]] Poco::Logger &Logger_;
std::stringstream &OutputStream_; std::stringstream &OutputStream_;
}; };

View File

@@ -8,7 +8,7 @@
namespace OpenWifi { namespace OpenWifi {
inline void Sanitize(const SecurityObjects::UserInfoAndPolicy &User, SecurityObjects::UserInfo & U) { inline void Sanitize([[maybe_unused]] const SecurityObjects::UserInfoAndPolicy &User, SecurityObjects::UserInfo & U) {
U.currentPassword.clear(); U.currentPassword.clear();
U.lastPasswords.clear(); U.lastPasswords.clear();
U.oauthType.clear(); U.oauthType.clear();

View File

@@ -24,7 +24,7 @@ namespace OpenWifi {
std::string FileType_; std::string FileType_;
std::string Name_; std::string Name_;
std::string Id_; std::string Id_;
Poco::Logger &Logger_; [[maybe_unused]] Poco::Logger &Logger_;
std::stringstream &OutputStream_; std::stringstream &OutputStream_;
}; };

View File

@@ -236,7 +236,7 @@ namespace OpenWifi::FMSObjects {
snapshot = std::time(nullptr); snapshot = std::time(nullptr);
} }
bool DeviceReport::from_json(const Poco::JSON::Object::Ptr &Obj) { bool DeviceReport::from_json([[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) {
try { try {
return true; return true;

View File

@@ -626,7 +626,7 @@ namespace OpenWifi::ProvObjects {
RESTAPI_utils::field_to_json( Obj,"data",data); RESTAPI_utils::field_to_json( Obj,"data",data);
RESTAPI_utils::field_to_json( Obj,"entity",entity); RESTAPI_utils::field_to_json( Obj,"entity",entity);
RESTAPI_utils::field_to_json( Obj,"creator",creator); RESTAPI_utils::field_to_json( Obj,"creator",creator);
field_to_json( Obj,"visibility",visibility); RESTAPI_utils::field_to_json( Obj,"visibility",visibility);
RESTAPI_utils::field_to_json( Obj,"access",access); RESTAPI_utils::field_to_json( Obj,"access",access);
RESTAPI_utils::field_to_json( Obj,"managementPolicy", managementPolicy); RESTAPI_utils::field_to_json( Obj,"managementPolicy", managementPolicy);
RESTAPI_utils::field_to_json( Obj,"venue", venue); RESTAPI_utils::field_to_json( Obj,"venue", venue);
@@ -638,7 +638,7 @@ namespace OpenWifi::ProvObjects {
RESTAPI_utils::field_from_json( Obj,"data",data); RESTAPI_utils::field_from_json( Obj,"data",data);
RESTAPI_utils::field_from_json( Obj,"entity",entity); RESTAPI_utils::field_from_json( Obj,"entity",entity);
RESTAPI_utils::field_from_json( Obj,"creator",creator); RESTAPI_utils::field_from_json( Obj,"creator",creator);
field_from_json( Obj,"visibility",visibility); RESTAPI_utils::field_from_json( Obj,"visibility",visibility);
RESTAPI_utils::field_from_json( Obj,"access",access); RESTAPI_utils::field_from_json( Obj,"access",access);
RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy); RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy);
RESTAPI_utils::field_from_json( Obj,"venue", venue); RESTAPI_utils::field_from_json( Obj,"venue", venue);
@@ -837,7 +837,7 @@ namespace OpenWifi::ProvObjects {
return true; return true;
} }
bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I) { bool CreateObjectInfo([[maybe_unused]] const SecurityObjects::UserInfo &U, ObjectInfo &I) {
I.modified = I.created = OpenWifi::Now(); I.modified = I.created = OpenWifi::Now();
I.id = MicroService::CreateUUID(); I.id = MicroService::CreateUUID();
return true; return true;

View File

@@ -400,7 +400,7 @@ namespace OpenWifi::ProvObjects {
std::string data; std::string data;
std::string entity; std::string entity;
std::string creator; std::string creator;
VISIBILITY visibility = PRIVATE; std::string visibility{"private"};
ObjectACLList access; ObjectACLList access;
Types::UUID_t managementPolicy; Types::UUID_t managementPolicy;
std::string venue; std::string venue;

View File

@@ -52,9 +52,9 @@ namespace OpenWifi {
Poco::JSON::Object RObj; Poco::JSON::Object RObj;
form.add("To",PhoneNumber); form.add("To", PhoneNumber);
form.add("From",PhoneNumber_); form.add("From", PhoneNumber_);
form.add("Body","This is from twillio"); form.add("Body", Message);
form.prepareSubmit(req); form.prepareSubmit(req);
std::ostream& ostr = session.sendRequest(req); std::ostream& ostr = session.sendRequest(req);

View File

@@ -27,10 +27,10 @@ namespace OpenWifi {
SenderLoginPassword_ = MicroService::instance().ConfigGetString("mailer.password"); SenderLoginPassword_ = MicroService::instance().ConfigGetString("mailer.password");
Sender_ = MicroService::instance().ConfigGetString("mailer.sender"); Sender_ = MicroService::instance().ConfigGetString("mailer.sender");
LoginMethod_ = MicroService::instance().ConfigGetString("mailer.loginmethod"); LoginMethod_ = MicroService::instance().ConfigGetString("mailer.loginmethod");
MailHostPort_ = (int) MicroService::instance().ConfigGetInt("mailer.port"); MailHostPort_ = MicroService::instance().ConfigGetInt("mailer.port");
TemplateDir_ = MicroService::instance().ConfigPath("mailer.templates", MicroService::instance().DataDir()); TemplateDir_ = MicroService::instance().ConfigPath("mailer.templates", MicroService::instance().DataDir());
MailRetry_ = (int) MicroService::instance().ConfigGetInt("mailer.retry",2*60); MailRetry_ = MicroService::instance().ConfigGetInt("mailer.retry",2*60);
MailAbandon_ = (int) MicroService::instance().ConfigGetInt("mailer.abandon",2*60*60); MailAbandon_ = MicroService::instance().ConfigGetInt("mailer.abandon",2*60*60);
Enabled_ = (!MailHost_.empty() && !SenderLoginPassword_.empty() && !SenderLoginUserName_.empty()); Enabled_ = (!MailHost_.empty() && !SenderLoginPassword_.empty() && !SenderLoginUserName_.empty());
} }
} }
@@ -47,13 +47,13 @@ namespace OpenWifi {
SenderThr_.join(); SenderThr_.join();
} }
void SMTPMailerService::reinitialize(Poco::Util::Application &self) { void SMTPMailerService::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
MicroService::instance().LoadConfigurationFile(); MicroService::instance().LoadConfigurationFile();
Logger().information("Reinitializing."); Logger().information("Reinitializing.");
LoadMyConfig(); LoadMyConfig();
} }
bool SMTPMailerService::SendMessage(const std::string &Recipient, const std::string &Name, const MessageAttributes &Attrs) { bool SMTPMailerService::SendMessage([[maybe_unused]] const std::string &Recipient, const std::string &Name, const MessageAttributes &Attrs) {
std::lock_guard G(Mutex_); std::lock_guard G(Mutex_);
PendingMessages_.push_back(MessageEvent{.Posted=(uint64_t )std::time(nullptr), PendingMessages_.push_back(MessageEvent{.Posted=(uint64_t )std::time(nullptr),
.LastTry=0, .LastTry=0,

View File

@@ -84,9 +84,9 @@ namespace OpenWifi {
private: private:
std::string MailHost_; std::string MailHost_;
std::string Sender_; std::string Sender_;
int MailHostPort_=25; uint32_t MailHostPort_=25;
int MailRetry_=2*60; uint64_t MailRetry_=2*60;
int MailAbandon_=2*60*20; uint64_t MailAbandon_=2*60*20;
std::string SenderLoginUserName_; std::string SenderLoginUserName_;
std::string SenderLoginPassword_; std::string SenderLoginPassword_;
std::string LoginMethod_ = "login"; std::string LoginMethod_ = "login";

View File

@@ -62,7 +62,7 @@ namespace OpenWifi {
StorageClass::Stop(); StorageClass::Stop();
} }
void Archiver::onTimer(Poco::Timer &timer) { void Archiver::onTimer([[maybe_unused]] Poco::Timer &timer) {
Poco::Logger &logger = Poco::Logger::get("STORAGE-ARCHIVER"); Poco::Logger &logger = Poco::Logger::get("STORAGE-ARCHIVER");
logger.information("Squiggy the DB: removing old tokens."); logger.information("Squiggy the DB: removing old tokens.");
StorageService()->SubTokenDB().CleanExpiredTokens(); StorageService()->SubTokenDB().CleanExpiredTokens();

View File

@@ -2614,7 +2614,7 @@ namespace OpenWifi {
return true; return true;
} }
void ConfigurationValidator::reinitialize(Poco::Util::Application &self) { void ConfigurationValidator::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
Logger().information("Reinitializing."); Logger().information("Reinitializing.");
Working_ = Initialized_ = false; Working_ = Initialized_ = false;
Init(); Init();

View File

@@ -80,9 +80,7 @@ using namespace std::chrono_literals;
#include "framework/ow_constants.h" #include "framework/ow_constants.h"
#include "RESTObjects/RESTAPI_SecurityObjects.h" #include "RESTObjects/RESTAPI_SecurityObjects.h"
#include "nlohmann/json.hpp" #include "nlohmann/json.hpp"
#include "ow_version.h" #include "ow_version.h"
#include "fmt/core.h" #include "fmt/core.h"
#define _OWDEBUG_ std::cout<< __FILE__ <<":" << __LINE__ << std::endl; #define _OWDEBUG_ std::cout<< __FILE__ <<":" << __LINE__ << std::endl;
@@ -301,7 +299,7 @@ namespace OpenWifi::RESTAPI_utils {
Obj.set(Field, Arr); Obj.set(Field, Arr);
} }
template<class T> void field_to_json(Poco::JSON::Object Obj, const char *Field, const T &Value) { template<class T> void field_to_json(Poco::JSON::Object &Obj, const char *Field, const T &Value) {
Poco::JSON::Object Answer; Poco::JSON::Object Answer;
Value.to_json(Answer); Value.to_json(Answer);
Obj.set(Field, Answer); Obj.set(Field, Answer);
@@ -575,7 +573,7 @@ namespace OpenWifi::RESTAPI_utils {
try { try {
Poco::JSON::Parser P; Poco::JSON::Parser P;
auto Object = P.parse(ObjectString).template extract<Poco::JSON::Array::Ptr>(); auto Object = P.parse(ObjectString).template extract<Poco::JSON::Array::Ptr>();
for (auto const i : *Object) { for (auto const &i : *Object) {
auto InnerObject = i.template extract<Poco::JSON::Object::Ptr>(); auto InnerObject = i.template extract<Poco::JSON::Object::Ptr>();
T Obj; T Obj;
Obj.from_json(InnerObject); Obj.from_json(InnerObject);
@@ -751,15 +749,12 @@ namespace OpenWifi::Utils {
using byte = std::uint8_t; using byte = std::uint8_t;
[[nodiscard]] inline std::string base64encode(const byte *input, unsigned long size) { [[nodiscard]] inline std::string base64encode(const byte *input, uint32_t size) {
std::string encoded; std::string encoded;
encoded.reserve(((size / 3) + (size % 3 > 0)) * 4); encoded.reserve(((size / 3) + (size % 3 > 0)) * 4);
std::uint32_t temp; std::uint32_t temp,i,ee;
ee = (size/3);
std::size_t i;
int ee = (int)(size/3);
for (i = 0; i < 3*ee; ++i) { for (i = 0; i < 3*ee; ++i) {
temp = input[i++] << 16; temp = input[i++] << 16;
@@ -851,7 +846,7 @@ namespace OpenWifi::Utils {
inline bool ParseTime(const std::string &Time, int & Hours, int & Minutes, int & Seconds) { inline bool ParseTime(const std::string &Time, int & Hours, int & Minutes, int & Seconds) {
Poco::StringTokenizer TimeTokens(Time,":",Poco::StringTokenizer::TOK_TRIM); Poco::StringTokenizer TimeTokens(Time,":",Poco::StringTokenizer::TOK_TRIM);
Hours = Minutes = Hours = 0 ; Hours = Minutes = Seconds = 0 ;
if(TimeTokens.count()==1) { if(TimeTokens.count()==1) {
Hours = std::atoi(TimeTokens[0].c_str()); Hours = std::atoi(TimeTokens[0].c_str());
} else if(TimeTokens.count()==2) { } else if(TimeTokens.count()==2) {
@@ -1257,7 +1252,7 @@ namespace OpenWifi {
inline void exception(const std::exception & E) { inline void exception(const std::exception & E) {
Poco::Thread * CurrentThread = Poco::Thread::current(); Poco::Thread * CurrentThread = Poco::Thread::current();
App_.logger().warning(fmt::format("std::exception in ",CurrentThread->getName())); App_.logger().warning(fmt::format("std::exception in {}: {}",CurrentThread->getName(),E.what()));
} }
inline void exception() { inline void exception() {
@@ -1282,9 +1277,10 @@ namespace OpenWifi {
public: public:
explicit MyPrivateKeyPassphraseHandler(const std::string &Password, Poco::Logger & Logger): explicit MyPrivateKeyPassphraseHandler(const std::string &Password, Poco::Logger & Logger):
PrivateKeyPassphraseHandler(true), PrivateKeyPassphraseHandler(true),
Logger_(Logger), Password_(Password),
Password_(Password) {} Logger_(Logger)
void onPrivateKeyRequested(const void * pSender,std::string & privateKey) { {}
void onPrivateKeyRequested([[maybe_unused]] const void * pSender,std::string & privateKey) {
Logger_.information("Returning key passphrase."); Logger_.information("Returning key passphrase.");
privateKey = Password_; privateKey = Password_;
}; };
@@ -1302,11 +1298,19 @@ namespace OpenWifi {
Poco::Net::Context::VerificationMode M = Poco::Net::Context::VerificationMode M =
Poco::Net::Context::VerificationMode::VERIFY_RELAXED, Poco::Net::Context::VerificationMode::VERIFY_RELAXED,
int backlog = 64) int backlog = 64)
: address_(std::move(Address)), port_(port), key_file_(std::move(Key_file)), : address_(std::move(Address)),
cert_file_(std::move(Cert_file)), root_ca_(std::move(RootCa)), port_(port),
issuer_cert_file_(std::move(Issuer)), client_cas_(std::move(ClientCas)), cert_file_(std::move(Cert_file)),
cas_(std::move(Cas)), key_file_password_(std::move(Key_file_password)), key_file_(std::move(Key_file)),
name_(std::move(Name)), level_(M), backlog_(backlog){}; root_ca_(std::move(RootCa)),
key_file_password_(std::move(Key_file_password)),
issuer_cert_file_(std::move(Issuer)),
client_cas_(std::move(ClientCas)),
cas_(std::move(Cas)),
name_(std::move(Name)),
backlog_(backlog),
level_(M)
{};
[[nodiscard]] inline const std::string &Address() const { return address_; }; [[nodiscard]] inline const std::string &Address() const { return address_; };
[[nodiscard]] inline uint32_t Port() const { return port_; }; [[nodiscard]] inline uint32_t Port() const { return port_; };
@@ -1394,7 +1398,7 @@ namespace OpenWifi {
} }
} }
[[nodiscard]] inline Poco::Net::ServerSocket CreateSocket(Poco::Logger &L) const { [[nodiscard]] inline Poco::Net::ServerSocket CreateSocket([[maybe_unused]] Poco::Logger &L) const {
Poco::Net::Context::Params P; Poco::Net::Context::Params P;
if (address_ == "*") { if (address_ == "*") {
@@ -1532,6 +1536,7 @@ namespace OpenWifi {
private: private:
std::string address_; std::string address_;
uint32_t port_;
std::string cert_file_; std::string cert_file_;
std::string key_file_; std::string key_file_;
std::string root_ca_; std::string root_ca_;
@@ -1539,7 +1544,6 @@ namespace OpenWifi {
std::string issuer_cert_file_; std::string issuer_cert_file_;
std::string client_cas_; std::string client_cas_;
std::string cas_; std::string cas_;
uint32_t port_;
std::string name_; std::string name_;
int backlog_; int backlog_;
Poco::Net::Context::VerificationMode level_; Poco::Net::Context::VerificationMode level_;
@@ -1553,10 +1557,10 @@ namespace OpenWifi {
inline void initialize(Poco::Util::Application &self) override; inline void initialize(Poco::Util::Application &self) override;
inline void uninitialize() override { inline void uninitialize() override {
} }
inline void reinitialize(Poco::Util::Application &self) override { inline void reinitialize([[maybe_unused]] Poco::Util::Application &self) override {
Logger().information("Reloading of this subsystem is not supported."); Logger().information("Reloading of this subsystem is not supported.");
} }
inline void defineOptions(Poco::Util::OptionSet &options) override { inline void defineOptions([[maybe_unused]] Poco::Util::OptionSet &options) override {
} }
inline const std::string & Name() const { return Name_; }; inline const std::string & Name() const { return Name_; };
inline const char * name() const override { return Name_.c_str(); } inline const char * name() const override { return Name_.c_str(); }
@@ -1575,7 +1579,7 @@ namespace OpenWifi {
struct LoggerWrapper { struct LoggerWrapper {
Poco::Logger &L; Poco::Logger &L;
inline LoggerWrapper(Poco::Logger &Logger) : L(Logger) {} explicit inline LoggerWrapper(Poco::Logger &Logger) : L(Logger) {}
}; };
protected: protected:
@@ -1776,17 +1780,17 @@ namespace OpenWifi {
: Bindings_(std::move(map)), : Bindings_(std::move(map)),
Logger_(l), Logger_(l),
Methods_(std::move(Methods)), Methods_(std::move(Methods)),
Server_(Server),
TransactionId_(TransactionId),
Internal_(Internal), Internal_(Internal),
AlwaysAuthorize_(AlwaysAuthorize),
RateLimited_(RateLimited), RateLimited_(RateLimited),
MyRates_(Profile), SubOnlyService_(SubscriberOnly),
SubOnlyService_(SubscriberOnly) AlwaysAuthorize_(AlwaysAuthorize),
{ Server_(Server),
MyRates_(Profile),
TransactionId_(TransactionId)
{
} }
inline bool RoleIsAuthorized(const std::string & Path, const std::string & Method, std::string & Reason) { inline bool RoleIsAuthorized([[maybe_unused]] const std::string & Path, [[maybe_unused]] const std::string & Method, [[maybe_unused]] std::string & Reason) {
return true; return true;
} }
@@ -1854,7 +1858,7 @@ namespace OpenWifi {
continue; continue;
bool Matched = true; bool Matched = true;
for (auto i = 0; i != PathItems.size() && Matched; i++) { for (size_t i = 0; i != PathItems.size() && Matched; i++) {
if (PathItems[i] != ParamItems[i]) { if (PathItems[i] != ParamItems[i]) {
if (ParamItems[i][0] == '{') { if (ParamItems[i][0] == '{') {
auto ParamName = ParamItems[i].substr(1, ParamItems[i].size() - 2); auto ParamName = ParamItems[i].substr(1, ParamItems[i].size() - 2);
@@ -1938,13 +1942,13 @@ namespace OpenWifi {
[[nodiscard]] inline static std::string MakeList(const std::vector<std::string> &L) { [[nodiscard]] inline static std::string MakeList(const std::vector<std::string> &L) {
std::string Return; std::string Return;
for (const auto &i : L) for (const auto &i : L) {
if (Return.empty()) if (Return.empty())
Return = i; Return = i;
else else
Return += ", " + i; Return += ", " + i;
}
return Return; return Return;
} }
static inline bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, Types::UUIDvec_t & Value) { static inline bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, Types::UUIDvec_t & Value) {
@@ -2138,7 +2142,7 @@ namespace OpenWifi {
Response->sendFile(File.path(),MT.ContentType); Response->sendFile(File.path(),MT.ContentType);
} }
inline void SendFile(Poco::TemporaryFile &TempAvatar, const std::string &Type, const std::string & Name) { inline void SendFile(Poco::TemporaryFile &TempAvatar, [[maybe_unused]] const std::string &Type, const std::string & Name) {
Response->setStatus(Poco::Net::HTTPResponse::HTTPStatus::HTTP_OK); Response->setStatus(Poco::Net::HTTPResponse::HTTPStatus::HTTP_OK);
AddCORS(); AddCORS();
auto MT = Utils::FindMediaType(Name); auto MT = Utils::FindMediaType(Name);
@@ -2243,8 +2247,9 @@ namespace OpenWifi {
auto RawSelect = GetParameter(RESTAPI::Protocol::SELECT, ""); auto RawSelect = GetParameter(RESTAPI::Protocol::SELECT, "");
auto Entries = Poco::StringTokenizer(RawSelect,","); auto Entries = Poco::StringTokenizer(RawSelect,",");
for(const auto &i:Entries) for(const auto &i:Entries) {
QB_.Select.emplace_back(i); QB_.Select.emplace_back(i);
}
if(QB_.Offset<1) if(QB_.Offset<1)
QB_.Offset=0; QB_.Offset=0;
return true; return true;
@@ -2640,7 +2645,7 @@ namespace OpenWifi {
} }
[[nodiscard]] inline std::string WrapSystemId(const std::string & PayLoad) { [[nodiscard]] inline std::string WrapSystemId(const std::string & PayLoad) {
return std::move( SystemInfoWrapper_ + PayLoad + "}"); return SystemInfoWrapper_ + PayLoad + "}";
} }
[[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; } [[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; }
@@ -2712,7 +2717,7 @@ namespace OpenWifi {
} }
inline static bool IsTokenExpired(const SecurityObjects::WebToken &T) { inline static bool IsTokenExpired(const SecurityObjects::WebToken &T) {
return ((T.expires_in_+T.created_)<std::time(nullptr)); return ((T.expires_in_+T.created_) < OpenWifi::Now());
} }
inline bool RetrieveTokenInformation(const std::string & SessionToken, inline bool RetrieveTokenInformation(const std::string & SessionToken,
@@ -2898,13 +2903,7 @@ namespace OpenWifi {
class ExtRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory { class ExtRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
public: public:
explicit ExtRequestHandlerFactory(RESTAPI_GenericServer & Server) : ExtRequestHandlerFactory() = default;
Logger_(RESTAPI_ExtServer::instance()->Logger()),
Server_(Server)
{
}
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override { inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
try { try {
Poco::URI uri(Request.getURI()); Poco::URI uri(Request.getURI());
@@ -2916,17 +2915,14 @@ namespace OpenWifi {
} }
return nullptr; return nullptr;
} }
private: private:
static inline std::atomic_uint64_t TransactionId_ = 1; static inline std::atomic_uint64_t TransactionId_ = 1;
Poco::Logger &Logger_;
RESTAPI_GenericServer &Server_;
}; };
class LogMuxer : public Poco::Channel { class LogMuxer : public Poco::Channel {
public: public:
inline std::string getProperty( const std::string &p ) const final { inline std::string getProperty( [[maybe_unused]] const std::string &p ) const final {
return ""; return "";
} }
@@ -2977,7 +2973,7 @@ namespace OpenWifi {
} }
} }
inline void setProperty(const std::string &name, const std::string &value) final { inline void setProperty([[maybe_unused]] const std::string &name, [[maybe_unused]] const std::string &value) final {
} }
@@ -3039,10 +3035,7 @@ namespace OpenWifi {
class IntRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory { class IntRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
public: public:
explicit IntRequestHandlerFactory(RESTAPI_GenericServer & Server) : inline IntRequestHandlerFactory() = default;
Logger_(RESTAPI_IntServer()->Logger()),
Server_(Server){}
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override { inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
Poco::URI uri(Request.getURI()); Poco::URI uri(Request.getURI());
auto *Path = uri.getPath().c_str(); auto *Path = uri.getPath().c_str();
@@ -3050,8 +3043,6 @@ namespace OpenWifi {
} }
private: private:
static inline std::atomic_uint64_t TransactionId_ = 1; static inline std::atomic_uint64_t TransactionId_ = 1;
Poco::Logger &Logger_;
RESTAPI_GenericServer &Server_;
}; };
struct MicroServiceMeta { struct MicroServiceMeta {
@@ -3198,7 +3189,6 @@ namespace OpenWifi {
bool DebugMode_ = false; bool DebugMode_ = false;
std::string DataDir_; std::string DataDir_;
std::string WWWAssetsDir_; std::string WWWAssetsDir_;
SubSystemVec SubSystems_;
Poco::Crypto::CipherFactory & CipherFactory_ = Poco::Crypto::CipherFactory::defaultFactory(); Poco::Crypto::CipherFactory & CipherFactory_ = Poco::Crypto::CipherFactory::defaultFactory();
Poco::Crypto::Cipher * Cipher_ = nullptr; Poco::Crypto::Cipher * Cipher_ = nullptr;
Poco::SHA2Engine SHA2_; Poco::SHA2Engine SHA2_;
@@ -3217,6 +3207,7 @@ namespace OpenWifi {
std::string DAEMON_CONFIG_ENV_VAR; std::string DAEMON_CONFIG_ENV_VAR;
std::string DAEMON_APP_NAME; std::string DAEMON_APP_NAME;
uint64_t DAEMON_BUS_TIMER; uint64_t DAEMON_BUS_TIMER;
SubSystemVec SubSystems_;
bool NoAPISecurity_=false; bool NoAPISecurity_=false;
bool NoBuiltInCrypto_=false; bool NoBuiltInCrypto_=false;
Poco::JWT::Signer Signer_; Poco::JWT::Signer Signer_;
@@ -3226,7 +3217,7 @@ namespace OpenWifi {
std::exit(Reason); std::exit(Reason);
} }
inline void MicroService::BusMessageReceived(const std::string &Key, const std::string & Payload) { inline void MicroService::BusMessageReceived([[maybe_unused]] const std::string &Key, const std::string & Payload) {
std::lock_guard G(InfraMutex_); std::lock_guard G(InfraMutex_);
try { try {
Poco::JSON::Parser P; Poco::JSON::Parser P;
@@ -3425,6 +3416,8 @@ namespace OpenWifi {
} }
} }
void DaemonPostInitialization(Poco::Util::Application &self);
inline void MicroService::initialize(Poco::Util::Application &self) { inline void MicroService::initialize(Poco::Util::Application &self) {
// add the default services // add the default services
LoadConfigurationFile(); LoadConfigurationFile();
@@ -3458,11 +3451,10 @@ namespace OpenWifi {
InitializeSubSystemServers(); InitializeSubSystemServers();
ServerApplication::initialize(self); ServerApplication::initialize(self);
DaemonPostInitialization(self);
Types::TopicNotifyFunction F = [this](const std::string &Key,const std::string &Payload) { this->BusMessageReceived(Key, Payload); }; Types::TopicNotifyFunction F = [this](const std::string &Key,const std::string &Payload) { this->BusMessageReceived(Key, Payload); };
KafkaManager()->RegisterTopicWatcher(KafkaTopics::SERVICE_EVENTS, F); KafkaManager()->RegisterTopicWatcher(KafkaTopics::SERVICE_EVENTS, F);
MicroServicePostInitialization();
} }
inline void MicroService::uninitialize() { inline void MicroService::uninitialize() {
@@ -3512,28 +3504,28 @@ namespace OpenWifi {
} }
inline void MicroService::handleHelp(const std::string &name, const std::string &value) { inline void MicroService::handleHelp([[maybe_unused]] const std::string &name, [[maybe_unused]] const std::string &value) {
HelpRequested_ = true; HelpRequested_ = true;
displayHelp(); displayHelp();
stopOptionsProcessing(); stopOptionsProcessing();
} }
inline void MicroService::handleVersion(const std::string &name, const std::string &value) { inline void MicroService::handleVersion([[maybe_unused]] const std::string &name, [[maybe_unused]] const std::string &value) {
HelpRequested_ = true; HelpRequested_ = true;
std::cout << Version() << std::endl; std::cout << Version() << std::endl;
stopOptionsProcessing(); stopOptionsProcessing();
} }
inline void MicroService::handleDebug(const std::string &name, const std::string &value) { inline void MicroService::handleDebug([[maybe_unused]] const std::string &name, const std::string &value) {
if(value == "true") if(value == "true")
DebugMode_ = true ; DebugMode_ = true ;
} }
inline void MicroService::handleLogs(const std::string &name, const std::string &value) { inline void MicroService::handleLogs([[maybe_unused]] const std::string &name, const std::string &value) {
LogDir_ = value; LogDir_ = value;
} }
inline void MicroService::handleConfig(const std::string &name, const std::string &value) { inline void MicroService::handleConfig([[maybe_unused]] const std::string &name, const std::string &value) {
ConfigFileName_ = value; ConfigFileName_ = value;
} }
@@ -3688,14 +3680,16 @@ namespace OpenWifi {
} }
inline std::string MicroService::Encrypt(const std::string &S) { inline std::string MicroService::Encrypt(const std::string &S) {
if(NoBuiltInCrypto_) if(NoBuiltInCrypto_) {
return S; return S;
}
return Cipher_->encryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);; return Cipher_->encryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);;
} }
inline std::string MicroService::Decrypt(const std::string &S) { inline std::string MicroService::Decrypt(const std::string &S) {
if(NoBuiltInCrypto_) if(NoBuiltInCrypto_) {
return S; return S;
}
return Cipher_->decryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);; return Cipher_->decryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);;
} }
@@ -3770,10 +3764,10 @@ namespace OpenWifi {
std::unique_ptr<Poco::Net::HTTPServer> NewServer; std::unique_ptr<Poco::Net::HTTPServer> NewServer;
if(MicroService::instance().NoAPISecurity()) { if(MicroService::instance().NoAPISecurity()) {
auto Sock{Svr.CreateSocket(Logger())}; auto Sock{Svr.CreateSocket(Logger())};
NewServer = std::make_unique<Poco::Net::HTTPServer>(new ExtRequestHandlerFactory(Server_), Pool_, Sock, Params); NewServer = std::make_unique<Poco::Net::HTTPServer>(new ExtRequestHandlerFactory, Pool_, Sock, Params);
} else { } else {
auto Sock{Svr.CreateSecureSocket(Logger())}; auto Sock{Svr.CreateSecureSocket(Logger())};
NewServer = std::make_unique<Poco::Net::HTTPServer>(new ExtRequestHandlerFactory(Server_), Pool_, Sock, Params); NewServer = std::make_unique<Poco::Net::HTTPServer>(new ExtRequestHandlerFactory, Pool_, Sock, Params);
}; };
NewServer->start(); NewServer->start();
RESTServers_.push_back(std::move(NewServer)); RESTServers_.push_back(std::move(NewServer));
@@ -3806,10 +3800,10 @@ namespace OpenWifi {
std::unique_ptr<Poco::Net::HTTPServer> NewServer; std::unique_ptr<Poco::Net::HTTPServer> NewServer;
if(MicroService::instance().NoAPISecurity()) { if(MicroService::instance().NoAPISecurity()) {
auto Sock{Svr.CreateSocket(Logger())}; auto Sock{Svr.CreateSocket(Logger())};
NewServer = std::make_unique<Poco::Net::HTTPServer>(new IntRequestHandlerFactory(Server_), Pool_, Sock, Params); NewServer = std::make_unique<Poco::Net::HTTPServer>(new IntRequestHandlerFactory, Pool_, Sock, Params);
} else { } else {
auto Sock{Svr.CreateSecureSocket(Logger())}; auto Sock{Svr.CreateSecureSocket(Logger())};
NewServer = std::make_unique<Poco::Net::HTTPServer>(new IntRequestHandlerFactory(Server_), Pool_, Sock, Params); NewServer = std::make_unique<Poco::Net::HTTPServer>(new IntRequestHandlerFactory, Pool_, Sock, Params);
}; };
NewServer->start(); NewServer->start();
RESTServers_.push_back(std::move(NewServer)); RESTServers_.push_back(std::move(NewServer));
@@ -3818,7 +3812,7 @@ namespace OpenWifi {
return 0; return 0;
} }
inline int MicroService::main(const ArgVec &args) { inline int MicroService::main([[maybe_unused]] const ArgVec &args) {
MyErrorHandler ErrorHandler(*this); MyErrorHandler ErrorHandler(*this);
Poco::ErrorHandler::set(&ErrorHandler); Poco::ErrorHandler::set(&ErrorHandler);
@@ -3864,7 +3858,7 @@ namespace OpenWifi {
} }
} }
inline void SubSystemServer::initialize(Poco::Util::Application &self) { inline void SubSystemServer::initialize([[maybe_unused]] Poco::Util::Application &self) {
auto i = 0; auto i = 0;
bool good = true; bool good = true;
@@ -3967,39 +3961,39 @@ namespace OpenWifi {
KafkaEnabled_ = MicroService::instance().ConfigGetBool("openwifi.kafka.enable",false); KafkaEnabled_ = MicroService::instance().ConfigGetBool("openwifi.kafka.enable",false);
} }
inline void KafkaLoggerFun(cppkafka::KafkaHandleBase & handle, int level, const std::string & facility, const std::string &messqge) { inline void KafkaLoggerFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int level, const std::string & facility, const std::string &message) {
switch ((cppkafka::LogLevel) level) { switch ((cppkafka::LogLevel) level) {
case cppkafka::LogLevel::LogNotice: { case cppkafka::LogLevel::LogNotice: {
KafkaManager()->Logger().notice(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); KafkaManager()->Logger().notice(fmt::format("kafka-log: facility: {} message: {}",facility, message));
} }
break; break;
case cppkafka::LogLevel::LogDebug: { case cppkafka::LogLevel::LogDebug: {
KafkaManager()->Logger().debug(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); KafkaManager()->Logger().debug(fmt::format("kafka-log: facility: {} message: {}",facility, message));
} }
break; break;
case cppkafka::LogLevel::LogInfo: { case cppkafka::LogLevel::LogInfo: {
KafkaManager()->Logger().information(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); KafkaManager()->Logger().information(fmt::format("kafka-log: facility: {} message: {}",facility, message));
} }
break; break;
case cppkafka::LogLevel::LogWarning: { case cppkafka::LogLevel::LogWarning: {
KafkaManager()->Logger().warning(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); KafkaManager()->Logger().warning(fmt::format("kafka-log: facility: {} message: {}",facility, message));
} }
break; break;
case cppkafka::LogLevel::LogAlert: case cppkafka::LogLevel::LogAlert:
case cppkafka::LogLevel::LogCrit: { case cppkafka::LogLevel::LogCrit: {
KafkaManager()->Logger().critical(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); KafkaManager()->Logger().critical(fmt::format("kafka-log: facility: {} message: {}",facility, message));
} }
break; break;
case cppkafka::LogLevel::LogErr: case cppkafka::LogLevel::LogErr:
case cppkafka::LogLevel::LogEmerg: case cppkafka::LogLevel::LogEmerg:
default: { default: {
KafkaManager()->Logger().error(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); KafkaManager()->Logger().error(fmt::format("kafka-log: facility: {} message: {}",facility, message));
} }
break; break;
} }
} }
inline void KafkaErrorFun(cppkafka::KafkaHandleBase & handle, int error, const std::string &reason) { inline void KafkaErrorFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int error, const std::string &reason) {
KafkaManager()->Logger().error(fmt::format("kafka-error: {}, reason: {}", error, reason)); KafkaManager()->Logger().error(fmt::format("kafka-error: {}, reason: {}", error, reason));
} }
@@ -4072,13 +4066,13 @@ namespace OpenWifi {
Config.set_default_topic_configuration(topic_config); Config.set_default_topic_configuration(topic_config);
cppkafka::Consumer Consumer(Config); cppkafka::Consumer Consumer(Config);
Consumer.set_assignment_callback([this](cppkafka::TopicPartitionList& partitions) { Consumer.set_assignment_callback([](cppkafka::TopicPartitionList& partitions) {
if(!partitions.empty()) { if(!partitions.empty()) {
KafkaManager()->Logger().information(fmt::format("Partition assigned: {}...", KafkaManager()->Logger().information(fmt::format("Partition assigned: {}...",
partitions.front().get_partition())); partitions.front().get_partition()));
} }
}); });
Consumer.set_revocation_callback([this](const cppkafka::TopicPartitionList& partitions) { Consumer.set_revocation_callback([](const cppkafka::TopicPartitionList& partitions) {
if(!partitions.empty()) { if(!partitions.empty()) {
KafkaManager()->Logger().information(fmt::format("Partition revocation: {}...", KafkaManager()->Logger().information(fmt::format("Partition revocation: {}...",
partitions.front().get_partition())); partitions.front().get_partition()));
@@ -4119,14 +4113,14 @@ namespace OpenWifi {
Consumer.unsubscribe(); Consumer.unsubscribe();
} }
inline void RESTAPI_ExtServer::reinitialize(Poco::Util::Application &self) { inline void RESTAPI_ExtServer::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
MicroService::instance().LoadConfigurationFile(); MicroService::instance().LoadConfigurationFile();
Logger().information("Reinitializing."); Logger().information("Reinitializing.");
Stop(); Stop();
Start(); Start();
} }
void RESTAPI_IntServer::reinitialize(Poco::Util::Application &self) { void RESTAPI_IntServer::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
MicroService::instance().LoadConfigurationFile(); MicroService::instance().LoadConfigurationFile();
Logger().information("Reinitializing."); Logger().information("Reinitializing.");
Stop(); Stop();
@@ -4475,7 +4469,7 @@ namespace OpenWifi {
#ifdef TIP_SECURITY_SERVICE #ifdef TIP_SECURITY_SERVICE
[[nodiscard]] bool AuthServiceIsAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired , bool Sub ); [[nodiscard]] bool AuthServiceIsAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired , bool Sub );
#endif #endif
inline bool RESTAPIHandler::IsAuthorized( bool & Expired , bool & Contacted , bool Sub ) { inline bool RESTAPIHandler::IsAuthorized( bool & Expired , [[maybe_unused]] bool & Contacted , bool Sub ) {
if(Internal_ && Request->has("X-INTERNAL-NAME")) { if(Internal_ && Request->has("X-INTERNAL-NAME")) {
auto Allowed = MicroService::instance().IsValidAPIKEY(*Request); auto Allowed = MicroService::instance().IsValidAPIKEY(*Request);
if(!Allowed) { if(!Allowed) {

View File

@@ -108,11 +108,11 @@ namespace ORM {
return "LONGBLOB"; return "LONGBLOB";
else if(Type==OpenWifi::DBType::pgsql) else if(Type==OpenWifi::DBType::pgsql)
return "BYTEA"; return "BYTEA";
else if(Type==OpenWifi::DBType::sqlite) else
return "BLOB"; return "BLOB";
default: default:
assert(false); assert(false);
return "";
} }
assert(false); assert(false);
return ""; return "";
@@ -121,12 +121,13 @@ namespace ORM {
inline std::string Escape(const std::string &S) { inline std::string Escape(const std::string &S) {
std::string R; std::string R;
for(const auto &i:S) for(const auto &i:S) {
if(i=='\'') if (i == '\'')
R += "''"; R += "''";
else else
R += i; R += i;
return R; }
return R;
} }
enum SqlComparison { EQ = 0, NEQ, LT, LTE, GT, GTE }; enum SqlComparison { EQ = 0, NEQ, LT, LTE, GT, GTE };
@@ -157,7 +158,9 @@ namespace ORM {
template <typename RecordType> class DBCache { template <typename RecordType> class DBCache {
public: public:
DBCache(unsigned Size, unsigned Timeout) DBCache(unsigned Size, unsigned Timeout) :
Size_(Size),
Timeout_(Timeout)
{ {
} }
@@ -166,7 +169,8 @@ namespace ORM {
virtual void UpdateCache(const RecordType &R)=0; virtual void UpdateCache(const RecordType &R)=0;
virtual void Delete(const std::string &FieldName, const std::string &Value)=0; virtual void Delete(const std::string &FieldName, const std::string &Value)=0;
private: private:
size_t Size_=0;
uint64_t Timeout_=0;
}; };
template <typename RecordTuple, typename RecordType> class DB { template <typename RecordTuple, typename RecordType> class DB {
@@ -182,8 +186,8 @@ namespace ORM {
Poco::Logger &L, Poco::Logger &L,
const char *Prefix, const char *Prefix,
DBCache<RecordType> * Cache=nullptr): DBCache<RecordType> * Cache=nullptr):
Type_(dbtype),
TableName_(TableName), TableName_(TableName),
Type_(dbtype),
Pool_(Pool), Pool_(Pool),
Logger_(L), Logger_(L),
Prefix_(Prefix), Prefix_(Prefix),
@@ -290,7 +294,7 @@ namespace ORM {
return std::string("(")+P1 + BOPS[BOP] + P2 +")"; return std::string("(")+P1 + BOPS[BOP] + P2 +")";
} }
std::string OP( bool Paran, const std::string &P1, SqlBinaryOp BOP , const std::string &P2) { std::string OP( [[maybe_unused]] bool Paran, const std::string &P1, SqlBinaryOp BOP , const std::string &P2) {
return P1 + BOPS[BOP] + P2 +")"; return P1 + BOPS[BOP] + P2 +")";
} }
@@ -865,19 +869,19 @@ namespace ORM {
} }
protected: protected:
std::string TableName_;
OpenWifi::DBType Type_;
Poco::Data::SessionPool &Pool_; Poco::Data::SessionPool &Pool_;
Poco::Logger &Logger_; Poco::Logger &Logger_;
std::string TableName_; std::string Prefix_;
DBCache<RecordType> *Cache_= nullptr; DBCache<RecordType> *Cache_= nullptr;
private: private:
OpenWifi::DBType Type_;
std::string CreateFields_; std::string CreateFields_;
std::string SelectFields_; std::string SelectFields_;
std::string SelectList_; std::string SelectList_;
std::string UpdateFields_; std::string UpdateFields_;
std::vector<std::string> IndexCreation_; std::vector<std::string> IndexCreation_;
std::map<std::string,int> FieldNames_; std::map<std::string,int> FieldNames_;
std::string Prefix_;
}; };
} }

View File

@@ -7,6 +7,16 @@
#include <string> #include <string>
#include "Poco/String.h" #include "Poco/String.h"
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
namespace OpenWifi::RESTAPI::Errors { namespace OpenWifi::RESTAPI::Errors {
static const std::string MissingUUID{"Missing UUID."}; static const std::string MissingUUID{"Missing UUID."};
static const std::string MissingSerialNumber{"Missing Serial Number."}; static const std::string MissingSerialNumber{"Missing Serial Number."};
@@ -353,4 +363,12 @@ namespace OpenWifi::Provisioning::DeviceClass {
} }
#if defined(__GNUC__ )
#pragma GCC diagnostic pop
#endif
#if defined(__clang__)
#pragma clang diagnostic pop
#endif

View File

@@ -42,7 +42,7 @@ namespace OpenWifi {
DB(T, Name.c_str(), ActionLinksDB_Fields,{}, P, L, ShortName.c_str()) { DB(T, Name.c_str(), ActionLinksDB_Fields,{}, P, L, ShortName.c_str()) {
} }
bool ActionLinkDB::Upgrade(uint32_t from, uint32_t &to) { bool ActionLinkDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
std::vector<std::string> Statements{ std::vector<std::string> Statements{
"alter table " + TableName_ + " add column userAction BOOLEAN default true;" "alter table " + TableName_ + " add column userAction BOOLEAN default true;"
}; };

View File

@@ -29,7 +29,7 @@ namespace OpenWifi {
class ActionLinkDB : public ORM::DB<ActionLinkRecordTuple, SecurityObjects::ActionLink> { class ActionLinkDB : public ORM::DB<ActionLinkRecordTuple, SecurityObjects::ActionLink> {
public: public:
ActionLinkDB( const std::string &name, const std::string &shortname, OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); ActionLinkDB( const std::string &name, const std::string &shortname, OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~ActionLinkDB() {}
bool CreateAction( SecurityObjects::ActionLink & A); bool CreateAction( SecurityObjects::ActionLink & A);
bool DeleteAction(std::string &ActionId); bool DeleteAction(std::string &ActionId);
bool CompleteAction(std::string &ActionId); bool CompleteAction(std::string &ActionId);

View File

@@ -27,7 +27,7 @@ namespace OpenWifi {
DB(T, Name.c_str(), AvatarDB_Fields,{}, P, L, ShortName.c_str()) { DB(T, Name.c_str(), AvatarDB_Fields,{}, P, L, ShortName.c_str()) {
} }
bool AvatarDB::SetAvatar(const std::string &Admin, std::string &Id, const std::string & AvatarContent, bool AvatarDB::SetAvatar([[maybe_unused]] const std::string &Admin, std::string &Id, const std::string & AvatarContent,
std::string &Type, std::string &Name) { std::string &Type, std::string &Name) {
try { try {
@@ -50,7 +50,7 @@ namespace OpenWifi {
return false; return false;
} }
bool AvatarDB::GetAvatar(const std::string &Admin, std::string &Id, std::string & AvatarContent, bool AvatarDB::GetAvatar([[maybe_unused]] const std::string &Admin, std::string &Id, std::string & AvatarContent,
std::string &Type, std::string &Name) { std::string &Type, std::string &Name) {
SecurityObjects::Avatar A; SecurityObjects::Avatar A;
try { try {
@@ -74,7 +74,7 @@ namespace OpenWifi {
return false; return false;
} }
bool AvatarDB::DeleteAvatar(const std::string &Admin, std::string &Id) { bool AvatarDB::DeleteAvatar([[maybe_unused]] const std::string &Admin, std::string &Id) {
return DeleteRecord("id",Id); return DeleteRecord("id",Id);
} }

View File

@@ -29,6 +29,7 @@ namespace OpenWifi {
class AvatarDB : public ORM::DB<AvatarRecordTuple, SecurityObjects::Avatar> { class AvatarDB : public ORM::DB<AvatarRecordTuple, SecurityObjects::Avatar> {
public: public:
AvatarDB( const std::string &name, const std::string &shortname, OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); AvatarDB( const std::string &name, const std::string &shortname, OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~AvatarDB() {}
bool SetAvatar(const std::string & Admin, std::string &Id, const std::string & AvatarContent, std::string &Type, std::string & Name); bool SetAvatar(const std::string & Admin, std::string &Id, const std::string & AvatarContent, std::string &Type, std::string & Name);
bool GetAvatar(const std::string & Admin, std::string &Id, std::string & AvatarContent, std::string &Type, std::string & Name); bool GetAvatar(const std::string & Admin, std::string &Id, std::string & AvatarContent, std::string &Type, std::string & Name);

View File

@@ -21,6 +21,7 @@ namespace OpenWifi {
class LoginDB : public ORM::DB<LoginInfoRecordTuple, SecurityObjects::LoginRecordInfo> { class LoginDB : public ORM::DB<LoginInfoRecordTuple, SecurityObjects::LoginRecordInfo> {
public: public:
LoginDB( const std::string &name, const std::string &shortname, OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); LoginDB( const std::string &name, const std::string &shortname, OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~LoginDB() {}
void AddLogin(const std::string & id, const std::string & email, const std::string &token); void AddLogin(const std::string & id, const std::string & email, const std::string &token);
void AddLogout(const std::string &token); void AddLogout(const std::string &token);

View File

@@ -31,7 +31,7 @@ namespace OpenWifi {
return ReplaceRecord("id", P.id, P); return ReplaceRecord("id", P.id, P);
} }
bool PreferencesDB::DeletePreferences(const std::string &AdminId, std::string &Id) { bool PreferencesDB::DeletePreferences([[maybe_unused]] const std::string &AdminId, std::string &Id) {
return DeleteRecord("id",Id); return DeleteRecord("id",Id);
} }

View File

@@ -23,6 +23,7 @@ namespace OpenWifi {
bool GetPreferences(std::string &Id, SecurityObjects::Preferences &P); bool GetPreferences(std::string &Id, SecurityObjects::Preferences &P);
bool SetPreferences(SecurityObjects::Preferences &P); bool SetPreferences(SecurityObjects::Preferences &P);
bool DeletePreferences(const std::string &AdminId, std::string & Id); bool DeletePreferences(const std::string &AdminId, std::string & Id);
virtual ~PreferencesDB() {}
private: private:
}; };

View File

@@ -48,7 +48,7 @@ namespace OpenWifi {
UsersOnly_(Users) { UsersOnly_(Users) {
} }
bool BaseTokenDB::AddToken(std::string &UserID, std::string &Token, std::string &RefreshToken, std::string & TokenType, uint64_t Expires, uint64_t TimeOut) { bool BaseTokenDB::AddToken(std::string &UserID, std::string &Token, std::string &RefreshToken, [[maybe_unused]] std::string & TokenType, uint64_t Expires, uint64_t TimeOut) {
SecurityObjects::Token T{.token=Token, .refreshToken=RefreshToken, .tokenType="Bearer", .userName=UserID, SecurityObjects::Token T{.token=Token, .refreshToken=RefreshToken, .tokenType="Bearer", .userName=UserID,
.created=(uint64_t) std::time(nullptr), .expires=Expires, .idleTimeout=TimeOut,.revocationDate=0}; .created=(uint64_t) std::time(nullptr), .expires=Expires, .idleTimeout=TimeOut,.revocationDate=0};
return CreateRecord(T); return CreateRecord(T);
@@ -99,8 +99,9 @@ namespace OpenWifi {
} }
TokenCache::TokenCache(unsigned Size, unsigned TimeOut, bool Users) : TokenCache::TokenCache(unsigned Size, unsigned TimeOut, bool Users) :
UsersOnly_(Users), ORM::DBCache<SecurityObjects::Token>(Size,TimeOut),
ORM::DBCache<SecurityObjects::Token>(Size,TimeOut) { UsersOnly_(Users)
{
CacheByToken_ = std::make_unique<Poco::ExpireLRUCache<std::string,SecurityObjects::Token>>(Size,TimeOut); CacheByToken_ = std::make_unique<Poco::ExpireLRUCache<std::string,SecurityObjects::Token>>(Size,TimeOut);
} }
@@ -110,7 +111,7 @@ namespace OpenWifi {
CacheByToken_->update(R.token,R); CacheByToken_->update(R.token,R);
} }
void TokenCache::Create(const SecurityObjects::Token &R) { void TokenCache::Create([[maybe_unused]] const SecurityObjects::Token &R) {
} }

View File

@@ -36,6 +36,7 @@ namespace OpenWifi {
public: public:
TokenCache(unsigned Size, unsigned TimeOut, bool Users); TokenCache(unsigned Size, unsigned TimeOut, bool Users);
virtual ~TokenCache() {}
void UpdateCache(const SecurityObjects::Token &R) override; void UpdateCache(const SecurityObjects::Token &R) override;
void Create(const SecurityObjects::Token &R) override; void Create(const SecurityObjects::Token &R) override;
bool GetFromCache(const std::string &FieldName, const std::string &Value, SecurityObjects::Token &R) override; bool GetFromCache(const std::string &FieldName, const std::string &Value, SecurityObjects::Token &R) override;
@@ -43,7 +44,7 @@ namespace OpenWifi {
private: private:
std::mutex Mutex_; std::mutex Mutex_;
bool UsersOnly_; [[maybe_unused]] bool UsersOnly_;
std::unique_ptr<Poco::ExpireLRUCache<std::string,SecurityObjects::Token>> CacheByToken_; std::unique_ptr<Poco::ExpireLRUCache<std::string,SecurityObjects::Token>> CacheByToken_;
}; };
@@ -51,6 +52,7 @@ namespace OpenWifi {
class BaseTokenDB : public ORM::DB<TokenRecordTuple, SecurityObjects::Token> { class BaseTokenDB : public ORM::DB<TokenRecordTuple, SecurityObjects::Token> {
public: public:
BaseTokenDB( const std::string &name, const std::string &shortname, OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L, TokenCache * Cache, bool User); BaseTokenDB( const std::string &name, const std::string &shortname, OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L, TokenCache * Cache, bool User);
virtual ~BaseTokenDB() {}
bool AddToken(std::string &UserId, std::string &Token, std::string &RefreshToken, std::string & TokenType, uint64_t Expires, uint64_t TimeOut); bool AddToken(std::string &UserId, std::string &Token, std::string &RefreshToken, std::string & TokenType, uint64_t Expires, uint64_t TimeOut);
@@ -60,7 +62,7 @@ namespace OpenWifi {
bool RevokeAllTokens( std::string & UserName ); bool RevokeAllTokens( std::string & UserName );
bool GetToken(std::string &Token, SecurityObjects::WebToken &WT, std::string & UserId, uint64_t &RevocationDate); bool GetToken(std::string &Token, SecurityObjects::WebToken &WT, std::string & UserId, uint64_t &RevocationDate);
private: private:
bool UsersOnly_; [[maybe_unused]] bool UsersOnly_;
}; };
} }

View File

@@ -97,7 +97,7 @@ namespace OpenWifi {
UsersOnly_(Users) { UsersOnly_(Users) {
} }
bool BaseUserDB::Upgrade(uint32_t from, uint32_t &to) { bool BaseUserDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
std::vector<std::string> Statements{ std::vector<std::string> Statements{
"alter table " + TableName_ + " add column modified BIGINT;", "alter table " + TableName_ + " add column modified BIGINT;",
"alter table " + TableName_ + " add column signingUp TEXT default '';" "alter table " + TableName_ + " add column signingUp TEXT default '';"
@@ -107,7 +107,7 @@ namespace OpenWifi {
return true; return true;
} }
bool BaseUserDB::CreateUser(const std::string & Admin, SecurityObjects::UserInfo & NewUser, bool PasswordHashedAlready ) { bool BaseUserDB::CreateUser([[maybe_unused]] const std::string & Admin, SecurityObjects::UserInfo & NewUser, bool PasswordHashedAlready ) {
try { try {
Poco::toLowerInPlace(NewUser.email); Poco::toLowerInPlace(NewUser.email);
if(Exists("email", NewUser.email)) { if(Exists("email", NewUser.email)) {
@@ -187,7 +187,7 @@ namespace OpenWifi {
return false; return false;
} }
bool BaseUserDB::UpdateUserInfo(const std::string & Admin, SecurityObjects::USER_ID_TYPE & Id, const SecurityObjects::UserInfo &UInfo) { bool BaseUserDB::UpdateUserInfo([[maybe_unused]] const std::string & Admin, SecurityObjects::USER_ID_TYPE & Id, const SecurityObjects::UserInfo &UInfo) {
try { try {
return UpdateRecord("id", Id, UInfo); return UpdateRecord("id", Id, UInfo);
} catch (const Poco::Exception &E) { } catch (const Poco::Exception &E) {
@@ -196,11 +196,11 @@ namespace OpenWifi {
return false; return false;
} }
bool BaseUserDB::DeleteUser(const std::string & Admin, const SecurityObjects::USER_ID_TYPE & Id) { bool BaseUserDB::DeleteUser([[maybe_unused]] const std::string & Admin, const SecurityObjects::USER_ID_TYPE & Id) {
return DeleteRecord("id", Id); return DeleteRecord("id", Id);
} }
bool BaseUserDB::DeleteUsers(const std::string & Admin, const std::string & owner) { bool BaseUserDB::DeleteUsers([[maybe_unused]] const std::string & Admin, const std::string & owner) {
std::string WhereClause{ " owner='" + owner +"' "}; std::string WhereClause{ " owner='" + owner +"' "};
return DeleteRecords(WhereClause); return DeleteRecords(WhereClause);
} }
@@ -226,8 +226,9 @@ namespace OpenWifi {
} }
UserCache::UserCache(unsigned Size, unsigned TimeOut, bool Users) : UserCache::UserCache(unsigned Size, unsigned TimeOut, bool Users) :
UsersOnly_(Users), ORM::DBCache<SecurityObjects::UserInfo>(Size,TimeOut),
ORM::DBCache<SecurityObjects::UserInfo>(Size,TimeOut) { UsersOnly_(Users)
{
CacheById_ = std::make_unique<Poco::ExpireLRUCache<std::string,SecurityObjects::UserInfo>>(Size,TimeOut); CacheById_ = std::make_unique<Poco::ExpireLRUCache<std::string,SecurityObjects::UserInfo>>(Size,TimeOut);
CacheByEMail_ = std::make_unique<Poco::ExpireLRUCache<std::string,std::string>>(Size,TimeOut); CacheByEMail_ = std::make_unique<Poco::ExpireLRUCache<std::string,std::string>>(Size,TimeOut);
} }
@@ -242,7 +243,7 @@ namespace OpenWifi {
StorageService()->SubTokenDB().DeleteRecordsFromCache("userName", R.id); StorageService()->SubTokenDB().DeleteRecordsFromCache("userName", R.id);
} }
inline void UserCache::Create(const SecurityObjects::UserInfo &R) { inline void UserCache::Create([[maybe_unused]] const SecurityObjects::UserInfo &R) {
} }
inline bool UserCache::GetFromCache(const std::string &FieldName, const std::string &Value, SecurityObjects::UserInfo &R) { inline bool UserCache::GetFromCache(const std::string &FieldName, const std::string &Value, SecurityObjects::UserInfo &R) {

View File

@@ -49,6 +49,7 @@ namespace OpenWifi {
class UserCache : public ORM::DBCache<SecurityObjects::UserInfo> { class UserCache : public ORM::DBCache<SecurityObjects::UserInfo> {
public: public:
UserCache(unsigned Size, unsigned TimeOut, bool Users); UserCache(unsigned Size, unsigned TimeOut, bool Users);
virtual ~UserCache() {}
void UpdateCache(const SecurityObjects::UserInfo &R) override; void UpdateCache(const SecurityObjects::UserInfo &R) override;
void Create(const SecurityObjects::UserInfo &R) override; void Create(const SecurityObjects::UserInfo &R) override;
bool GetFromCache(const std::string &FieldName, const std::string &Value, SecurityObjects::UserInfo &R) override; bool GetFromCache(const std::string &FieldName, const std::string &Value, SecurityObjects::UserInfo &R) override;
@@ -65,6 +66,7 @@ namespace OpenWifi {
public: public:
const uint32_t CurrentVersion = 2; const uint32_t CurrentVersion = 2;
BaseUserDB( const std::string &name, const std::string &shortname, OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L, UserCache * Cache, bool users); BaseUserDB( const std::string &name, const std::string &shortname, OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L, UserCache * Cache, bool users);
virtual ~BaseUserDB() {}
bool CreateUser(const std::string & Admin, SecurityObjects::UserInfo & NewUser, bool PasswordHashedAlready = false ); bool CreateUser(const std::string & Admin, SecurityObjects::UserInfo & NewUser, bool PasswordHashedAlready = false );
bool GetUserByEmail(const std::string & email, SecurityObjects::UserInfo & User); bool GetUserByEmail(const std::string & email, SecurityObjects::UserInfo & User);