mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-01 19:27:59 +00:00
Adding fmt library
This commit is contained in:
@@ -54,6 +54,7 @@ set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
find_package(Boost REQUIRED system)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(AWSSDK REQUIRED COMPONENTS sns)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
find_package(CppKafka REQUIRED)
|
||||
@@ -126,6 +127,7 @@ if(NOT SMALL_BUILD)
|
||||
target_link_libraries(owsec PUBLIC
|
||||
${Poco_LIBRARIES} ${Boost_LIBRARIES} ${MySQL_LIBRARIES} ${ZLIB_LIBRARIES}
|
||||
CppKafka::cppkafka ${AWSSDK_LINK_LIBRARIES}
|
||||
fmt::fmt
|
||||
)
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_libraries(owsec PUBLIC PocoJSON)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenWifi {
|
||||
switch(i.action) {
|
||||
case OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD: {
|
||||
if(AuthService::SendEmailToUser(i.id, UInfo.email, AuthService::FORGOT_PASSWORD)) {
|
||||
Logger().information(Poco::format("Send password reset link to %s",UInfo.email));
|
||||
Logger().information(fmt::format("Send password reset link to {}",UInfo.email));
|
||||
}
|
||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ namespace OpenWifi {
|
||||
|
||||
case OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL: {
|
||||
if(AuthService::SendEmailToUser(i.id, UInfo.email, AuthService::EMAIL_VERIFICATION)) {
|
||||
Logger().information(Poco::format("Send email verification link to %s",UInfo.email));
|
||||
Logger().information(fmt::format("Send email verification link to {}",UInfo.email));
|
||||
}
|
||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ namespace OpenWifi {
|
||||
|
||||
case OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD: {
|
||||
if(AuthService::SendEmailToSubUser(i.id, UInfo.email, AuthService::FORGOT_PASSWORD)) {
|
||||
Logger().information(Poco::format("Send subscriber password reset link to %s",UInfo.email));
|
||||
Logger().information(fmt::format("Send subscriber password reset link to {}",UInfo.email));
|
||||
}
|
||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace OpenWifi {
|
||||
|
||||
case OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL: {
|
||||
if(AuthService::SendEmailToSubUser(i.id, UInfo.email, AuthService::EMAIL_VERIFICATION)) {
|
||||
Logger().information(Poco::format("Send subscriber email verification link to %s",UInfo.email));
|
||||
Logger().information(fmt::format("Send subscriber email verification link to {}",UInfo.email));
|
||||
}
|
||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ namespace OpenWifi {
|
||||
|
||||
case OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP: {
|
||||
if(AuthService::SendEmailToSubUser(i.id, UInfo.email, AuthService::SIGNUP_VERIFICATION)) {
|
||||
Logger().information(Poco::format("Send new subscriber email verification link to %s",UInfo.email));
|
||||
Logger().information(fmt::format("Send new subscriber email verification link to {}",UInfo.email));
|
||||
}
|
||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string AuthService::GenerateTokenHMAC(const std::string & UserName, ACCESS_TYPE Type) {
|
||||
std::string Identity(UserName + ":" + Poco::format("%d",(int)std::time(nullptr)) + ":" + std::to_string(rand()));
|
||||
std::string Identity(UserName + ":" + fmt::format("{}",std::time(nullptr)) + ":" + std::to_string(rand()));
|
||||
HMAC_.update(Identity);
|
||||
return Poco::DigestEngine::digestToHex(HMAC_.digest());
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void RESTAPI_action_links::RequestResetPassword(SecurityObjects::ActionLink &Link) {
|
||||
Logger_.information(Poco::format("REQUEST-PASSWORD-RESET(%s): For ID=%s", Request->clientAddress().toString(), Link.userId));
|
||||
Logger_.information(fmt::format("REQUEST-PASSWORD-RESET({}): For ID={}", Request->clientAddress().toString(), Link.userId));
|
||||
Poco::File FormFile{ Daemon()->AssetDir() + "/password_reset.html"};
|
||||
Types::StringPairVec FormVars{ {"UUID", Link.id},
|
||||
{"PASSWORD_VALIDATION", AuthService()->PasswordValidationExpression()}};
|
||||
@@ -51,7 +51,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void RESTAPI_action_links::DoNewSubVerification(SecurityObjects::ActionLink &Link) {
|
||||
Logger_.information(Poco::format("REQUEST-SUB-SIGNUP(%s): For ID=%s", Request->clientAddress().toString(), Link.userId));
|
||||
Logger_.information(fmt::format("REQUEST-SUB-SIGNUP({}): For ID={}", Request->clientAddress().toString(), Link.userId));
|
||||
Poco::File FormFile{ Daemon()->AssetDir() + "/signup_verification.html"};
|
||||
Types::StringPairVec FormVars{ {"UUID", Link.id},
|
||||
{"PASSWORD_VALIDATION", AuthService()->PasswordValidationExpression()}};
|
||||
@@ -207,7 +207,7 @@ namespace OpenWifi {
|
||||
},
|
||||
Body,30000);
|
||||
|
||||
Logger().information(Poco::format("(%s): Completed subscriber e-mail verification and password.",UInfo.email));
|
||||
Logger().information(fmt::format("({}): Completed subscriber e-mail verification and password.",UInfo.email));
|
||||
Poco::JSON::Object::Ptr Response;
|
||||
ProvRequest.Do(Response);
|
||||
|
||||
@@ -234,7 +234,7 @@ namespace OpenWifi {
|
||||
return SendHTMLFileBack(FormFile, FormVars);
|
||||
}
|
||||
|
||||
Logger_.information(Poco::format("EMAIL-VERIFICATION(%s): For ID=%s", Request->clientAddress().toString(), UInfo.email));
|
||||
Logger_.information(fmt::format("EMAIL-VERIFICATION(%s): For ID={}", Request->clientAddress().toString(), UInfo.email));
|
||||
UInfo.waitingForEmailCheck = false;
|
||||
UInfo.validated = true;
|
||||
UInfo.lastEmailCheck = std::time(nullptr);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenWifi {
|
||||
if (!partHandler.Name().empty() && partHandler.Length()< MicroService::instance().ConfigGetInt("openwifi.avatar.maxsize",2000000)) {
|
||||
Answer.set(RESTAPI::Protocol::AVATARID, Id);
|
||||
Answer.set(RESTAPI::Protocol::ERRORCODE, 0);
|
||||
Logger_.information(Poco::format("Uploaded avatar: %s Type: %s", partHandler.Name(), partHandler.ContentType()));
|
||||
Logger_.information(fmt::format("Uploaded avatar: {} Type: {}", partHandler.Name(), partHandler.ContentType()));
|
||||
StorageService()->AvatarDB().SetAvatar(UserInfo_.userinfo.email,
|
||||
Id, SS.str(), partHandler.ContentType(), partHandler.Name());
|
||||
StorageService()->UserDB().SetAvatar(Id,"1");
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenWifi {
|
||||
}
|
||||
bool GetMe = GetBoolParameter(RESTAPI::Protocol::ME, false);
|
||||
if(GetMe) {
|
||||
Logger_.information(Poco::format("REQUEST-ME(%s): Request for %s", Request->clientAddress().toString(), UserInfo_.userinfo.email));
|
||||
Logger_.information(fmt::format("REQUEST-ME({}): Request for {}", Request->clientAddress().toString(), UserInfo_.userinfo.email));
|
||||
Poco::JSON::Object Me;
|
||||
SecurityObjects::UserInfo ReturnedUser = UserInfo_.userinfo;
|
||||
Sanitize(UserInfo_, ReturnedUser);
|
||||
@@ -51,7 +51,7 @@ namespace OpenWifi {
|
||||
return ReturnStatus(Poco::Net::HTTPResponse::HTTP_NO_CONTENT, true);
|
||||
}
|
||||
|
||||
Logger_.information(Poco::format("BAD-LOGOUT(%s): Request for %s", Request->clientAddress().toString(), UserInfo_.userinfo.email));
|
||||
Logger_.information(fmt::format("BAD-LOGOUT({}): Request for {}", Request->clientAddress().toString(), UserInfo_.userinfo.email));
|
||||
NotFound();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenWifi {
|
||||
Poco::toLowerInPlace(userId);
|
||||
|
||||
if(GetBoolParameter(RESTAPI::Protocol::REQUIREMENTS, false)) {
|
||||
Logger_.information(Poco::format("POLICY-REQUEST(%s): Request.", Request->clientAddress().toString()));
|
||||
Logger_.information(fmt::format("POLICY-REQUEST({}): Request.", Request->clientAddress().toString()));
|
||||
Poco::JSON::Object Answer;
|
||||
Answer.set(RESTAPI::Protocol::PASSWORDPATTERN, AuthService()->PasswordValidationExpression());
|
||||
Answer.set(RESTAPI::Protocol::ACCESSPOLICY, AuthService()->GetAccessPolicy());
|
||||
@@ -76,7 +76,7 @@ namespace OpenWifi {
|
||||
SecurityObjects::UserInfo UInfo1;
|
||||
auto UserExists = StorageService()->UserDB().GetUserByEmail(userId,UInfo1);
|
||||
if(UserExists) {
|
||||
Logger_.information(Poco::format("FORGOTTEN-PASSWORD(%s): Request for %s", Request->clientAddress().toString(), userId));
|
||||
Logger_.information(fmt::format("FORGOTTEN-PASSWORD({}): Request for {}", Request->clientAddress().toString(), userId));
|
||||
SecurityObjects::ActionLink NewLink;
|
||||
|
||||
NewLink.action = OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD;
|
||||
@@ -102,7 +102,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
if(GetBoolParameter(RESTAPI::Protocol::RESENDMFACODE,false)) {
|
||||
Logger_.information(Poco::format("RESEND-MFA-CODE(%s): Request for %s", Request->clientAddress().toString(), userId));
|
||||
Logger_.information(fmt::format("RESEND-MFA-CODE({}): Request for {}", Request->clientAddress().toString(), userId));
|
||||
if(Obj->has("uuid")) {
|
||||
auto uuid = Obj->get("uuid").toString();
|
||||
if(MFAServer()->ResendCode(uuid))
|
||||
@@ -112,7 +112,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
if(GetBoolParameter(RESTAPI::Protocol::COMPLETEMFACHALLENGE,false)) {
|
||||
Logger_.information(Poco::format("COMPLETE-MFA-CHALLENGE(%s): Request for %s", Request->clientAddress().toString(), userId));
|
||||
Logger_.information(fmt::format("COMPLETE-MFA-CHALLENGE({}): Request for {}", Request->clientAddress().toString(), userId));
|
||||
if(Obj->has("uuid")) {
|
||||
SecurityObjects::UserInfoAndPolicy UInfo;
|
||||
if(MFAServer()->CompleteMFAChallenge(Obj,UInfo)) {
|
||||
|
||||
@@ -10,19 +10,16 @@
|
||||
namespace OpenWifi {
|
||||
|
||||
void RESTAPI_signup_handler::DoPost() {
|
||||
__DBG__
|
||||
auto UserName = GetParameter("email","");
|
||||
auto signupUUID = GetParameter("signupUUID","");
|
||||
if(UserName.empty() || signupUUID.empty()) {
|
||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||
}
|
||||
|
||||
__DBG__
|
||||
if(!Utils::ValidEMailAddress(UserName)) {
|
||||
return BadRequest(RESTAPI::Errors::InvalidEmailAddress);
|
||||
}
|
||||
|
||||
__DBG__
|
||||
// Do we already exist? Can only signup once...
|
||||
SecurityObjects::UserInfo Existing;
|
||||
if(StorageService()->SubDB().GetUserByEmail(UserName,Existing)) {
|
||||
@@ -36,7 +33,6 @@ namespace OpenWifi {
|
||||
|
||||
return BadRequest(3, "Waiting for device:" + Existing.signingUp);
|
||||
}
|
||||
__DBG__
|
||||
|
||||
SecurityObjects::UserInfo NewSub;
|
||||
NewSub.signingUp = signupUUID;
|
||||
@@ -48,14 +44,11 @@ namespace OpenWifi {
|
||||
NewSub.email = UserName;
|
||||
NewSub.userRole = SecurityObjects::SUBSCRIBER;
|
||||
NewSub.changePassword = true;
|
||||
__DBG__
|
||||
|
||||
StorageService()->SubDB().CreateRecord(NewSub);
|
||||
__DBG__
|
||||
|
||||
Logger_.information(Poco::format("SIGNUP-PASSWORD(%s): Request for %s", Request->clientAddress().toString(), UserName));
|
||||
Logger_.information(fmt::format("SIGNUP-PASSWORD({}): Request for {}", Request->clientAddress().toString(), UserName));
|
||||
SecurityObjects::ActionLink NewLink;
|
||||
__DBG__
|
||||
|
||||
NewLink.action = OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP;
|
||||
NewLink.id = MicroService::CreateUUID();
|
||||
@@ -64,11 +57,9 @@ namespace OpenWifi {
|
||||
NewLink.expires = NewLink.created + (1*60*60); // 1 hour
|
||||
NewLink.userAction = false;
|
||||
StorageService()->ActionLinksDB().CreateAction(NewLink);
|
||||
__DBG__
|
||||
|
||||
Poco::JSON::Object Answer;
|
||||
NewSub.to_json(Answer);
|
||||
__DBG__
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenWifi {
|
||||
if (!partHandler.Name().empty() && partHandler.Length()< MicroService::instance().ConfigGetInt("openwifi.avatar.maxsize",2000000)) {
|
||||
Answer.set(RESTAPI::Protocol::AVATARID, Id);
|
||||
Answer.set(RESTAPI::Protocol::ERRORCODE, 0);
|
||||
Logger_.information(Poco::format("Uploaded avatar: %s Type: %s", partHandler.Name(), partHandler.ContentType()));
|
||||
Logger_.information(fmt::format("Uploaded avatar: {} Type: {}", partHandler.Name(), partHandler.ContentType()));
|
||||
StorageService()->SubAvatarDB().SetAvatar(UserInfo_.userinfo.email,
|
||||
Id, SS.str(), partHandler.ContentType(), partHandler.Name());
|
||||
StorageService()->SubDB().SetAvatar(Id,"1");
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenWifi {
|
||||
}
|
||||
bool GetMe = GetBoolParameter(RESTAPI::Protocol::ME, false);
|
||||
if(GetMe) {
|
||||
Logger_.information(Poco::format("REQUEST-ME(%s): Request for %s", Request->clientAddress().toString(),
|
||||
Logger_.information(fmt::format("REQUEST-ME({}): Request for {}", Request->clientAddress().toString(),
|
||||
UserInfo_.userinfo.email));
|
||||
Poco::JSON::Object Me;
|
||||
SecurityObjects::UserInfo ReturnedUser = UserInfo_.userinfo;
|
||||
@@ -45,7 +45,7 @@ namespace OpenWifi {
|
||||
return ReturnStatus(Poco::Net::HTTPResponse::HTTP_NO_CONTENT, true);
|
||||
}
|
||||
|
||||
Logger_.information(Poco::format("BAD-LOGOUT(%s): Request for %s", Request->clientAddress().toString(), UserInfo_.userinfo.email));
|
||||
Logger_.information(fmt::format("BAD-LOGOUT({}): Request for {}", Request->clientAddress().toString(), UserInfo_.userinfo.email));
|
||||
NotFound();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenWifi {
|
||||
Poco::toLowerInPlace(userId);
|
||||
|
||||
if(GetBoolParameter(RESTAPI::Protocol::REQUIREMENTS, false)) {
|
||||
Logger_.information(Poco::format("POLICY-REQUEST(%s): Request.", Request->clientAddress().toString()));
|
||||
Logger_.information(fmt::format("POLICY-REQUEST({}): Request.", Request->clientAddress().toString()));
|
||||
Poco::JSON::Object Answer;
|
||||
Answer.set(RESTAPI::Protocol::PASSWORDPATTERN, AuthService()->SubPasswordValidationExpression());
|
||||
Answer.set(RESTAPI::Protocol::ACCESSPOLICY, AuthService()->GetSubAccessPolicy());
|
||||
@@ -70,7 +70,7 @@ namespace OpenWifi {
|
||||
SecurityObjects::UserInfo UInfo1;
|
||||
auto UserExists = StorageService()->SubDB().GetUserByEmail(userId,UInfo1);
|
||||
if(UserExists) {
|
||||
Logger_.information(Poco::format("FORGOTTEN-PASSWORD(%s): Request for %s", Request->clientAddress().toString(), userId));
|
||||
Logger_.information(fmt::format("FORGOTTEN-PASSWORD({}): Request for {}", Request->clientAddress().toString(), userId));
|
||||
SecurityObjects::ActionLink NewLink;
|
||||
|
||||
NewLink.action = OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD;
|
||||
@@ -96,7 +96,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
if(GetBoolParameter(RESTAPI::Protocol::RESENDMFACODE,false)) {
|
||||
Logger_.information(Poco::format("RESEND-MFA-CODE(%s): Request for %s", Request->clientAddress().toString(), userId));
|
||||
Logger_.information(fmt::format("RESEND-MFA-CODE({}): Request for {}", Request->clientAddress().toString(), userId));
|
||||
if(Obj->has("uuid")) {
|
||||
auto uuid = Obj->get("uuid").toString();
|
||||
if(MFAServer()->ResendCode(uuid))
|
||||
@@ -106,7 +106,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
if(GetBoolParameter(RESTAPI::Protocol::COMPLETEMFACHALLENGE,false)) {
|
||||
Logger_.information(Poco::format("COMPLETE-MFA-CHALLENGE(%s): Request for %s", Request->clientAddress().toString(), userId));
|
||||
Logger_.information(fmt::format("COMPLETE-MFA-CHALLENGE({}): Request for {}", Request->clientAddress().toString(), userId));
|
||||
if(Obj->has("uuid") && Obj->has("answer")) {
|
||||
SecurityObjects::UserInfoAndPolicy UInfo;
|
||||
if(MFAServer()->CompleteMFAChallenge(Obj,UInfo)) {
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenWifi {
|
||||
StorageService()->SubTokenDB().RevokeAllTokens(TargetUser.email);
|
||||
StorageService()->SubPreferencesDB().DeleteRecord("id", Id);
|
||||
StorageService()->SubAvatarDB().DeleteRecord("id", Id);
|
||||
Logger_.information(Poco::format("User '%s' deleted by '%s'.",Id,UserInfo_.userinfo.email));
|
||||
Logger_.information(fmt::format("User '{}' deleted by '{}'.",Id,UserInfo_.userinfo.email));
|
||||
OK();
|
||||
}
|
||||
|
||||
@@ -111,18 +111,18 @@ namespace OpenWifi {
|
||||
NewUser.userTypeProprietaryInfo.authenticatorSecret.clear();
|
||||
|
||||
if(!StorageService()->SubDB().CreateUser(NewUser.email, NewUser)) {
|
||||
Logger_.information(Poco::format("Could not add user '%s'.",NewUser.email));
|
||||
Logger_.information(fmt::format("Could not add user '{}'.",NewUser.email));
|
||||
return BadRequest(RESTAPI::Errors::RecordNotCreated);
|
||||
}
|
||||
|
||||
if(GetParameter("email_verification","false")=="true") {
|
||||
if(AuthService::VerifySubEmail(NewUser))
|
||||
Logger_.information(Poco::format("Verification e-mail requested for %s",NewUser.email));
|
||||
Logger_.information(fmt::format("Verification e-mail requested for {}",NewUser.email));
|
||||
StorageService()->SubDB().UpdateUserInfo(UserInfo_.userinfo.email,NewUser.id,NewUser);
|
||||
}
|
||||
|
||||
if(!StorageService()->SubDB().GetUserByEmail(NewUser.email, NewUser)) {
|
||||
Logger_.information(Poco::format("User '%s' but not retrieved.",NewUser.email));
|
||||
Logger_.information(fmt::format("User '{}' but not retrieved.",NewUser.email));
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace OpenWifi {
|
||||
Sanitize(UserInfo_, NewUser);
|
||||
NewUser.to_json(UserInfoObject);
|
||||
ReturnObject(UserInfoObject);
|
||||
Logger_.information(Poco::format("User '%s' has been added by '%s')",NewUser.email, UserInfo_.userinfo.email));
|
||||
Logger_.information(fmt::format("User '{}' has been added by '{}')",NewUser.email, UserInfo_.userinfo.email));
|
||||
}
|
||||
|
||||
void RESTAPI_subuser_handler::DoPut() {
|
||||
@@ -203,7 +203,7 @@ namespace OpenWifi {
|
||||
|
||||
if(GetParameter("email_verification","false")=="true") {
|
||||
if(AuthService::VerifySubEmail(Existing))
|
||||
Logger_.information(Poco::format("Verification e-mail requested for %s",Existing.email));
|
||||
Logger_.information(fmt::format("Verification e-mail requested for {}",Existing.email));
|
||||
}
|
||||
|
||||
if(RawObject->has("userTypeProprietaryInfo")) {
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenWifi {
|
||||
StorageService()->AvatarDB().DeleteAvatar(UserInfo_.userinfo.email,Id);
|
||||
StorageService()->PreferencesDB().DeletePreferences(UserInfo_.userinfo.email,Id);
|
||||
StorageService()->UserTokenDB().RevokeAllTokens(Id);
|
||||
Logger_.information(Poco::format("User '%s' deleted by '%s'.",Id,UserInfo_.userinfo.email));
|
||||
Logger_.information(fmt::format("User '{}' deleted by '{}'.",Id,UserInfo_.userinfo.email));
|
||||
OK();
|
||||
}
|
||||
|
||||
@@ -116,18 +116,18 @@ namespace OpenWifi {
|
||||
NewUser.userTypeProprietaryInfo.authenticatorSecret.clear();
|
||||
|
||||
if(!StorageService()->UserDB().CreateUser(NewUser.email,NewUser)) {
|
||||
Logger_.information(Poco::format("Could not add user '%s'.",NewUser.email));
|
||||
Logger_.information(fmt::format("Could not add user '{}'.",NewUser.email));
|
||||
return BadRequest(RESTAPI::Errors::RecordNotCreated);
|
||||
}
|
||||
|
||||
if(GetParameter("email_verification","false")=="true") {
|
||||
if(AuthService::VerifyEmail(NewUser))
|
||||
Logger_.information(Poco::format("Verification e-mail requested for %s",NewUser.email));
|
||||
Logger_.information(fmt::format("Verification e-mail requested for {}",NewUser.email));
|
||||
StorageService()->UserDB().UpdateUserInfo(UserInfo_.userinfo.email,NewUser.id,NewUser);
|
||||
}
|
||||
|
||||
if(!StorageService()->UserDB().GetUserByEmail(NewUser.email, NewUser)) {
|
||||
Logger_.information(Poco::format("User '%s' but not retrieved.",NewUser.email));
|
||||
Logger_.information(fmt::format("User '{}' but not retrieved.",NewUser.email));
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace OpenWifi {
|
||||
Sanitize(UserInfo_, NewUser);
|
||||
NewUser.to_json(UserInfoObject);
|
||||
ReturnObject(UserInfoObject);
|
||||
Logger_.information(Poco::format("User '%s' has been added by '%s')",NewUser.email, UserInfo_.userinfo.email));
|
||||
Logger_.information(fmt::format("User '{}' has been added by '{}')",NewUser.email, UserInfo_.userinfo.email));
|
||||
}
|
||||
|
||||
void RESTAPI_user_handler::DoPut() {
|
||||
@@ -211,7 +211,7 @@ namespace OpenWifi {
|
||||
|
||||
if(GetParameter("email_verification","false")=="true") {
|
||||
if(AuthService::VerifyEmail(Existing))
|
||||
Logger_.information(Poco::format("Verification e-mail requested for %s",Existing.email));
|
||||
Logger_.information(fmt::format("Verification e-mail requested for {}",Existing.email));
|
||||
}
|
||||
|
||||
if(RawObject->has("userTypeProprietaryInfo")) {
|
||||
|
||||
@@ -51,16 +51,16 @@ namespace OpenWifi {
|
||||
|
||||
auto psms_out = sns.Publish(psms_req);
|
||||
if (psms_out.IsSuccess()) {
|
||||
Logger().debug(Poco::format("SMS sent to %s",PhoneNumber));
|
||||
Logger().debug(fmt::format("SMS sent to {}",PhoneNumber));
|
||||
return true;
|
||||
}
|
||||
std::string ErrMsg{psms_out.GetError().GetMessage()};
|
||||
Logger().debug(Poco::format("SMS NOT sent to %s: %s",PhoneNumber, ErrMsg));
|
||||
Logger().debug(fmt::format("SMS NOT sent to {}: {}",PhoneNumber, ErrMsg));
|
||||
return false;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
Logger().debug(Poco::format("SMS NOT sent to %s: failure in SMS service",PhoneNumber));
|
||||
Logger().debug(fmt::format("SMS NOT sent to {}: failure in SMS service",PhoneNumber));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,12 +64,12 @@ namespace OpenWifi {
|
||||
std::istream& rs = session.receiveResponse(res);
|
||||
|
||||
if(res.getStatus()==Poco::Net::HTTPResponse::HTTP_OK) {
|
||||
Logger().information(Poco::format("Message sent to %s", PhoneNumber));
|
||||
Logger().information(fmt::format("Message sent to {}", PhoneNumber));
|
||||
return true;
|
||||
} else {
|
||||
std::ostringstream os;
|
||||
Poco::StreamCopier::copyStream(rs,os);
|
||||
Logger().information(Poco::format("Message was not to %s: Error:%s", PhoneNumber, os.str()));
|
||||
Logger().information(fmt::format("Message was not to {}: Error:{}", PhoneNumber, os.str()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,14 +84,14 @@ namespace OpenWifi {
|
||||
uint64_t now = OpenWifi::Now();
|
||||
if((i->LastTry==0 || (now-i->LastTry)>MailRetry_)) {
|
||||
if (SendIt(*i)) {
|
||||
Logger().information(Poco::format("Attempting to deliver for mail '%s'.", Recipient));
|
||||
Logger().information(fmt::format("Attempting to deliver for mail '{}'.", Recipient));
|
||||
i = Messages_.erase(i);
|
||||
} else {
|
||||
i->LastTry = now;
|
||||
++i;
|
||||
}
|
||||
} else if ((now-i->Posted)>MailAbandon_) {
|
||||
Logger().information(Poco::format("Mail for '%s' has timed out and will not be sent.", Recipient));
|
||||
Logger().information(fmt::format("Mail for '{}' has timed out and will not be sent.", Recipient));
|
||||
i = Messages_.erase(i);
|
||||
} else {
|
||||
++i;
|
||||
@@ -122,7 +122,7 @@ namespace OpenWifi {
|
||||
TheSender = Sender_ ;
|
||||
}
|
||||
Message.setSender( TheSender );
|
||||
Logger().information(Poco::format("Sending message to:%s from %s",Recipient,TheSender));
|
||||
Logger().information(fmt::format("Sending message to:{} from {}",Recipient,TheSender));
|
||||
Message.addRecipient(Poco::Net::MailRecipient(Poco::Net::MailRecipient::PRIMARY_RECIPIENT, Recipient));
|
||||
Message.setSubject(Msg.Attrs.find(SUBJECT)->second);
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace OpenWifi {
|
||||
Poco::StreamCopier::copyStream(IF, OS);
|
||||
Message.addAttachment("logo", new Poco::Net::StringPartSource(OS.str(), "image/png"));
|
||||
} catch (...) {
|
||||
Logger().warning(Poco::format("Cannot add '%s' logo in email",AuthService::GetLogoAssetFileName()));
|
||||
Logger().warning(fmt::format("Cannot add '{}' logo in email",AuthService::GetLogoAssetFileName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace OpenWifi {
|
||||
Logger().log(E);
|
||||
}
|
||||
catch (const std::exception &E) {
|
||||
Logger().warning(Poco::format("Cannot send message to:%s, error: %s",Recipient, E.what()));
|
||||
Logger().warning(fmt::format("Cannot send message to:{}, error: {}",Recipient, E.what()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ using namespace std::chrono_literals;
|
||||
|
||||
#include "ow_version.h"
|
||||
|
||||
#include "fmt/core.h"
|
||||
|
||||
#define _OWDEBUG_ std::cout<< __FILE__ <<":" << __LINE__ << std::endl;
|
||||
// #define _OWDEBUG_ Logger().debug(Poco::format("%s: %lu",__FILE__,__LINE__));
|
||||
namespace OpenWifi {
|
||||
@@ -1221,17 +1223,17 @@ namespace OpenWifi {
|
||||
inline void exception(const Poco::Exception & E) {
|
||||
Poco::Thread * CurrentThread = Poco::Thread::current();
|
||||
App_.logger().log(E);
|
||||
App_.logger().error(Poco::format("Exception occurred in %s",CurrentThread->getName()));
|
||||
App_.logger().error(fmt::format("Exception occurred in {}",CurrentThread->getName()));
|
||||
}
|
||||
|
||||
inline void exception(const std::exception & E) {
|
||||
Poco::Thread * CurrentThread = Poco::Thread::current();
|
||||
App_.logger().warning(Poco::format("std::exception on %s",CurrentThread->getName()));
|
||||
App_.logger().warning(fmt::format("std::exception in {}}",CurrentThread->getName()));
|
||||
}
|
||||
|
||||
inline void exception() {
|
||||
Poco::Thread * CurrentThread = Poco::Thread::current();
|
||||
App_.logger().warning(Poco::format("exception on %s",CurrentThread->getName()));
|
||||
App_.logger().warning(fmt::format("exception in {}",CurrentThread->getName()));
|
||||
}
|
||||
private:
|
||||
Poco::Util::Application &App_;
|
||||
@@ -1330,7 +1332,7 @@ namespace OpenWifi {
|
||||
|
||||
SSL_CTX *SSLCtx = Context->sslContext();
|
||||
if (!SSL_CTX_check_private_key(SSLCtx)) {
|
||||
L.fatal(Poco::format("Wrong Certificate(%s) for Key(%s)", cert_file_, key_file_));
|
||||
L.fatal(fmt::format("Wrong Certificate({}) for Key({})", cert_file_, key_file_));
|
||||
}
|
||||
|
||||
SSL_CTX_set_verify(SSLCtx, SSL_VERIFY_PEER, nullptr);
|
||||
@@ -1381,58 +1383,58 @@ namespace OpenWifi {
|
||||
|
||||
inline void LogCertInfo(Poco::Logger &L, const Poco::Crypto::X509Certificate &C) const {
|
||||
L.information("=============================================================================================");
|
||||
L.information(Poco::format("> Issuer: %s", C.issuerName()));
|
||||
L.information(fmt::format("> Issuer: {}", C.issuerName()));
|
||||
L.information("---------------------------------------------------------------------------------------------");
|
||||
L.information(Poco::format("> Common Name: %s",
|
||||
L.information(fmt::format("> Common Name: {}",
|
||||
C.issuerName(Poco::Crypto::X509Certificate::NID_COMMON_NAME)));
|
||||
L.information(Poco::format("> Country: %s",
|
||||
L.information(fmt::format("> Country: {}",
|
||||
C.issuerName(Poco::Crypto::X509Certificate::NID_COUNTRY)));
|
||||
L.information(Poco::format("> Locality: %s",
|
||||
L.information(fmt::format("> Locality: {}",
|
||||
C.issuerName(Poco::Crypto::X509Certificate::NID_LOCALITY_NAME)));
|
||||
L.information(Poco::format("> State/Prov: %s",
|
||||
L.information(fmt::format("> State/Prov: {}",
|
||||
C.issuerName(Poco::Crypto::X509Certificate::NID_STATE_OR_PROVINCE)));
|
||||
L.information(Poco::format("> Org name: %s",
|
||||
L.information(fmt::format("> Org name: {}",
|
||||
C.issuerName(Poco::Crypto::X509Certificate::NID_ORGANIZATION_NAME)));
|
||||
L.information(
|
||||
Poco::format("> Org unit: %s",
|
||||
fmt::format("> Org unit: {}",
|
||||
C.issuerName(Poco::Crypto::X509Certificate::NID_ORGANIZATION_UNIT_NAME)));
|
||||
L.information(
|
||||
Poco::format("> Email: %s",
|
||||
fmt::format("> Email: {}",
|
||||
C.issuerName(Poco::Crypto::X509Certificate::NID_PKCS9_EMAIL_ADDRESS)));
|
||||
L.information(Poco::format("> Serial#: %s",
|
||||
L.information(fmt::format("> Serial#: {}",
|
||||
C.issuerName(Poco::Crypto::X509Certificate::NID_SERIAL_NUMBER)));
|
||||
L.information("---------------------------------------------------------------------------------------------");
|
||||
L.information(Poco::format("> Subject: %s", C.subjectName()));
|
||||
L.information(fmt::format("> Subject: {}", C.subjectName()));
|
||||
L.information("---------------------------------------------------------------------------------------------");
|
||||
L.information(Poco::format("> Common Name: %s",
|
||||
L.information(fmt::format("> Common Name: {}",
|
||||
C.subjectName(Poco::Crypto::X509Certificate::NID_COMMON_NAME)));
|
||||
L.information(Poco::format("> Country: %s",
|
||||
L.information(fmt::format("> Country: {}",
|
||||
C.subjectName(Poco::Crypto::X509Certificate::NID_COUNTRY)));
|
||||
L.information(Poco::format("> Locality: %s",
|
||||
L.information(fmt::format("> Locality: {}",
|
||||
C.subjectName(Poco::Crypto::X509Certificate::NID_LOCALITY_NAME)));
|
||||
L.information(
|
||||
Poco::format("> State/Prov: %s",
|
||||
fmt::format("> State/Prov: {}",
|
||||
C.subjectName(Poco::Crypto::X509Certificate::NID_STATE_OR_PROVINCE)));
|
||||
L.information(
|
||||
Poco::format("> Org name: %s",
|
||||
fmt::format("> Org name: {}",
|
||||
C.subjectName(Poco::Crypto::X509Certificate::NID_ORGANIZATION_NAME)));
|
||||
L.information(
|
||||
Poco::format("> Org unit: %s",
|
||||
fmt::format("> Org unit: {}",
|
||||
C.subjectName(Poco::Crypto::X509Certificate::NID_ORGANIZATION_UNIT_NAME)));
|
||||
L.information(
|
||||
Poco::format("> Email: %s",
|
||||
fmt::format("> Email: {}",
|
||||
C.subjectName(Poco::Crypto::X509Certificate::NID_PKCS9_EMAIL_ADDRESS)));
|
||||
L.information(Poco::format("> Serial#: %s",
|
||||
L.information(fmt::format("> Serial#: {}",
|
||||
C.subjectName(Poco::Crypto::X509Certificate::NID_SERIAL_NUMBER)));
|
||||
L.information("---------------------------------------------------------------------------------------------");
|
||||
L.information(Poco::format("> Signature Algo: %s", C.signatureAlgorithm()));
|
||||
L.information(fmt::format("> Signature Algo: {}", C.signatureAlgorithm()));
|
||||
auto From = Poco::DateTimeFormatter::format(C.validFrom(), Poco::DateTimeFormat::HTTP_FORMAT);
|
||||
L.information(Poco::format("> Valid from: %s", From));
|
||||
L.information(fmt::format("> Valid from: {}", From));
|
||||
auto Expires =
|
||||
Poco::DateTimeFormatter::format(C.expiresOn(), Poco::DateTimeFormat::HTTP_FORMAT);
|
||||
L.information(Poco::format("> Expires on: %s", Expires));
|
||||
L.information(Poco::format("> Version: %d", (int)C.version()));
|
||||
L.information(Poco::format("> Serial #: %s", C.serialNumber()));
|
||||
L.information(fmt::format("> Expires on: {}", Expires));
|
||||
L.information(fmt::format("> Version: {}", (int)C.version()));
|
||||
L.information(fmt::format("> Serial #: {}", C.serialNumber()));
|
||||
L.information("=============================================================================================");
|
||||
}
|
||||
|
||||
@@ -1441,7 +1443,7 @@ namespace OpenWifi {
|
||||
Poco::Crypto::X509Certificate C(cert_file_);
|
||||
L.information("=============================================================================================");
|
||||
L.information("=============================================================================================");
|
||||
L.information(Poco::format("Certificate Filename: %s", cert_file_));
|
||||
L.information(fmt::format("Certificate Filename: {}", cert_file_));
|
||||
LogCertInfo(L, C);
|
||||
L.information("=============================================================================================");
|
||||
|
||||
@@ -1449,7 +1451,7 @@ namespace OpenWifi {
|
||||
Poco::Crypto::X509Certificate C1(issuer_cert_file_);
|
||||
L.information("=============================================================================================");
|
||||
L.information("=============================================================================================");
|
||||
L.information(Poco::format("Issues Certificate Filename: %s", issuer_cert_file_));
|
||||
L.information(fmt::format("Issues Certificate Filename: {}", issuer_cert_file_));
|
||||
LogCertInfo(L, C1);
|
||||
L.information("=============================================================================================");
|
||||
}
|
||||
@@ -1460,11 +1462,11 @@ namespace OpenWifi {
|
||||
|
||||
L.information("=============================================================================================");
|
||||
L.information("=============================================================================================");
|
||||
L.information(Poco::format("Client CAs Filename: %s", client_cas_));
|
||||
L.information(fmt::format("Client CAs Filename: {}", client_cas_));
|
||||
L.information("=============================================================================================");
|
||||
auto i = 1;
|
||||
for (const auto &C3 : Certs) {
|
||||
L.information(Poco::format(" Index: %d", i));
|
||||
L.information(fmt::format(" Index: {}", i));
|
||||
L.information("=============================================================================================");
|
||||
LogCertInfo(L, C3);
|
||||
i++;
|
||||
@@ -1484,11 +1486,11 @@ namespace OpenWifi {
|
||||
|
||||
L.information("=============================================================================================");
|
||||
L.information("=============================================================================================");
|
||||
L.information(Poco::format("CA Filename: %s", root_ca_));
|
||||
L.information(fmt::format("CA Filename: {}", root_ca_));
|
||||
L.information("=============================================================================================");
|
||||
auto i = 1;
|
||||
for (const auto &C : Certs) {
|
||||
L.information(Poco::format(" Index: %d", i));
|
||||
L.information(fmt::format(" Index: {}", i));
|
||||
L.information("=============================================================================================");
|
||||
LogCertInfo(L, C);
|
||||
i++;
|
||||
@@ -1689,7 +1691,7 @@ namespace OpenWifi {
|
||||
E->Count++;
|
||||
Cache_.update(H,E);
|
||||
if(E->Count > MaxCalls) {
|
||||
Logger().warning(Poco::format("RATE-LIMIT-EXCEEDED: from '%s'", R.clientAddress().toString()));
|
||||
Logger().warning(fmt::format("RATE-LIMIT-EXCEEDED: from '{}'", R.clientAddress().toString()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -2042,7 +2044,7 @@ namespace OpenWifi {
|
||||
ErrorObject.set("ErrorDescription","This resource does not exist.");
|
||||
std::ostream &Answer = Response->send();
|
||||
Poco::JSON::Stringifier::stringify(ErrorObject, Answer);
|
||||
Logger_.debug(Poco::format("RES-NOTFOUND: User='%s@%s' Method='%s' Path='%s",
|
||||
Logger_.debug(fmt::format("RES-NOTFOUND: User='{}@{}}' Method='{}}' Path='{}}",
|
||||
UserInfo_.userinfo.email,
|
||||
Utils::FormatIPv6(Request->clientAddress().toString()),
|
||||
Request->getMethod(),
|
||||
@@ -2640,10 +2642,10 @@ namespace OpenWifi {
|
||||
KafkaDispatcher Dispatcher_;
|
||||
|
||||
inline void PartitionAssignment(const cppkafka::TopicPartitionList& partitions) {
|
||||
Logger().information(Poco::format("Partition assigned: %Lu...",(uint64_t )partitions.front().get_partition()));
|
||||
Logger().information(fmt::format("Partition assigned: {}...", partitions.front().get_partition()));
|
||||
}
|
||||
inline void PartitionRevocation(const cppkafka::TopicPartitionList& partitions) {
|
||||
Logger().information(Poco::format("Partition revocation: %Lu...",(uint64_t )partitions.front().get_partition()));
|
||||
Logger().information(fmt::format("Partition revocation: {}...",partitions.front().get_partition()));
|
||||
}
|
||||
|
||||
KafkaManager() noexcept:
|
||||
@@ -2757,7 +2759,7 @@ namespace OpenWifi {
|
||||
|
||||
void handleRequest(Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) override
|
||||
{
|
||||
Logger_.information(Poco::format("ALB-REQUEST(%s): New ALB request.",Request.clientAddress().toString()));
|
||||
Logger_.information(fmt::format("ALB-REQUEST({}): New ALB request.",Request.clientAddress().toString()));
|
||||
Response.setChunkedTransferEncoding(true);
|
||||
Response.setContentType("text/html");
|
||||
Response.setDate(Poco::Timestamp());
|
||||
@@ -3200,6 +3202,10 @@ namespace OpenWifi {
|
||||
try {
|
||||
Poco::JSON::Parser P;
|
||||
auto Object = P.parse(Payload).extract<Poco::JSON::Object::Ptr>();
|
||||
/* std::ostringstream OOO;
|
||||
Object->stringify(OOO) ;
|
||||
std::cout << "BUS MESSAGE:" << OOO.str() << std::endl;
|
||||
*/
|
||||
if (Object->has(KafkaTopics::ServiceEvents::Fields::ID) &&
|
||||
Object->has(KafkaTopics::ServiceEvents::Fields::EVENT)) {
|
||||
uint64_t ID = Object->get(KafkaTopics::ServiceEvents::Fields::ID);
|
||||
@@ -3213,14 +3219,13 @@ namespace OpenWifi {
|
||||
Object->has(KafkaTopics::ServiceEvents::Fields::PRIVATE) &&
|
||||
Object->has(KafkaTopics::ServiceEvents::Fields::VRSN) &&
|
||||
Object->has(KafkaTopics::ServiceEvents::Fields::KEY)) {
|
||||
|
||||
if (Event == KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE && Services_.find(ID) != Services_.end()) {
|
||||
Services_[ID].LastUpdate = std::time(nullptr);
|
||||
} else if (Event == KafkaTopics::ServiceEvents::EVENT_LEAVE) {
|
||||
Services_.erase(ID);
|
||||
logger().information(Poco::format("Service %s ID=%Lu leaving system.",Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE).toString(),ID));
|
||||
logger().information(fmt::format("Service {} ID={} leaving system.",Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE).toString(),ID));
|
||||
} else if (Event == KafkaTopics::ServiceEvents::EVENT_JOIN || Event == KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE) {
|
||||
logger().information(Poco::format("Service %s ID=%Lu joining system.",Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE).toString(),ID));
|
||||
logger().information(fmt::format("Service {} ID={} joining system.",Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE).toString(),ID));
|
||||
Services_[ID] = MicroServiceMeta{
|
||||
.Id = ID,
|
||||
.Type = Poco::toLower(Object->get(KafkaTopics::ServiceEvents::Fields::TYPE).toString()),
|
||||
@@ -3230,11 +3235,11 @@ namespace OpenWifi {
|
||||
.Version = Object->get(KafkaTopics::ServiceEvents::Fields::VRSN).toString(),
|
||||
.LastUpdate = (uint64_t)std::time(nullptr)};
|
||||
for (const auto &[Id, Svc] : Services_) {
|
||||
logger().information(Poco::format("ID: %Lu Type: %s EndPoint: %s",Id,Svc.Type,Svc.PrivateEndPoint));
|
||||
logger().information(fmt::format("ID: {} Type: {} EndPoint: {}",Id,Svc.Type,Svc.PrivateEndPoint));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger().error(Poco::format("KAFKA-MSG: invalid event '%s', missing a field.",Event));
|
||||
logger().error(fmt::format("KAFKA-MSG: invalid event '{}', missing a field.",Event));
|
||||
}
|
||||
} else if (Event==KafkaTopics::ServiceEvents::EVENT_REMOVE_TOKEN) {
|
||||
if(Object->has(KafkaTopics::ServiceEvents::Fields::TOKEN)) {
|
||||
@@ -3242,10 +3247,10 @@ namespace OpenWifi {
|
||||
AuthClient()->RemovedCachedToken(Object->get(KafkaTopics::ServiceEvents::Fields::TOKEN).toString());
|
||||
#endif
|
||||
} else {
|
||||
logger().error(Poco::format("KAFKA-MSG: invalid event '%s', missing token",Event));
|
||||
logger().error(fmt::format("KAFKA-MSG: invalid event '{}', missing token",Event));
|
||||
}
|
||||
} else {
|
||||
logger().error(Poco::format("Unknown Event: %s Source: %Lu", Event, ID));
|
||||
logger().error(fmt::format("Unknown Event: {} Source: {}", Event, ID));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -3719,9 +3724,9 @@ namespace OpenWifi {
|
||||
for(const auto & Svr: ConfigServersList_) {
|
||||
|
||||
if(MicroService::instance().NoAPISecurity()) {
|
||||
Logger().information(Poco::format("Starting: %s:%s. Security has been disabled for APIs.", Svr.Address(), std::to_string(Svr.Port())));
|
||||
Logger().information(fmt::format("Starting: {}:{}. Security has been disabled for APIs.", Svr.Address(), Svr.Port()));
|
||||
} else {
|
||||
Logger().information(Poco::format("Starting: %s:%s Keyfile:%s CertFile: %s", Svr.Address(), std::to_string(Svr.Port()),
|
||||
Logger().information(fmt::format("Starting: {}:{} Keyfile:{} CertFile: {}", Svr.Address(), Svr.Port(),
|
||||
Svr.KeyFile(),Svr.CertFile()));
|
||||
Svr.LogCert(Logger());
|
||||
if (!Svr.RootCA().empty())
|
||||
@@ -3755,9 +3760,9 @@ namespace OpenWifi {
|
||||
for(const auto & Svr: ConfigServersList_) {
|
||||
|
||||
if(MicroService::instance().NoAPISecurity()) {
|
||||
Logger().information(Poco::format("Starting: %s:%s. Security has been disabled for APIs.", Svr.Address(), std::to_string(Svr.Port())));
|
||||
Logger().information(fmt::format("Starting: {}:{}. Security has been disabled for APIs.", Svr.Address(), Svr.Port()));
|
||||
} else {
|
||||
Logger().information(Poco::format("Starting: %s:%s. Keyfile:%s CertFile: %s", Svr.Address(), std::to_string(Svr.Port()),
|
||||
Logger().information(fmt::format("Starting: {}:{}. Keyfile:{} CertFile: {}", Svr.Address(), Svr.Port(),
|
||||
Svr.KeyFile(),Svr.CertFile()));
|
||||
Svr.LogCert(Logger());
|
||||
if (!Svr.RootCA().empty())
|
||||
@@ -3793,7 +3798,7 @@ namespace OpenWifi {
|
||||
SavePID();
|
||||
|
||||
Poco::Logger &logger = Poco::Logger::get(DAEMON_APP_NAME);
|
||||
logger.notice(Poco::format("Starting %s version %s.",DAEMON_APP_NAME, Version()));
|
||||
logger.notice(fmt::format("Starting {} version {}.",DAEMON_APP_NAME, Version()));
|
||||
|
||||
if(Poco::Net::Socket::supportsIPv6())
|
||||
logger.information("System supports IPv6.");
|
||||
@@ -3804,11 +3809,11 @@ namespace OpenWifi {
|
||||
logger.information("Starting as a daemon.");
|
||||
}
|
||||
|
||||
logger.information(Poco::format("System ID set to %Lu",ID_));
|
||||
logger.information(fmt::format("System ID set to {}",ID_));
|
||||
StartSubSystemServers();
|
||||
waitForTerminationRequest();
|
||||
StopSubSystemServers();
|
||||
logger.notice(Poco::format("Stopped %s...",DAEMON_APP_NAME));
|
||||
logger.notice(fmt::format("Stopped {}...",DAEMON_APP_NAME));
|
||||
}
|
||||
|
||||
return Application::EXIT_OK;
|
||||
@@ -3936,37 +3941,37 @@ namespace OpenWifi {
|
||||
inline void KafkaLoggerFun(cppkafka::KafkaHandleBase & handle, int level, const std::string & facility, const std::string &messqge) {
|
||||
switch ((cppkafka::LogLevel) level) {
|
||||
case cppkafka::LogLevel::LogNotice: {
|
||||
KafkaManager()->Logger().notice(Poco::format("kafka-log: facility: %s message: %s",facility, messqge));
|
||||
KafkaManager()->Logger().notice(fmt::format("kafka-log: facility: {} message: {}",facility, messqge));
|
||||
}
|
||||
break;
|
||||
case cppkafka::LogLevel::LogDebug: {
|
||||
KafkaManager()->Logger().debug(Poco::format("kafka-log: facility: %s message: %s",facility, messqge));
|
||||
KafkaManager()->Logger().debug(fmt::format("kafka-log: facility: {} message: {}",facility, messqge));
|
||||
}
|
||||
break;
|
||||
case cppkafka::LogLevel::LogInfo: {
|
||||
KafkaManager()->Logger().information(Poco::format("kafka-log: facility: %s message: %s",facility, messqge));
|
||||
KafkaManager()->Logger().information(fmt::format("kafka-log: facility: {} message: {}",facility, messqge));
|
||||
}
|
||||
break;
|
||||
case cppkafka::LogLevel::LogWarning: {
|
||||
KafkaManager()->Logger().warning(Poco::format("kafka-log: facility: %s message: %s",facility, messqge));
|
||||
KafkaManager()->Logger().warning(fmt::format("kafka-log: facility: {} message: {}",facility, messqge));
|
||||
}
|
||||
break;
|
||||
case cppkafka::LogLevel::LogAlert:
|
||||
case cppkafka::LogLevel::LogCrit: {
|
||||
KafkaManager()->Logger().critical(Poco::format("kafka-log: facility: %s message: %s",facility, messqge));
|
||||
KafkaManager()->Logger().critical(fmt::format("kafka-log: facility: {} message: {}",facility, messqge));
|
||||
}
|
||||
break;
|
||||
case cppkafka::LogLevel::LogErr:
|
||||
case cppkafka::LogLevel::LogEmerg:
|
||||
default: {
|
||||
KafkaManager()->Logger().error(Poco::format("kafka-log: facility: %s message: %s",facility, messqge));
|
||||
KafkaManager()->Logger().error(fmt::format("kafka-log: facility: {} message: {}",facility, messqge));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline void KafkaErrorFun(cppkafka::KafkaHandleBase & handle, int error, const std::string &reason) {
|
||||
KafkaManager()->Logger().error(Poco::format("kafka-error: %d, reason: %s", error, reason));
|
||||
KafkaManager()->Logger().error(fmt::format("kafka-error: {}, reason: {}", error, reason));
|
||||
}
|
||||
|
||||
inline void AddKafkaSecurity(cppkafka::Configuration & Config) {
|
||||
@@ -4040,14 +4045,14 @@ namespace OpenWifi {
|
||||
cppkafka::Consumer Consumer(Config);
|
||||
Consumer.set_assignment_callback([this](cppkafka::TopicPartitionList& partitions) {
|
||||
if(!partitions.empty()) {
|
||||
KafkaManager()->Logger().information(Poco::format("Partition assigned: %Lu...",
|
||||
(uint64_t)partitions.front().get_partition()));
|
||||
KafkaManager()->Logger().information(fmt::format("Partition assigned: {}...",
|
||||
partitions.front().get_partition()));
|
||||
}
|
||||
});
|
||||
Consumer.set_revocation_callback([this](const cppkafka::TopicPartitionList& partitions) {
|
||||
if(!partitions.empty()) {
|
||||
KafkaManager()->Logger().information(Poco::format("Partition revocation: %Lu...",
|
||||
(uint64_t)partitions.front().get_partition()));
|
||||
KafkaManager()->Logger().information(fmt::format("Partition revocation: {}...",
|
||||
partitions.front().get_partition()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4067,7 +4072,7 @@ namespace OpenWifi {
|
||||
continue;
|
||||
if (Msg.get_error()) {
|
||||
if (!Msg.is_eof()) {
|
||||
KafkaManager()->Logger().error(Poco::format("Error: %s", Msg.get_error().to_string()));
|
||||
KafkaManager()->Logger().error(fmt::format("Error: {}", Msg.get_error().to_string()));
|
||||
}if(!AutoCommit)
|
||||
Consumer.async_commit(Msg);
|
||||
continue;
|
||||
@@ -4077,7 +4082,7 @@ namespace OpenWifi {
|
||||
Consumer.async_commit(Msg);
|
||||
}
|
||||
} catch (const cppkafka::HandleException &E) {
|
||||
KafkaManager()->Logger().warning(Poco::format("Caught a Kafka exception (consumer): %s",std::string{E.what()}));
|
||||
KafkaManager()->Logger().warning(fmt::format("Caught a Kafka exception (consumer): {}", E.what()));
|
||||
} catch (const Poco::Exception &E) {
|
||||
KafkaManager()->Logger().log(E);
|
||||
}
|
||||
@@ -4171,7 +4176,7 @@ namespace OpenWifi {
|
||||
auto Value = GetS(RESTAPI::Protocol::VALUE, InnerObj);
|
||||
MicroService::instance().SetSubsystemLogLevel(Name, Value);
|
||||
Logger_.information(
|
||||
Poco::format("Setting log level for %s at %s", Name, Value));
|
||||
fmt::format("Setting log level for {} at {}", Name, Value));
|
||||
}
|
||||
}
|
||||
return OK();
|
||||
@@ -4446,14 +4451,14 @@ namespace OpenWifi {
|
||||
auto Allowed = MicroService::instance().IsValidAPIKEY(*Request);
|
||||
if(!Allowed) {
|
||||
if(Server_.LogBadTokens(false)) {
|
||||
Logger_.debug(Poco::format("I-REQ-DENIED(%s): Method='%s' Path='%s",
|
||||
Logger_.debug(fmt::format("I-REQ-DENIED({}): Method={} Path={}",
|
||||
Utils::FormatIPv6(Request->clientAddress().toString()),
|
||||
Request->getMethod(), Request->getURI()));
|
||||
}
|
||||
} else {
|
||||
auto Id = Request->get("X-INTERNAL-NAME", "unknown");
|
||||
if(Server_.LogIt(Request->getMethod(),true)) {
|
||||
Logger_.debug(Poco::format("I-REQ-ALLOWED(%s): User='%s' Method='%s' Path='%s",
|
||||
Logger_.debug(fmt::format("I-REQ-ALLOWED({}): User='{}' Method={} Path={}",
|
||||
Utils::FormatIPv6(Request->clientAddress().toString()), Id,
|
||||
Request->getMethod(), Request->getURI()));
|
||||
}
|
||||
@@ -4476,7 +4481,7 @@ namespace OpenWifi {
|
||||
if (AuthClient()->IsAuthorized( SessionToken_, UserInfo_, Expired, Contacted, Sub)) {
|
||||
#endif
|
||||
if(Server_.LogIt(Request->getMethod(),true)) {
|
||||
Logger_.debug(Poco::format("X-REQ-ALLOWED(%s): User='%s@%s' Method='%s' Path='%s'",
|
||||
Logger_.debug(fmt::format("X-REQ-ALLOWED({}): User='{}@{}' Method={} Path={}",
|
||||
UserInfo_.userinfo.email,
|
||||
Utils::FormatIPv6(Request->clientAddress().toString()),
|
||||
Request->clientAddress().toString(),
|
||||
@@ -4486,7 +4491,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
} else {
|
||||
if(Server_.LogBadTokens(true)) {
|
||||
Logger_.debug(Poco::format("X-REQ-DENIED(%s): Method='%s' Path='%s'",
|
||||
Logger_.debug(fmt::format("X-REQ-DENIED({}): Method={} Path={}",
|
||||
Utils::FormatIPv6(Request->clientAddress().toString()),
|
||||
Request->getMethod(), Request->getURI()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user