mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-02 11:47:56 +00:00
Microservice bus cleanup.
This commit is contained in:
@@ -69,7 +69,11 @@ add_executable( ucentralsec
|
||||
src/RESTAPI_action_links.cpp src/RESTAPI_action_links.h src/storage_users.cpp
|
||||
src/RESTAPI_InternalServer.cpp src/RESTAPI_InternalServer.h
|
||||
src/RESTAPI_validateToken_handler.cpp src/RESTAPI_validateToken_handler.h
|
||||
src/RESTAPI_systemEndpoints_handler.cpp src/RESTAPI_systemEndpoints_handler.h src/RESTAPI_AssetServer.cpp src/RESTAPI_AssetServer.h src/RESTAPI_avatarHandler.cpp src/RESTAPI_avatarHandler.h src/storage_avatar.cpp src/storage_avatar.h src/storage_users.h)
|
||||
src/RESTAPI_systemEndpoints_handler.cpp src/RESTAPI_systemEndpoints_handler.h
|
||||
src/RESTAPI_AssetServer.cpp src/RESTAPI_AssetServer.h
|
||||
src/RESTAPI_avatarHandler.cpp src/RESTAPI_avatarHandler.h
|
||||
src/storage_avatar.cpp src/storage_avatar.h src/storage_users.h
|
||||
src/OpenWifiTypes.h )
|
||||
|
||||
if(NOT SMALL_BUILD)
|
||||
target_link_libraries(ucentralsec PUBLIC
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
//
|
||||
// License type: BSD 3-Clause License
|
||||
// License copy: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE
|
||||
//
|
||||
// Created by Stephane Bourque on 2021-03-04.
|
||||
// Arilia Wireless Inc.
|
||||
// Created by stephane bourque on 2021-06-04.
|
||||
//
|
||||
|
||||
#ifndef UCENTRALGW_ALBHEALTHCHECKSERVER_H
|
||||
@@ -24,7 +20,7 @@
|
||||
#include "Daemon.h"
|
||||
#include "SubSystemServer.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
class ALBRequestHandler: public Poco::Net::HTTPRequestHandler
|
||||
/// Return a HTML document with the current date and time.
|
||||
@@ -89,7 +85,7 @@ namespace uCentral {
|
||||
|
||||
int Start() {
|
||||
if(Daemon()->ConfigGetBool("alb.enable",false)) {
|
||||
Port_ = (int)Daemon()->ConfigGetInt("alb.port",15017);
|
||||
Port_ = (int)Daemon()->ConfigGetInt("alb.port",15015);
|
||||
Socket_ = std::make_unique<Poco::Net::ServerSocket>(Port_);
|
||||
auto Params = new Poco::Net::HTTPServerParams;
|
||||
Server_ = std::make_unique<Poco::Net::HTTPServer>(new ALBRequestHandlerFactory(Logger_), *Socket_, Params);
|
||||
|
||||
88
src/AuthClient.cpp
Normal file
88
src/AuthClient.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
//
|
||||
// Created by stephane bourque on 2021-06-30.
|
||||
//
|
||||
#include <utility>
|
||||
|
||||
#include "AuthClient.h"
|
||||
#include "RESTAPI_SecurityObjects.h"
|
||||
#include "Daemon.h"
|
||||
#include "OpenAPIRequest.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
class AuthClient * AuthClient::instance_ = nullptr;
|
||||
|
||||
int AuthClient::Start() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AuthClient::Stop() {
|
||||
|
||||
}
|
||||
|
||||
void AuthClient::RemovedCachedToken(const std::string &Token) {
|
||||
SubMutexGuard G(Mutex_);
|
||||
UserCache_.erase(Token);
|
||||
}
|
||||
|
||||
bool IsTokenExpired(const SecurityObjects::WebToken &T) {
|
||||
return ((T.expires_in_+T.created_)<std::time(nullptr));
|
||||
}
|
||||
|
||||
bool AuthClient::IsAuthorized(Poco::Net::HTTPServerRequest & Request, std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo ) {
|
||||
SubMutexGuard G(Mutex_);
|
||||
|
||||
auto User = UserCache_.find(SessionToken);
|
||||
if(User != UserCache_.end() && !IsTokenExpired(User->second.webtoken)) {
|
||||
UInfo = User->second;
|
||||
return true;
|
||||
} else {
|
||||
Types::StringPairVec QueryData;
|
||||
QueryData.push_back(std::make_pair("token",SessionToken));
|
||||
OpenAPIRequestGet Req( uSERVICE_SECURITY,
|
||||
"/api/v1/validateToken",
|
||||
QueryData,
|
||||
5000);
|
||||
Poco::JSON::Object::Ptr Response;
|
||||
if(Req.Do(Response)==Poco::Net::HTTPResponse::HTTP_OK) {
|
||||
if(Response->has("tokenInfo") && Response->has("userInfo")) {
|
||||
SecurityObjects::UserInfoAndPolicy P;
|
||||
P.from_json(Response);
|
||||
UserCache_[SessionToken] = P;
|
||||
UInfo = P;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AuthClient::IsTokenAuthorized(const std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo) {
|
||||
SubMutexGuard G(Mutex_);
|
||||
|
||||
auto User = UserCache_.find(SessionToken);
|
||||
if(User != UserCache_.end() && !IsTokenExpired(User->second.webtoken)) {
|
||||
UInfo = User->second;
|
||||
return true;
|
||||
} else {
|
||||
Types::StringPairVec QueryData;
|
||||
QueryData.push_back(std::make_pair("token",SessionToken));
|
||||
OpenAPIRequestGet Req(uSERVICE_SECURITY,
|
||||
"/api/v1/validateToken",
|
||||
QueryData,
|
||||
5000);
|
||||
Poco::JSON::Object::Ptr Response;
|
||||
if(Req.Do(Response)==Poco::Net::HTTPResponse::HTTP_OK) {
|
||||
if(Response->has("tokenInfo") && Response->has("userInfo")) {
|
||||
SecurityObjects::UserInfoAndPolicy P;
|
||||
P.from_json(Response);
|
||||
UserCache_[SessionToken] = P;
|
||||
UInfo = P;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
45
src/AuthClient.h
Normal file
45
src/AuthClient.h
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Created by stephane bourque on 2021-06-30.
|
||||
//
|
||||
|
||||
#ifndef UCENTRALGW_AUTHCLIENT_H
|
||||
#define UCENTRALGW_AUTHCLIENT_H
|
||||
|
||||
#include "Poco/JSON/Object.h"
|
||||
#include "Poco/Net/HTTPServerRequest.h"
|
||||
#include "Poco/Net/HTTPServerResponse.h"
|
||||
#include "Poco/JWT/Signer.h"
|
||||
#include "Poco/SHA2Engine.h"
|
||||
#include "RESTAPI_SecurityObjects.h"
|
||||
#include "SubSystemServer.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
class AuthClient : public SubSystemServer {
|
||||
public:
|
||||
explicit AuthClient() noexcept:
|
||||
SubSystemServer("Authentication", "AUTH-CLNT", "authentication")
|
||||
{
|
||||
}
|
||||
|
||||
static AuthClient *instance() {
|
||||
if (instance_ == nullptr) {
|
||||
instance_ = new AuthClient;
|
||||
}
|
||||
return instance_;
|
||||
}
|
||||
|
||||
int Start() override;
|
||||
void Stop() override;
|
||||
bool IsAuthorized(Poco::Net::HTTPServerRequest & Request, std::string &SessionToken, OpenWifi::SecurityObjects::UserInfoAndPolicy & UInfo );
|
||||
void RemovedCachedToken(const std::string &Token);
|
||||
bool IsTokenAuthorized(const std::string &Token, SecurityObjects::UserInfoAndPolicy & UInfo);
|
||||
private:
|
||||
static AuthClient *instance_;
|
||||
OpenWifi::SecurityObjects::UserInfoCache UserCache_;
|
||||
};
|
||||
|
||||
inline AuthClient * AuthClient() { return AuthClient::instance(); }
|
||||
}
|
||||
|
||||
#endif // UCENTRALGW_AUTHCLIENT_H
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "SMTPMailerService.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
class AuthService *AuthService::instance_ = nullptr;
|
||||
|
||||
AuthService::ACCESS_TYPE AuthService::IntToAccessType(int C) {
|
||||
@@ -277,7 +277,7 @@ namespace uCentral {
|
||||
std::string AuthService::ComputePasswordHash(const std::string &UserName, const std::string &Password) {
|
||||
std::string UName = Poco::trim(Poco::toLower(UserName));
|
||||
SHA2_.update(Password + UName);
|
||||
return uCentral::Utils::ToHex(SHA2_.digest());
|
||||
return Utils::ToHex(SHA2_.digest());
|
||||
}
|
||||
|
||||
bool AuthService::SendEmailToUser(std::string &Email, EMAIL_REASON Reason) {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "RESTAPI_SecurityObjects.h"
|
||||
|
||||
namespace uCentral{
|
||||
namespace OpenWifi{
|
||||
|
||||
static const std::string AUTHENTICATION_SYSTEM{"SYSTEM"};
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "RESTAPI_InternalServer.h"
|
||||
#include "AuthService.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
class Daemon *Daemon::instance_ = nullptr;
|
||||
|
||||
class Daemon *Daemon::instance() {
|
||||
@@ -55,7 +55,7 @@ namespace uCentral {
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
try {
|
||||
auto App = uCentral::Daemon::instance();
|
||||
auto App = OpenWifi::Daemon::instance();
|
||||
auto ExitCode = App->run(argc, argv);
|
||||
delete App;
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
#include "Poco/Crypto/Cipher.h"
|
||||
|
||||
|
||||
#include "uCentralTypes.h"
|
||||
#include "OpenWifiTypes.h"
|
||||
#include "MicroService.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
static const char * vDAEMON_PROPERTIES_FILENAME = "ucentralsec.properties";
|
||||
static const char * vDAEMON_ROOT_ENV_VAR = "UCENTRALSEC_ROOT";
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "Daemon.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
class KafkaManager *KafkaManager::instance_ = nullptr;
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
#include <thread>
|
||||
|
||||
#include "SubSystemServer.h"
|
||||
#include "uCentralTypes.h"
|
||||
#include "OpenWifiTypes.h"
|
||||
|
||||
#include "cppkafka/cppkafka.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
class KafkaManager : public SubSystemServer {
|
||||
public:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef UCENTRALGW_KAFKA_TOPICS_H
|
||||
#define UCENTRALGW_KAFKA_TOPICS_H
|
||||
|
||||
namespace uCentral::KafkaTopics {
|
||||
namespace OpenWifi::KafkaTopics {
|
||||
static const std::string HEALTHCHECK{"healthcheck"};
|
||||
static const std::string STATE{"state"};
|
||||
static const std::string CONNECTION{"connection"};
|
||||
@@ -13,6 +13,7 @@ namespace uCentral::KafkaTopics {
|
||||
static const std::string ALERTS{"alerts"};
|
||||
static const std::string COMMAND{"command"};
|
||||
static const std::string SERVICE_EVENTS{"service_events"};
|
||||
static const std::string DEVICE_EVENT_QUEUE{"device_event_queue"};
|
||||
|
||||
namespace ServiceEvents {
|
||||
static const std::string EVENT_JOIN{"join"};
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "AuthClient.h"
|
||||
#endif
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
void MyErrorHandler::exception(const Poco::Exception & E) {
|
||||
Poco::Thread * CurrentThread = Poco::Thread::current();
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
#include "Poco/Net/HTTPServerRequest.h"
|
||||
#include "Poco/Process.h"
|
||||
|
||||
#include "uCentralTypes.h"
|
||||
#include "OpenWifiTypes.h"
|
||||
#include "SubSystemServer.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
static const std::string uSERVICE_SECURITY{"ucentralsec"};
|
||||
static const std::string uSERVICE_GATEWAY{"ucentralgw"};
|
||||
|
||||
68
src/OpenAPIRequest.cpp
Normal file
68
src/OpenAPIRequest.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// Created by stephane bourque on 2021-07-01.
|
||||
//
|
||||
#include <iostream>
|
||||
|
||||
#include "OpenAPIRequest.h"
|
||||
|
||||
#include "Poco/Net/HTTPSClientSession.h"
|
||||
#include <Poco/Net/HTTPClientSession.h>
|
||||
#include <Poco/Net/HTTPRequest.h>
|
||||
#include <Poco/Net/HTTPResponse.h>
|
||||
#include <Poco/StreamCopier.h>
|
||||
#include <Poco/JSON/Parser.h>
|
||||
#include <Poco/Path.h>
|
||||
#include <Poco/URI.h>
|
||||
#include <Poco/Exception.h>
|
||||
#include "Utils.h"
|
||||
#include "Daemon.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
OpenAPIRequestGet::OpenAPIRequestGet( const std::string & ServiceType,
|
||||
const std::string & EndPoint,
|
||||
Types::StringPairVec & QueryData,
|
||||
uint64_t msTimeout):
|
||||
Type_(ServiceType),
|
||||
EndPoint_(EndPoint),
|
||||
QueryData_(QueryData),
|
||||
msTimeout_(msTimeout) {
|
||||
|
||||
}
|
||||
|
||||
int OpenAPIRequestGet::Do(Poco::JSON::Object::Ptr &ResponseObject) {
|
||||
try {
|
||||
auto Services = Daemon()->GetServices(Type_);
|
||||
for(auto const &Svc:Services) {
|
||||
Poco::URI URI(Svc.PrivateEndPoint);
|
||||
Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
|
||||
|
||||
URI.setPath(EndPoint_);
|
||||
for (const auto &qp : QueryData_)
|
||||
URI.addQueryParameter(qp.first, qp.second);
|
||||
|
||||
std::string Path(URI.getPathAndQuery());
|
||||
Session.setTimeout(Poco::Timespan(5, 0));
|
||||
|
||||
Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_GET,
|
||||
Path,
|
||||
Poco::Net::HTTPMessage::HTTP_1_1);
|
||||
Request.add("X-API-KEY", Svc.AccessKey);
|
||||
Session.sendRequest(Request);
|
||||
|
||||
Poco::Net::HTTPResponse Response;
|
||||
std::istream &is = Session.receiveResponse(Response);
|
||||
if(Response.getStatus()==Poco::Net::HTTPResponse::HTTP_OK) {
|
||||
Poco::JSON::Parser P;
|
||||
ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
|
||||
}
|
||||
return Response.getStatus();
|
||||
}
|
||||
}
|
||||
catch (const Poco::Exception &E)
|
||||
{
|
||||
std::cerr << E.displayText() << std::endl;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
29
src/OpenAPIRequest.h
Normal file
29
src/OpenAPIRequest.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Created by stephane bourque on 2021-07-01.
|
||||
//
|
||||
|
||||
#ifndef UCENTRALGW_OPENAPIREQUEST_H
|
||||
#define UCENTRALGW_OPENAPIREQUEST_H
|
||||
|
||||
#include "Poco/JSON/Object.h"
|
||||
|
||||
#include "OpenWifiTypes.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
class OpenAPIRequestGet {
|
||||
public:
|
||||
explicit OpenAPIRequestGet( const std::string & Type,
|
||||
const std::string & EndPoint,
|
||||
Types::StringPairVec & QueryData,
|
||||
uint64_t msTimeout);
|
||||
int Do(Poco::JSON::Object::Ptr &ResponseObject);
|
||||
private:
|
||||
std::string Type_;
|
||||
std::string EndPoint_;
|
||||
Types::StringPairVec QueryData_;
|
||||
uint64_t msTimeout_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // UCENTRALGW_OPENAPIREQUEST_H
|
||||
@@ -15,7 +15,9 @@
|
||||
#include <utility>
|
||||
#include <queue>
|
||||
|
||||
namespace uCentral::Types {
|
||||
#include "Poco/StringTokenizer.h"
|
||||
|
||||
namespace OpenWifi::Types {
|
||||
typedef std::pair<std::string,std::string> StringPair;
|
||||
typedef std::vector<StringPair> StringPairVec;
|
||||
typedef std::queue<StringPair> StringPairQueue;
|
||||
@@ -28,6 +30,9 @@ namespace uCentral::Types {
|
||||
typedef std::map<std::string, TopicNotifyFunctionList> NotifyTable;
|
||||
typedef std::map<std::string,uint64_t> CountedMap;
|
||||
|
||||
typedef std::string UUID_t;
|
||||
typedef std::vector<UUID_t> UUIDvec_t;
|
||||
|
||||
inline void UpdateCountedMap(CountedMap &M, const std::string &S, uint64_t Increment=1) {
|
||||
auto it = M.find(S);
|
||||
if(it==M.end())
|
||||
@@ -35,6 +40,29 @@ namespace uCentral::Types {
|
||||
else
|
||||
it->second += Increment;
|
||||
}
|
||||
|
||||
inline std::string to_string( const StringVec &V) {
|
||||
std::string Result;
|
||||
|
||||
bool first=true;
|
||||
for(const auto &i:V) {
|
||||
if(first) {
|
||||
Result += i;
|
||||
first = false;
|
||||
} else {
|
||||
Result += ",";
|
||||
Result += i;
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline void from_string(const std::string &S, StringVec &V) {
|
||||
Poco::StringTokenizer Tokens(S,",",Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
|
||||
|
||||
for(auto const &i:Tokens)
|
||||
V.emplace_back(i);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // UCENTRALGW_UCENTRALTYPES_H
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "Utils.h"
|
||||
#include "RESTAPI_protocol.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_AssetServer::handleRequest(Poco::Net::HTTPServerRequest &Request, Poco::Net::HTTPServerResponse &Response) {
|
||||
if(Request.getMethod()==Poco::Net::HTTPRequest::HTTP_GET)
|
||||
DoGet(Request, Response);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "RESTAPI_handler.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
class RESTAPI_AssetServer : public RESTAPIHandler {
|
||||
public:
|
||||
RESTAPI_AssetServer(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
class RESTAPI_InternalServer *RESTAPI_InternalServer::instance_ = nullptr;
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace uCentral {
|
||||
Poco::Net::HTTPRequestHandler *InternalRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & Request) {
|
||||
|
||||
Logger_.debug(Poco::format("REQUEST(%s): %s %s",
|
||||
uCentral::Utils::FormatIPv6(Request.clientAddress().toString()),
|
||||
Utils::FormatIPv6(Request.clientAddress().toString()),
|
||||
Request.getMethod(), Request.getURI()));
|
||||
|
||||
Poco::URI uri(Request.getURI());
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "Poco/Net/HTTPServerRequest.h"
|
||||
#include "Poco/Net/NetException.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
class RESTAPI_InternalServer : public SubSystemServer {
|
||||
public:
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
#include "RESTAPI_SecurityObjects.h"
|
||||
#include "RESTAPI_utils.h"
|
||||
|
||||
using uCentral::RESTAPI_utils::field_to_json;
|
||||
using uCentral::RESTAPI_utils::field_from_json;
|
||||
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||
using OpenWifi::RESTAPI_utils::field_from_json;
|
||||
|
||||
namespace uCentral::SecurityObjects {
|
||||
namespace OpenWifi::SecurityObjects {
|
||||
|
||||
void AclTemplate::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"Read",Read_);
|
||||
@@ -303,6 +303,20 @@ namespace uCentral::SecurityObjects {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes) {
|
||||
try {
|
||||
SecurityObjects::NoteInfoVec NIV;
|
||||
NIV = RESTAPI_utils::to_object_array<SecurityObjects::NoteInfo>(Obj->get("notes").toString());
|
||||
for(auto const &i:NIV) {
|
||||
SecurityObjects::NoteInfo ii{.created=(uint64_t)std::time(nullptr), .createdBy=UInfo.email, .note=i.note};
|
||||
Notes.push_back(ii);
|
||||
}
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ProfileAction::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"resource", resource);
|
||||
field_to_json<ResourceAccessType>(Obj,"access", access, ResourceAccessTypeToString);
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#define UCENTRAL_RESTAPI_SECURITYOBJECTS_H
|
||||
|
||||
#include "Poco/JSON/Object.h"
|
||||
#include "uCentralTypes.h"
|
||||
#include "OpenWifiTypes.h"
|
||||
|
||||
namespace uCentral::SecurityObjects {
|
||||
namespace OpenWifi::SecurityObjects {
|
||||
|
||||
struct AclTemplate {
|
||||
bool Read_ = true;
|
||||
@@ -94,6 +94,8 @@ namespace uCentral::SecurityObjects {
|
||||
};
|
||||
typedef std::vector<UserInfo> UserInfoVec;
|
||||
|
||||
bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
|
||||
|
||||
struct InternalServiceInfo {
|
||||
std::string privateURI;
|
||||
std::string publicURI;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "RESTAPI_server.h"
|
||||
#include "Daemon.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_action_links::handleRequest(Poco::Net::HTTPServerRequest &Request,
|
||||
Poco::Net::HTTPServerResponse &Response) {
|
||||
// there is no authentication here, this is just someone clicking on a link
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include "Poco/CountingStream.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
class RESTAPI_action_links : public RESTAPIHandler {
|
||||
public:
|
||||
RESTAPI_action_links(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "Utils.h"
|
||||
#include "RESTAPI_protocol.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
void AvatarPartHandler::handlePart(const Poco::Net::MessageHeader &Header, std::istream &Stream) {
|
||||
FileType_ = Header.get(RESTAPI::Protocol::CONTENTTYPE, RESTAPI::Protocol::UNSPECIFIED);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "RESTAPI_handler.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
class AvatarPartHandler : public Poco::Net::PartHandler {
|
||||
public:
|
||||
|
||||
@@ -27,16 +27,16 @@
|
||||
#include "Utils.h"
|
||||
#include "Daemon.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
bool RESTAPIHandler::ParseBindings(const std::string & Request, const std::list<const char *> & EndPoints, BindingMap &bindings) {
|
||||
std::string Param, Value;
|
||||
|
||||
bindings.clear();
|
||||
std::vector<std::string> PathItems = uCentral::Utils::Split(Request, '/');
|
||||
std::vector<std::string> PathItems = Utils::Split(Request, '/');
|
||||
|
||||
for(const auto &EndPoint:EndPoints) {
|
||||
std::vector<std::string> ParamItems = uCentral::Utils::Split(EndPoint, '/');
|
||||
std::vector<std::string> ParamItems = Utils::Split(EndPoint, '/');
|
||||
if (PathItems.size() != ParamItems.size())
|
||||
continue;
|
||||
|
||||
@@ -365,17 +365,17 @@ namespace uCentral {
|
||||
}
|
||||
|
||||
bool RESTAPIHandler::InitQueryBlock() {
|
||||
QB_.SerialNumber = GetParameter(uCentral::RESTAPI::Protocol::SERIALNUMBER, "");
|
||||
QB_.StartDate = GetParameter(uCentral::RESTAPI::Protocol::STARTDATE, 0);
|
||||
QB_.EndDate = GetParameter(uCentral::RESTAPI::Protocol::ENDDATE, 0);
|
||||
QB_.Offset = GetParameter(uCentral::RESTAPI::Protocol::OFFSET, 1);
|
||||
QB_.Limit = GetParameter(uCentral::RESTAPI::Protocol::LIMIT, 100);
|
||||
QB_.Filter = GetParameter(uCentral::RESTAPI::Protocol::FILTER, "");
|
||||
QB_.Select = GetParameter(uCentral::RESTAPI::Protocol::SELECT, "");
|
||||
QB_.Lifetime = GetBoolParameter(uCentral::RESTAPI::Protocol::LIFETIME,false);
|
||||
QB_.LogType = GetParameter(uCentral::RESTAPI::Protocol::LOGTYPE,0);
|
||||
QB_.LastOnly = GetBoolParameter(uCentral::RESTAPI::Protocol::LASTONLY,false);
|
||||
QB_.Newest = GetBoolParameter(uCentral::RESTAPI::Protocol::NEWEST,false);
|
||||
QB_.SerialNumber = GetParameter(RESTAPI::Protocol::SERIALNUMBER, "");
|
||||
QB_.StartDate = GetParameter(RESTAPI::Protocol::STARTDATE, 0);
|
||||
QB_.EndDate = GetParameter(RESTAPI::Protocol::ENDDATE, 0);
|
||||
QB_.Offset = GetParameter(RESTAPI::Protocol::OFFSET, 1);
|
||||
QB_.Limit = GetParameter(RESTAPI::Protocol::LIMIT, 100);
|
||||
QB_.Filter = GetParameter(RESTAPI::Protocol::FILTER, "");
|
||||
QB_.Select = GetParameter(RESTAPI::Protocol::SELECT, "");
|
||||
QB_.Lifetime = GetBoolParameter(RESTAPI::Protocol::LIFETIME,false);
|
||||
QB_.LogType = GetParameter(RESTAPI::Protocol::LOGTYPE,0);
|
||||
QB_.LastOnly = GetBoolParameter(RESTAPI::Protocol::LASTONLY,false);
|
||||
QB_.Newest = GetBoolParameter(RESTAPI::Protocol::NEWEST,false);
|
||||
|
||||
if(QB_.Offset<1) return false;
|
||||
return true;
|
||||
@@ -400,7 +400,7 @@ namespace uCentral {
|
||||
}
|
||||
|
||||
[[nodiscard]] uint64_t RESTAPIHandler::GetWhen(const Poco::JSON::Object::Ptr &Obj) {
|
||||
return RESTAPIHandler::Get(uCentral::RESTAPI::Protocol::WHEN, Obj);
|
||||
return RESTAPIHandler::Get(RESTAPI::Protocol::WHEN, Obj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include "RESTAPI_SecurityObjects.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
class RESTAPI_PartHandler: public Poco::Net::PartHandler
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_oauth2Handler::handleRequest(Poco::Net::HTTPServerRequest &Request,
|
||||
Poco::Net::HTTPServerResponse &Response) {
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace uCentral {
|
||||
Poco::JSON::Parser parser;
|
||||
Poco::JSON::Object::Ptr Obj = parser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
|
||||
|
||||
auto userId = GetS(uCentral::RESTAPI::Protocol::USERID, Obj);
|
||||
auto password = GetS(uCentral::RESTAPI::Protocol::PASSWORD, Obj);
|
||||
auto newPassword = GetS(uCentral::RESTAPI::Protocol::NEWPASSWORD, Obj);
|
||||
auto userId = GetS(RESTAPI::Protocol::USERID, Obj);
|
||||
auto password = GetS(RESTAPI::Protocol::PASSWORD, Obj);
|
||||
auto newPassword = GetS(RESTAPI::Protocol::NEWPASSWORD, Obj);
|
||||
|
||||
if(GetBoolParameter(RESTAPI::Protocol::REQUIREMENTS, false)) {
|
||||
Poco::JSON::Object Answer;
|
||||
@@ -79,7 +79,7 @@ namespace uCentral {
|
||||
UnAuthorized(Request, Response, "Not authorized.");
|
||||
return;
|
||||
}
|
||||
auto Token = GetBinding(uCentral::RESTAPI::Protocol::TOKEN, "...");
|
||||
auto Token = GetBinding(RESTAPI::Protocol::TOKEN, "...");
|
||||
if (Token == SessionToken_) {
|
||||
AuthService()->Logout(Token);
|
||||
ReturnStatus(Request, Response, Poco::Net::HTTPResponse::HTTP_NO_CONTENT, true);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "RESTAPI_handler.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
class RESTAPI_oauth2Handler : public RESTAPIHandler {
|
||||
public:
|
||||
RESTAPI_oauth2Handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef UCENTRALGW_RESTAPI_PROTOCOL_H
|
||||
#define UCENTRALGW_RESTAPI_PROTOCOL_H
|
||||
|
||||
namespace uCentral::RESTAPI::Protocol {
|
||||
namespace OpenWifi::RESTAPI::Protocol {
|
||||
static const char * CAPABILITIES = "capabilities";
|
||||
static const char * LOGS = "logs";
|
||||
static const char * HEALTHCHECKS = "healthchecks";
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "Daemon.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
class RESTAPI_Server *RESTAPI_Server::instance_ = nullptr;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace uCentral {
|
||||
|
||||
Poco::Net::HTTPRequestHandler *RequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & Request) {
|
||||
|
||||
Logger_.debug(Poco::format("REQUEST(%s): %s %s", uCentral::Utils::FormatIPv6(Request.clientAddress().toString()), Request.getMethod(), Request.getURI()));
|
||||
Logger_.debug(Poco::format("REQUEST(%s): %s %s", Utils::FormatIPv6(Request.clientAddress().toString()), Request.getMethod(), Request.getURI()));
|
||||
|
||||
Poco::URI uri(Request.getURI());
|
||||
const auto & Path = uri.getPath();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "Poco/Net/HTTPServerRequest.h"
|
||||
#include "Poco/Net/NetException.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
class RESTAPI_Server : public SubSystemServer {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "Daemon.h"
|
||||
#include "RESTAPI_SecurityObjects.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_systemEndpoints_handler::handleRequest(Poco::Net::HTTPServerRequest &Request,
|
||||
Poco::Net::HTTPServerResponse &Response) {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define UCENTRALSEC_RESTAPI_SYSTEMENDPOINTS_HANDLER_H
|
||||
|
||||
#include "RESTAPI_handler.h"
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
class RESTAPI_systemEndpoints_handler : public RESTAPIHandler {
|
||||
public:
|
||||
RESTAPI_systemEndpoints_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "Daemon.h"
|
||||
#include "RESTAPI_protocol.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_system_command::handleRequest(Poco::Net::HTTPServerRequest &Request,
|
||||
Poco::Net::HTTPServerResponse &Response) {
|
||||
|
||||
@@ -36,19 +36,19 @@ namespace uCentral {
|
||||
Poco::JSON::Parser parser;
|
||||
auto Obj = parser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
|
||||
|
||||
if (Obj->has(uCentral::RESTAPI::Protocol::COMMAND)) {
|
||||
auto Command = Poco::toLower(Obj->get(uCentral::RESTAPI::Protocol::COMMAND).toString());
|
||||
if (Command == uCentral::RESTAPI::Protocol::SETLOGLEVEL) {
|
||||
if (Obj->has(uCentral::RESTAPI::Protocol::PARAMETERS) &&
|
||||
Obj->isArray(uCentral::RESTAPI::Protocol::PARAMETERS)) {
|
||||
auto ParametersBlock = Obj->getArray(uCentral::RESTAPI::Protocol::PARAMETERS);
|
||||
if (Obj->has(RESTAPI::Protocol::COMMAND)) {
|
||||
auto Command = Poco::toLower(Obj->get(RESTAPI::Protocol::COMMAND).toString());
|
||||
if (Command == RESTAPI::Protocol::SETLOGLEVEL) {
|
||||
if (Obj->has(RESTAPI::Protocol::PARAMETERS) &&
|
||||
Obj->isArray(RESTAPI::Protocol::PARAMETERS)) {
|
||||
auto ParametersBlock = Obj->getArray(RESTAPI::Protocol::PARAMETERS);
|
||||
for (const auto &i:*ParametersBlock) {
|
||||
Poco::JSON::Parser pp;
|
||||
auto InnerObj = pp.parse(i).extract<Poco::JSON::Object::Ptr>();
|
||||
if (InnerObj->has(uCentral::RESTAPI::Protocol::TAG) &&
|
||||
InnerObj->has(uCentral::RESTAPI::Protocol::VALUE)) {
|
||||
auto Name = GetS(uCentral::RESTAPI::Protocol::TAG, InnerObj);
|
||||
auto Value = GetS(uCentral::RESTAPI::Protocol::VALUE, InnerObj);
|
||||
if (InnerObj->has(RESTAPI::Protocol::TAG) &&
|
||||
InnerObj->has(RESTAPI::Protocol::VALUE)) {
|
||||
auto Name = GetS(RESTAPI::Protocol::TAG, InnerObj);
|
||||
auto Value = GetS(RESTAPI::Protocol::VALUE, InnerObj);
|
||||
Daemon()->SetSubsystemLogLevel(Name, Value);
|
||||
Logger_.information(Poco::format("Setting log level for %s at %s", Name, Value));
|
||||
}
|
||||
@@ -56,38 +56,38 @@ namespace uCentral {
|
||||
OK(Request, Response);
|
||||
return;
|
||||
}
|
||||
} else if (Command == uCentral::RESTAPI::Protocol::GETLOGLEVELS) {
|
||||
} else if (Command == RESTAPI::Protocol::GETLOGLEVELS) {
|
||||
auto CurrentLogLevels = Daemon()->GetLogLevels();
|
||||
Poco::JSON::Object Result;
|
||||
Poco::JSON::Array Array;
|
||||
for(auto &[Name,Level]:CurrentLogLevels) {
|
||||
Poco::JSON::Object Pair;
|
||||
Pair.set( uCentral::RESTAPI::Protocol::TAG,Name);
|
||||
Pair.set(uCentral::RESTAPI::Protocol::VALUE,Level);
|
||||
Pair.set( RESTAPI::Protocol::TAG,Name);
|
||||
Pair.set(RESTAPI::Protocol::VALUE,Level);
|
||||
Array.add(Pair);
|
||||
}
|
||||
Result.set(uCentral::RESTAPI::Protocol::TAGLIST,Array);
|
||||
Result.set(RESTAPI::Protocol::TAGLIST,Array);
|
||||
ReturnObject(Request,Result,Response);
|
||||
return;
|
||||
} else if (Command == uCentral::RESTAPI::Protocol::GETLOGLEVELNAMES) {
|
||||
} else if (Command == RESTAPI::Protocol::GETLOGLEVELNAMES) {
|
||||
Poco::JSON::Object Result;
|
||||
Poco::JSON::Array LevelNamesArray;
|
||||
const Types::StringVec & LevelNames = Daemon()->GetLogLevelNames();
|
||||
for(const auto &i:LevelNames)
|
||||
LevelNamesArray.add(i);
|
||||
Result.set(uCentral::RESTAPI::Protocol::LIST,LevelNamesArray);
|
||||
Result.set(RESTAPI::Protocol::LIST,LevelNamesArray);
|
||||
ReturnObject(Request,Result,Response);
|
||||
return;
|
||||
} else if (Command == uCentral::RESTAPI::Protocol::GETSUBSYSTEMNAMES) {
|
||||
} else if (Command == RESTAPI::Protocol::GETSUBSYSTEMNAMES) {
|
||||
Poco::JSON::Object Result;
|
||||
Poco::JSON::Array LevelNamesArray;
|
||||
const Types::StringVec & SubSystemNames = Daemon()->GetSubSystems();
|
||||
for(const auto &i:SubSystemNames)
|
||||
LevelNamesArray.add(i);
|
||||
Result.set(uCentral::RESTAPI::Protocol::LIST,LevelNamesArray);
|
||||
Result.set(RESTAPI::Protocol::LIST,LevelNamesArray);
|
||||
ReturnObject(Request,Result,Response);
|
||||
return;
|
||||
} else if (Command == uCentral::RESTAPI::Protocol::STATS) {
|
||||
} else if (Command == RESTAPI::Protocol::STATS) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "RESTAPI_handler.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
class RESTAPI_system_command : public RESTAPIHandler {
|
||||
public:
|
||||
RESTAPI_system_command(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "Utils.h"
|
||||
#include "RESTAPI_utils.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_user_handler::handleRequest(Poco::Net::HTTPServerRequest &Request, Poco::Net::HTTPServerResponse &Response) {
|
||||
|
||||
if (!ContinueProcessing(Request, Response))
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "RESTAPI_handler.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
class RESTAPI_user_handler : public RESTAPIHandler {
|
||||
public:
|
||||
RESTAPI_user_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "RESTAPI_protocol.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_users_handler::handleRequest(Poco::Net::HTTPServerRequest &Request, Poco::Net::HTTPServerResponse &Response) {
|
||||
if (!ContinueProcessing(Request, Response))
|
||||
return;
|
||||
@@ -41,7 +41,7 @@ namespace uCentral {
|
||||
}
|
||||
}
|
||||
Poco::JSON::Object RetObj;
|
||||
RetObj.set(uCentral::RESTAPI::Protocol::USERS, ArrayObj);
|
||||
RetObj.set(RESTAPI::Protocol::USERS, ArrayObj);
|
||||
ReturnObject(Request, RetObj, Response);
|
||||
return;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ namespace uCentral {
|
||||
}
|
||||
}
|
||||
Poco::JSON::Object RetObj;
|
||||
RetObj.set(uCentral::RESTAPI::Protocol::USERS, ArrayObj);
|
||||
RetObj.set(RESTAPI::Protocol::USERS, ArrayObj);
|
||||
ReturnObject(Request, RetObj, Response);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "RESTAPI_handler.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
class RESTAPI_users_handler : public RESTAPIHandler {
|
||||
public:
|
||||
RESTAPI_users_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "RESTAPI_utils.h"
|
||||
|
||||
namespace uCentral::RESTAPI_utils {
|
||||
namespace OpenWifi::RESTAPI_utils {
|
||||
|
||||
void EmbedDocument(const std::string & ObjName, Poco::JSON::Object & Obj, const std::string &ObjStr) {
|
||||
std::string D = ObjStr.empty() ? "{}" : ObjStr;
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include "Poco/JSON/Object.h"
|
||||
#include "Poco/JSON/Parser.h"
|
||||
#include "Poco/Net/HTTPServerRequest.h"
|
||||
#include "uCentralTypes.h"
|
||||
#include "OpenWifiTypes.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace uCentral::RESTAPI_utils {
|
||||
namespace OpenWifi::RESTAPI_utils {
|
||||
|
||||
void EmbedDocument(const std::string & ObjName, Poco::JSON::Object & Obj, const std::string &ObjStr);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "AuthService.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_validateToken_handler::handleRequest(Poco::Net::HTTPServerRequest &Request,
|
||||
Poco::Net::HTTPServerResponse &Response) {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "RESTAPI_handler.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
class RESTAPI_validateToken_handler : public RESTAPIHandler {
|
||||
public:
|
||||
RESTAPI_validateToken_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "Utils.h"
|
||||
#include "Daemon.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
class SMTPMailerService * SMTPMailerService::instance_ = nullptr;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "Poco/File.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
enum MESSAGE_ATTRIBUTES {
|
||||
RECIPIENT_EMAIL,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "Poco/Util/Application.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
class Storage *Storage::instance_ = nullptr;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "RESTAPI_SecurityObjects.h"
|
||||
#include "SubSystemServer.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
static const std::string AllActionLinksFieldsForSelect {
|
||||
"Id, "
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "Daemon.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
SubSystemServer::SubSystemServer(std::string Name, const std::string &LoggingPrefix,
|
||||
std::string SubSystemConfigPrefix)
|
||||
: Name_(std::move(Name)), Logger_(Poco::Logger::get(LoggingPrefix)),
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
using SubMutex = std::recursive_mutex;
|
||||
using SubMutexGuard = std::lock_guard<SubMutex>;
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
class PropertiesFileServerEntry {
|
||||
public:
|
||||
PropertiesFileServerEntry(std::string Address, uint32_t port, std::string Key_file,
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "uCentralProtocol.h"
|
||||
#include "Daemon.h"
|
||||
|
||||
namespace uCentral::Utils {
|
||||
namespace OpenWifi::Utils {
|
||||
|
||||
[[nodiscard]] bool ValidSerialNumber(const std::string &Serial) {
|
||||
return ((Serial.size() < uCentralProtocol::SERIAL_NUMBER_LENGTH) &&
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
#include "Poco/Net/IPAddress.h"
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/File.h"
|
||||
#include "uCentralTypes.h"
|
||||
#include "OpenWifiTypes.h"
|
||||
|
||||
#define DBGLINE { std::cout << __FILE__ << ":" << __func__ << ":" << __LINE__ << std::endl; };
|
||||
|
||||
namespace uCentral::Utils {
|
||||
namespace OpenWifi::Utils {
|
||||
|
||||
enum MediaTypeEncodings {
|
||||
PLAIN,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "Poco/Data/LOBStream.h"
|
||||
#include "Daemon.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
/*
|
||||
"Id VARCHAR(36) PRIMARY KEY, "
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef WLAN_CLOUD_UCENTRALSEC_STORAGE_AVATAR_H
|
||||
#define WLAN_CLOUD_UCENTRALSEC_STORAGE_AVATAR_H
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "Daemon.h"
|
||||
#include "StorageService.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
#ifdef SMALL_BUILD
|
||||
int Service::Setup_MySQL() { uCentral::instance()->exit(Poco::Util::Application::EXIT_CONFIG);}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "Daemon.h"
|
||||
#include "StorageService.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
#ifdef SMALL_BUILD
|
||||
int Service::Setup_PostgreSQL() { uCentral::instance()->exit(Poco::Util::Application::EXIT_CONFIG);}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "Daemon.h"
|
||||
#include "StorageService.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
int Storage::Setup_SQLite() {
|
||||
Logger_.notice("SQLite Storage enabled.");
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "storage_users.h"
|
||||
#include "storage_avatar.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
int Storage::Create_Tables() {
|
||||
Create_UserTable();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "Poco/Tuple.h"
|
||||
#include "storage_users.h"
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
|
||||
bool Convert(const UserInfoRecord &T, SecurityObjects::UserInfo &U) {
|
||||
U.Id = T.get<0>();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef UCENTRALSEC_STORAGE_USERS_H
|
||||
#define UCENTRALSEC_STORAGE_USERS_H
|
||||
|
||||
namespace uCentral {
|
||||
namespace OpenWifi {
|
||||
static const std::string AllUsersFieldsForCreation{
|
||||
" Id varchar(36) UNIQUE PRIMARY KEY,"
|
||||
"name varchar,"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "Poco/String.h"
|
||||
|
||||
namespace uCentral::uCentralProtocol {
|
||||
namespace OpenWifi::uCentralProtocol {
|
||||
|
||||
const int SERIAL_NUMBER_LENGTH = 30;
|
||||
|
||||
@@ -79,6 +79,15 @@ namespace uCentral::uCentralProtocol {
|
||||
static const char * VERBOSE = "verbose";
|
||||
static const char * BANDS = "bands";
|
||||
static const char * CHANNELS = "channels";
|
||||
static const char * PASSWORD = "password";
|
||||
static const char * DEVICEUPDATE = "deviceupdate";
|
||||
|
||||
static const char * SERIALNUMBER = "serialNumber";
|
||||
static const char * COMPATIBLE = "compatible";
|
||||
static const char * DISCONNECTION = "disconnection";
|
||||
static const char * TIMESTAMP = "timestamp";
|
||||
static const char * SYSTEM = "system";
|
||||
static const char * HOST = "host";
|
||||
|
||||
enum EVENT_MSG {
|
||||
ET_UNKNOWN,
|
||||
@@ -89,7 +98,8 @@ namespace uCentral::uCentralProtocol {
|
||||
ET_CRASHLOG,
|
||||
ET_PING,
|
||||
ET_CFGPENDING,
|
||||
ET_RECOVERY
|
||||
ET_RECOVERY,
|
||||
ET_DEVICEUPDATE
|
||||
};
|
||||
|
||||
static EVENT_MSG EventFromString(const std::string & Method) {
|
||||
@@ -109,6 +119,8 @@ namespace uCentral::uCentralProtocol {
|
||||
return ET_CFGPENDING;
|
||||
} else if (!Poco::icompare(Method, RECOVERY)) {
|
||||
return ET_RECOVERY;
|
||||
} else if (!Poco::icompare(Method, DEVICEUPDATE)) {
|
||||
return ET_DEVICEUPDATE;
|
||||
} else
|
||||
return ET_UNKNOWN;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user