 |
Fledge
An open source edge computing platform for industrial users
|
1 #ifndef _SERVICE_HANDLER_H
2 #define _SERVICE_HANDLER_H
12 #include <config_category.h>
14 #include <management_client.h>
23 virtual void shutdown() = 0;
24 virtual void restart() = 0;
25 virtual void configChange(
const std::string& category,
const std::string& config) = 0;
26 virtual void configChildCreate(
const std::string& parent_category,
const std::string& category,
const std::string& config) = 0;
27 virtual void configChildDelete(
const std::string& parent_category,
const std::string& category) = 0;
28 virtual bool isRunning() = 0;
29 virtual bool securityChange(
const std::string &payload) {
return payload.empty(); };
39 virtual ~
ServiceAuthHandler() {
if (m_refreshThread) { m_refreshRunning =
false; m_refreshThread->join();
delete m_refreshThread; } };
40 std::string& getName() {
return m_name; };
41 std::string& getType() {
return m_type; };
49 std::shared_ptr<HttpServer::Request> request,
50 const std::string& serviceName,
51 const std::string& serviceType);
54 std::shared_ptr<HttpServer::Request> request,
55 std::string& callerName,
56 std::string& callerType);
59 std::shared_ptr<HttpServer::Request> request,
61 std::shared_ptr<HttpServer::Response>,
62 std::shared_ptr<HttpServer::Request>)> funcPUT);
65 void respond(std::shared_ptr<HttpServer::Response> response,
66 const std::string& payload)
68 *response <<
"HTTP/1.1 200 OK\r\n"
69 <<
"Content-Length: " << payload.length() <<
"\r\n"
70 <<
"Content-type: application/json\r\n\r\n"
74 void respond(std::shared_ptr<HttpServer::Response> response,
75 SimpleWeb::StatusCode code,
76 const std::string& payload)
78 *response <<
"HTTP/1.1 " << status_code(code) <<
"\r\n"
79 <<
"Content-Length: " << payload.length() <<
"\r\n"
80 <<
"Content-type: application/json\r\n\r\n"
88 bool verifyURL(
const std::string& path,
89 const std::string& sName,
90 const std::string& sType);
91 bool verifyService(
const std::string& sName,
92 const std::string &sType);
103 std::mutex m_mtx_config;
105 bool m_authentication_enabled;
110 std::thread *m_refreshThread;
111 bool m_refreshRunning;
void setInitialAuthenticatedCaller()
Set initial value of enabled authentication.
Definition: service_security.cpp:142
bool securityChange(const std::string &payload)
Request security change action:
Definition: service_security.cpp:738
bool AuthenticationMiddlewareACL(std::shared_ptr< HttpServer::Response > response, std::shared_ptr< HttpServer::Request > request, const std::string &serviceName, const std::string &serviceType)
Authentication Middleware ACL check.
Definition: service_security.cpp:475
void AuthenticationMiddlewarePUT(std::shared_ptr< HttpServer::Response > response, std::shared_ptr< HttpServer::Request > request, std::function< void(std::shared_ptr< HttpServer::Response >, std::shared_ptr< HttpServer::Request >)> funcPUT)
Authentication Middleware for PUT methods.
Definition: service_security.cpp:359
This class represents the ACL (Access Control List) as JSON object fetched from Fledge Storage.
Definition: acl.h:23
static ManagementClient * m_mgtClient
Initialise m_mgtClient object to NULL.
Definition: service_handler.h:99
void refreshBearerToken()
Refresh the bearer token of the runnign service This routine is run by a thread started in createSecu...
Definition: service_security.cpp:585
bool getAuthenticatedCaller()
Return enabled authentication value.
Definition: service_security.cpp:175
bool AuthenticationMiddlewareCommon(std::shared_ptr< HttpServer::Response > response, std::shared_ptr< HttpServer::Request > request, std::string &callerName, std::string &callerType)
Authentication Middleware for Dispatcher service.
Definition: service_security.cpp:531
The management client class used by services and tasks to communicate with the management API of the ...
Definition: management_client.h:43
Definition: config_category.h:56
bool updateSecurityCategory(const std::string &newCategory)
Update the class objects from security category content update.
Definition: service_security.cpp:111
bool createSecurityCategories(ManagementClient *mgtClient, bool dryRun)
Create "${service}Security" category with empty content.
Definition: service_security.cpp:34
ServiceAuthHandler adds security to the base class ServiceHandler.
Definition: service_handler.h:35
void setAuthenticatedCaller(bool enabled)
Set enabled authentication value.
Definition: service_security.cpp:164
ServiceHandler abstract class - the interface that services using the management API must provide.
Definition: service_handler.h:20