mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-01 19:27:59 +00:00
Adding proper security logging.
This commit is contained in:
@@ -25,7 +25,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void AuthClient::RemovedCachedToken(const std::string &Token) {
|
||||
SubMutexGuard G(Mutex_);
|
||||
std::lock_guard G(Mutex_);
|
||||
UserCache_.erase(Token);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
bool AuthClient::IsAuthorized(Poco::Net::HTTPServerRequest & Request, std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo ) {
|
||||
SubMutexGuard G(Mutex_);
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
auto User = UserCache_.find(SessionToken);
|
||||
if(User != UserCache_.end() && !IsTokenExpired(User->second.webtoken)) {
|
||||
@@ -63,7 +63,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
bool AuthClient::IsTokenAuthorized(const std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo) {
|
||||
SubMutexGuard G(Mutex_);
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
auto User = UserCache_.find(SessionToken);
|
||||
if(User != UserCache_.end() && !IsTokenExpired(User->second.webtoken)) {
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenWifi {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
try
|
||||
{
|
||||
SubMutexGuard G(ProducerMutex_);
|
||||
std::lock_guard G(ProducerMutex_);
|
||||
auto Num=0;
|
||||
while (!Queue_.empty()) {
|
||||
const auto M = Queue_.front();
|
||||
@@ -148,7 +148,7 @@ namespace OpenWifi {
|
||||
Consumer.async_commit(Msg);
|
||||
continue;
|
||||
}
|
||||
SubMutexGuard G(ConsumerMutex_);
|
||||
std::lock_guard G(ConsumerMutex_);
|
||||
auto It = Notifiers_.find(Msg.get_topic());
|
||||
if (It != Notifiers_.end()) {
|
||||
Types::TopicNotifyFunctionList &FL = It->second;
|
||||
@@ -176,7 +176,7 @@ namespace OpenWifi {
|
||||
|
||||
void KafkaManager::PostMessage(const std::string &topic, const std::string & key, const std::string &PayLoad, bool WrapMessage ) {
|
||||
if(KafkaEnabled_) {
|
||||
SubMutexGuard G(Mutex_);
|
||||
std::lock_guard G(Mutex_);
|
||||
KMessage M{
|
||||
.Topic = topic,
|
||||
.Key = key,
|
||||
@@ -187,7 +187,7 @@ namespace OpenWifi {
|
||||
|
||||
int KafkaManager::RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F) {
|
||||
if(KafkaEnabled_) {
|
||||
SubMutexGuard G(Mutex_);
|
||||
std::lock_guard G(Mutex_);
|
||||
auto It = Notifiers_.find(Topic);
|
||||
if(It == Notifiers_.end()) {
|
||||
Types::TopicNotifyFunctionList L;
|
||||
@@ -204,7 +204,7 @@ namespace OpenWifi {
|
||||
|
||||
void KafkaManager::UnregisterTopicWatcher(const std::string &Topic, int Id) {
|
||||
if(KafkaEnabled_) {
|
||||
SubMutexGuard G(Mutex_);
|
||||
std::lock_guard G(Mutex_);
|
||||
auto It = Notifiers_.find(Topic);
|
||||
if(It != Notifiers_.end()) {
|
||||
Types::TopicNotifyFunctionList & L = It->second;
|
||||
|
||||
@@ -52,8 +52,8 @@ namespace OpenWifi {
|
||||
|
||||
private:
|
||||
static KafkaManager *instance_;
|
||||
SubMutex ProducerMutex_;
|
||||
SubMutex ConsumerMutex_;
|
||||
std::mutex ProducerMutex_;
|
||||
std::mutex ConsumerMutex_;
|
||||
bool KafkaEnabled_ = false;
|
||||
std::atomic_bool ProducerRunning_ = false;
|
||||
std::atomic_bool ConsumerRunning_ = false;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void MicroService::BusMessageReceived(const std::string &Key, const std::string & Message) {
|
||||
SubMutexGuard G(InfraMutex_);
|
||||
std::lock_guard G(InfraMutex_);
|
||||
try {
|
||||
Poco::JSON::Parser P;
|
||||
auto Object = P.parse(Message).extract<Poco::JSON::Object::Ptr>();
|
||||
@@ -133,7 +133,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
MicroServiceMetaVec MicroService::GetServices(const std::string & Type) {
|
||||
SubMutexGuard G(InfraMutex_);
|
||||
std::lock_guard G(InfraMutex_);
|
||||
|
||||
auto T = Poco::toLower(Type);
|
||||
MicroServiceMetaVec Res;
|
||||
@@ -145,7 +145,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
MicroServiceMetaVec MicroService::GetServices() {
|
||||
SubMutexGuard G(InfraMutex_);
|
||||
std::lock_guard G(InfraMutex_);
|
||||
|
||||
MicroServiceMetaVec Res;
|
||||
for(const auto &[Id,ServiceRec]:Services_) {
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace OpenWifi {
|
||||
std::string UIURI_;
|
||||
std::string Version_{std::string(APP_VERSION) + "("+ BUILD_NUMBER + ")"};
|
||||
BusEventManager BusEventManager_;
|
||||
SubMutex InfraMutex_;
|
||||
std::mutex InfraMutex_;
|
||||
|
||||
std::string DAEMON_PROPERTIES_FILENAME;
|
||||
std::string DAEMON_ROOT_ENV_VAR;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
bool SMTPMailerService::SendMessage(const std::string &Recipient, const std::string &Name, const MessageAttributes &Attrs) {
|
||||
SubMutexGuard G(Mutex_);
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
uint64_t Now = std::time(nullptr);
|
||||
auto CE = Cache_.find(Poco::toLower(Recipient));
|
||||
@@ -72,7 +72,7 @@ namespace OpenWifi {
|
||||
if(!Running_)
|
||||
break;
|
||||
{
|
||||
SubMutexGuard G(Mutex_);
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
uint64_t Now = std::time(nullptr);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
int Storage::Start() {
|
||||
SubMutexGuard Guard(Mutex_);
|
||||
std::lock_guard Guard(Mutex_);
|
||||
|
||||
Logger_.setLevel(Poco::Message::PRIO_NOTICE);
|
||||
Logger_.notice("Starting.");
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
|
||||
#include "Poco/Net/X509Certificate.h"
|
||||
|
||||
using SubMutex = std::recursive_mutex;
|
||||
using SubMutexGuard = std::lock_guard<SubMutex>;
|
||||
|
||||
namespace OpenWifi {
|
||||
class PropertiesFileServerEntry {
|
||||
public:
|
||||
@@ -87,11 +84,11 @@ class SubSystemServer : public Poco::Util::Application::Subsystem {
|
||||
virtual void Stop() = 0;
|
||||
|
||||
protected:
|
||||
SubMutex Mutex_{};
|
||||
Poco::Logger &Logger_;
|
||||
std::string Name_;
|
||||
std::recursive_mutex Mutex_{};
|
||||
Poco::Logger &Logger_;
|
||||
std::string Name_;
|
||||
std::vector<PropertiesFileServerEntry> ConfigServersList_;
|
||||
std::string SubSystemConfigPrefix_;
|
||||
std::string SubSystemConfigPrefix_;
|
||||
};
|
||||
}
|
||||
#endif //UCENTRAL_SUBSYSTEMSERVER_H
|
||||
|
||||
Reference in New Issue
Block a user