mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-10-29 18:02:29 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -10,17 +10,20 @@
|
||||
namespace OpenWifi {
|
||||
|
||||
int ActionLinkManager::Start() {
|
||||
poco_information(Logger(),"Starting...");
|
||||
if(!Running_)
|
||||
Thr_.start(*this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ActionLinkManager::Stop() {
|
||||
poco_information(Logger(),"Stopping...");
|
||||
if(Running_) {
|
||||
Running_ = false;
|
||||
Thr_.wakeUp();
|
||||
Thr_.join();
|
||||
}
|
||||
poco_information(Logger(),"Stopped...");
|
||||
}
|
||||
|
||||
void ActionLinkManager::run() {
|
||||
@@ -63,7 +66,7 @@ namespace OpenWifi {
|
||||
switch(i.action) {
|
||||
case OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD: {
|
||||
if(AuthService::SendEmailToUser(i.id, UInfo.email, MessagingTemplates::FORGOT_PASSWORD)) {
|
||||
Logger().information(fmt::format("Send password reset link to {}",UInfo.email));
|
||||
poco_information(Logger(),fmt::format("Send password reset link to {}",UInfo.email));
|
||||
}
|
||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||
}
|
||||
@@ -71,7 +74,7 @@ namespace OpenWifi {
|
||||
|
||||
case OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL: {
|
||||
if(AuthService::SendEmailToUser(i.id, UInfo.email, MessagingTemplates::EMAIL_VERIFICATION)) {
|
||||
Logger().information(fmt::format("Send email verification link to {}",UInfo.email));
|
||||
poco_information(Logger(),fmt::format("Send email verification link to {}",UInfo.email));
|
||||
}
|
||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||
}
|
||||
@@ -79,7 +82,7 @@ namespace OpenWifi {
|
||||
|
||||
case OpenWifi::SecurityObjects::LinkActions::EMAIL_INVITATION: {
|
||||
if(AuthService::SendEmailToUser(i.id, UInfo.email, MessagingTemplates::EMAIL_INVITATION)) {
|
||||
Logger().information(fmt::format("Send new subscriber email invitation link to {}",UInfo.email));
|
||||
poco_information(Logger(),fmt::format("Send new subscriber email invitation link to {}",UInfo.email));
|
||||
}
|
||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||
}
|
||||
@@ -88,7 +91,7 @@ namespace OpenWifi {
|
||||
case OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD: {
|
||||
auto Signup = Poco::StringTokenizer(UInfo.signingUp,":");
|
||||
if(AuthService::SendEmailToSubUser(i.id, UInfo.email,MessagingTemplates::SUB_FORGOT_PASSWORD, Signup.count()==1 ? "" : Signup[0])) {
|
||||
Logger().information(fmt::format("Send subscriber password reset link to {}",UInfo.email));
|
||||
poco_information(Logger(),fmt::format("Send subscriber password reset link to {}",UInfo.email));
|
||||
}
|
||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||
}
|
||||
@@ -97,7 +100,7 @@ namespace OpenWifi {
|
||||
case OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL: {
|
||||
auto Signup = Poco::StringTokenizer(UInfo.signingUp,":");
|
||||
if(AuthService::SendEmailToSubUser(i.id, UInfo.email, MessagingTemplates::SUB_EMAIL_VERIFICATION, Signup.count()==1 ? "" : Signup[0])) {
|
||||
Logger().information(fmt::format("Send subscriber email verification link to {}",UInfo.email));
|
||||
poco_information(Logger(),fmt::format("Send subscriber email verification link to {}",UInfo.email));
|
||||
}
|
||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||
}
|
||||
@@ -106,7 +109,7 @@ namespace OpenWifi {
|
||||
case OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP: {
|
||||
auto Signup = Poco::StringTokenizer(UInfo.signingUp,":");
|
||||
if(AuthService::SendEmailToSubUser(i.id, UInfo.email, MessagingTemplates::SIGNUP_VERIFICATION, Signup.count()==1 ? "" : Signup[0])) {
|
||||
Logger().information(fmt::format("Send new subscriber email verification link to {}",UInfo.email));
|
||||
poco_information(Logger(),fmt::format("Send new subscriber email verification link to {}",UInfo.email));
|
||||
}
|
||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenWifi {
|
||||
static const std::string DefaultPassword_8_u_l_n_1{"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[\\{\\}\\(\\)~_\\+\\|\\\\\\[\\]\\;\\:\\<\\>\\.\\,\\/\\?\\\"\\'\\`\\=#?!@$%^&*-]).{8,}$"};
|
||||
|
||||
int AuthService::Start() {
|
||||
Logger().notice("Starting...");
|
||||
poco_information(Logger(),"Starting...");
|
||||
TokenAging_ = (uint64_t) MicroService::instance().ConfigGetInt("authentication.token.ageing", 30 * 24 * 60 * 60);
|
||||
RefreshTokenLifeSpan_ = (uint64_t) MicroService::instance().ConfigGetInt("authentication.refresh_token.lifespan", 90 * 24 * 60 * 600);
|
||||
HowManyOldPassword_ = MicroService::instance().ConfigGetInt("authentication.oldpasswords", 5);
|
||||
@@ -65,7 +65,8 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void AuthService::Stop() {
|
||||
Logger().notice("Stopping...");
|
||||
poco_information(Logger(),"Stopping...");
|
||||
poco_information(Logger(),"Stopped...");
|
||||
}
|
||||
|
||||
bool AuthService::RefreshUserToken(Poco::Net::HTTPServerRequest & Request, const std::string & RefreshToken, SecurityObjects::UserInfoAndPolicy & UI) {
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace OpenWifi {
|
||||
|
||||
bool SMSSender::Send(const std::string &PhoneNumber, const std::string &Message) {
|
||||
if(!Enabled_) {
|
||||
Logger().information("SMS has not been enabled. Messages cannot be sent.");
|
||||
poco_information(Logger(),"SMS has not been enabled. Messages cannot be sent.");
|
||||
return false;
|
||||
}
|
||||
return ProviderImpl_->Send(PhoneNumber,Message);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenWifi {
|
||||
Region_ = MicroService::instance().ConfigGetString("smssender.aws.region","");
|
||||
|
||||
if(SecretKey_.empty() || AccessKey_.empty() || Region_.empty()) {
|
||||
Logger().debug("SMSSender is disabled. Please provide key, secret, and region.");
|
||||
poco_debug(Logger(),"SMSSender is disabled. Please provide key, secret, and region.");
|
||||
return false;
|
||||
}
|
||||
Running_=true;
|
||||
@@ -51,16 +51,16 @@ namespace OpenWifi {
|
||||
|
||||
auto psms_out = sns.Publish(psms_req);
|
||||
if (psms_out.IsSuccess()) {
|
||||
Logger().debug(fmt::format("SMS sent to {}",PhoneNumber));
|
||||
poco_debug(Logger(),fmt::format("SMS sent to {}",PhoneNumber));
|
||||
return true;
|
||||
}
|
||||
std::string ErrMsg{psms_out.GetError().GetMessage()};
|
||||
Logger().debug(fmt::format("SMS NOT sent to {}: {}",PhoneNumber, ErrMsg));
|
||||
poco_debug(Logger(),fmt::format("SMS NOT sent to {}: {}",PhoneNumber, ErrMsg));
|
||||
return false;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
Logger().debug(fmt::format("SMS NOT sent to {}: failure in SMS service",PhoneNumber));
|
||||
poco_debug(Logger(),fmt::format("SMS NOT sent to {}: failure in SMS service",PhoneNumber));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenWifi {
|
||||
PhoneNumber_ = MicroService::instance().ConfigGetString("smssender.twilio.phonenumber","");
|
||||
|
||||
if(Sid_.empty() || Token_.empty() || PhoneNumber_.empty()) {
|
||||
Logger().debug("SMSSender is disabled. Please provide SID, TOKEN, and PHONE NUMBER.");
|
||||
poco_debug(Logger(),"SMSSender is disabled. Please provide SID, TOKEN, and PHONE NUMBER.");
|
||||
return false;
|
||||
}
|
||||
Running_=true;
|
||||
@@ -65,12 +65,12 @@ namespace OpenWifi {
|
||||
std::istream& rs = session.receiveResponse(res);
|
||||
|
||||
if(res.getStatus()==Poco::Net::HTTPResponse::HTTP_OK) {
|
||||
Logger().information(fmt::format("Message sent to {}", PhoneNumber));
|
||||
poco_information(Logger(),fmt::format("Message sent to {}", PhoneNumber));
|
||||
return true;
|
||||
} else {
|
||||
std::ostringstream os;
|
||||
Poco::StreamCopier::copyStream(rs,os);
|
||||
Logger().information(fmt::format("Message was not to {}: Error:{}", PhoneNumber, os.str()));
|
||||
poco_information(Logger(),fmt::format("Message was not to {}: Error:{}", PhoneNumber, os.str()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenWifi {
|
||||
|
||||
void SMTPMailerService::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
|
||||
MicroService::instance().LoadConfigurationFile();
|
||||
Logger().information("Reinitializing.");
|
||||
poco_information(Logger(),"Reinitializing.");
|
||||
LoadMyConfig();
|
||||
}
|
||||
|
||||
@@ -88,21 +88,21 @@ namespace OpenWifi {
|
||||
if((i->LastTry==0 || (now-i->LastTry)>MailRetry_)) {
|
||||
switch(SendIt(*i)) {
|
||||
case MessageSendStatus::msg_sent: {
|
||||
Logger().information(fmt::format("Attempting to deliver for mail '{}'.", Recipient));
|
||||
poco_information(Logger(),fmt::format("Attempting to deliver for mail '{}'.", Recipient));
|
||||
i = Messages_.erase(i);
|
||||
} break;
|
||||
case MessageSendStatus::msg_not_sent_but_resend: {
|
||||
Logger().information(fmt::format("Mail for '{}' was not. We will retry later.", Recipient));
|
||||
poco_information(Logger(),fmt::format("Mail for '{}' was not. We will retry later.", Recipient));
|
||||
i->LastTry = now;
|
||||
++i;
|
||||
} break;
|
||||
case MessageSendStatus::msg_not_sent_but_do_not_resend: {
|
||||
Logger().information(fmt::format("Mail for '{}' will not be sent. Check email address", Recipient));
|
||||
poco_information(Logger(),fmt::format("Mail for '{}' will not be sent. Check email address", Recipient));
|
||||
i = Messages_.erase(i);
|
||||
} break;
|
||||
}
|
||||
} else if ((now-i->Posted)>MailAbandon_) {
|
||||
Logger().information(fmt::format("Mail for '{}' has timed out and will not be sent.", Recipient));
|
||||
poco_information(Logger(),fmt::format("Mail for '{}' has timed out and will not be sent.", Recipient));
|
||||
i = Messages_.erase(i);
|
||||
} else {
|
||||
++i;
|
||||
@@ -138,7 +138,7 @@ namespace OpenWifi {
|
||||
Message->addRecipient(Poco::Net::MailRecipient(Poco::Net::MailRecipient::PRIMARY_RECIPIENT, Recipient));
|
||||
Message->setSubject(Msg.Attrs.find(SUBJECT)->second);
|
||||
|
||||
Logger().information(fmt::format("Sending message to:{} from {}",Recipient,TheSender));
|
||||
poco_information(Logger(),fmt::format("Sending message to:{} from {}",Recipient,TheSender));
|
||||
|
||||
if(Msg.Attrs.find(TEXT) != Msg.Attrs.end()) {
|
||||
std::string Content = Msg.Attrs.find(TEXT)->second;
|
||||
@@ -163,7 +163,7 @@ namespace OpenWifi {
|
||||
Poco::StreamCopier::copyStream(IF, OS);
|
||||
Message->addAttachment("logo", new Poco::Net::StringPartSource(OS.str(), "image/png"));
|
||||
} catch (...) {
|
||||
Logger().warning(fmt::format("Cannot add '{}' logo in email",AuthService::GetLogoAssetFileName()));
|
||||
poco_warning(Logger(),fmt::format("Cannot add '{}' logo in email",AuthService::GetLogoAssetFileName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace OpenWifi {
|
||||
return MessageSendStatus::msg_not_sent_but_resend;
|
||||
}
|
||||
catch (const std::exception &E) {
|
||||
Logger().warning(fmt::format("Cannot send message to:{}, error: {}",Recipient, E.what()));
|
||||
poco_warning(Logger(),fmt::format("Cannot send message to:{}, error: {}",Recipient, E.what()));
|
||||
return MessageSendStatus::msg_not_sent_but_do_not_resend;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace OpenWifi {
|
||||
|
||||
int StorageService::Start() {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
poco_information(Logger(),"Starting...");
|
||||
|
||||
StorageClass::Start();
|
||||
|
||||
@@ -57,10 +58,10 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void StorageService::Stop() {
|
||||
Logger().notice("Stopping...");
|
||||
poco_information(Logger(),"Stopping...");
|
||||
Timer_.stop();
|
||||
StorageClass::Stop();
|
||||
Logger().notice("Stopped...");
|
||||
poco_information(Logger(),"Stopped...");
|
||||
}
|
||||
|
||||
void Archiver::onTimer([[maybe_unused]] Poco::Timer &timer) {
|
||||
|
||||
Reference in New Issue
Block a user