mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-02 03:37:51 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -493,6 +493,16 @@ components:
|
|||||||
sms:
|
sms:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
ExtraSystemConfiguration:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
parameterName:
|
||||||
|
type: string
|
||||||
|
parameterValue:
|
||||||
|
type: string
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
##
|
##
|
||||||
## These are endpoints that all services in the uCentral stack must provide
|
## These are endpoints that all services in the uCentral stack must provide
|
||||||
@@ -2057,6 +2067,69 @@ paths:
|
|||||||
404:
|
404:
|
||||||
$ref: '#/components/responses/NotFound'
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
/systemConfiguration:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- SystemConfiguration
|
||||||
|
summary: Retrieve system configuration items
|
||||||
|
operationId: getSystemConfiguration
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
description: Which parameters you want to retrieve
|
||||||
|
name: entries
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
example:
|
||||||
|
- element1
|
||||||
|
- element1,element2,element3
|
||||||
|
required: false
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: List of configuration elements
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/ExtraSystemConfiguration'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- SystemConfiguration
|
||||||
|
summary: Set some or all system configuration
|
||||||
|
operationId: setSystemConfiguration
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ExtraSystemConfiguration'
|
||||||
|
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
$ref: '#/components/schemas/ExtraSystemConfiguration'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- SystemConfiguration
|
||||||
|
summary: Delete all additional system configuration
|
||||||
|
operationId: deleteSystemConfiguration
|
||||||
|
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
$ref: '#/components/responses/Success'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
##
|
##
|
||||||
## These are endpoints that all services in the uCentral stack must provide
|
## These are endpoints that all services in the uCentral stack must provide
|
||||||
|
|||||||
@@ -721,4 +721,20 @@ namespace OpenWifi::SecurityObjects {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExtraSystemConfiguration::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "parameterName", parameterName);
|
||||||
|
field_to_json(Obj, "parameterValue", parameterValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ExtraSystemConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json(Obj, "parameterName", parameterName);
|
||||||
|
field_from_json(Obj, "parameterValue", parameterValue);
|
||||||
|
return true;
|
||||||
|
} catch (...) {
|
||||||
|
std::cout << "Cannot parse: Token" << std::endl;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace OpenWifi::SecurityObjects
|
} // namespace OpenWifi::SecurityObjects
|
||||||
|
|||||||
@@ -367,5 +367,13 @@ namespace OpenWifi {
|
|||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ExtraSystemConfiguration {
|
||||||
|
std::string parameterName;
|
||||||
|
std::string parameterValue;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace SecurityObjects
|
} // namespace SecurityObjects
|
||||||
} // namespace OpenWifi
|
} // namespace OpenWifi
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "framework/MicroServiceFuncs.h"
|
|
||||||
#include "framework/RESTAPI_Handler.h"
|
#include "framework/RESTAPI_Handler.h"
|
||||||
|
#include "framework/MicroServiceFuncs.h"
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ namespace OpenWifi {
|
|||||||
class RESTAPI_system_configuration : public RESTAPIHandler {
|
class RESTAPI_system_configuration : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_system_configuration(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L,
|
RESTAPI_system_configuration(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L,
|
||||||
RESTAPI_GenericServerAccounting &Server,
|
RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId,
|
||||||
uint64_t TransactionId, bool Internal)
|
bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_PUT,
|
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_PUT,
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
@@ -27,23 +27,42 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
inline void DoPost() final {}
|
inline void DoPost() final {}
|
||||||
|
|
||||||
inline void DoGet() final { return OK(); }
|
inline void DoGet() final {
|
||||||
|
auto entries = GetParameter("entries","");
|
||||||
|
if(entries.empty()) {
|
||||||
|
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto entriesArray = Poco::StringTokenizer(entries,",",Poco::StringTokenizer::TOK_TRIM);
|
||||||
|
Poco::JSON::Array Array;
|
||||||
|
for(const auto &entry:entriesArray) {
|
||||||
|
SecurityObjects::ExtraSystemConfiguration X;
|
||||||
|
X.parameterName = entry;
|
||||||
|
X.parameterValue = MicroServiceConfigGetString(entry,"");
|
||||||
|
Poco::JSON::Object E;
|
||||||
|
X.to_json(E);
|
||||||
|
Array.add(E);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
Array.stringify(os);
|
||||||
|
return ReturnRawJSON(os.str());
|
||||||
|
}
|
||||||
|
|
||||||
inline void DoPut() final{
|
inline void DoPut() final{
|
||||||
if(UserInfo_.userinfo.userRole!=SecurityObjects::ROOT) {
|
if(UserInfo_.userinfo.userRole!=SecurityObjects::ROOT) {
|
||||||
return UnAuthorized(RESTAPI::Errors::ACCESS_DENIED);
|
return UnAuthorized(RESTAPI::Errors::ACCESS_DENIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK();
|
return BadRequest(RESTAPI::Errors::NotImplemented);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void DoDelete() final{
|
inline void DoDelete() final{
|
||||||
if(UserInfo_.userinfo.userRole!=SecurityObjects::ROOT) {
|
if(UserInfo_.userinfo.userRole!=SecurityObjects::ROOT) {
|
||||||
return UnAuthorized(RESTAPI::Errors::ACCESS_DENIED);
|
return UnAuthorized(RESTAPI::Errors::ACCESS_DENIED);
|
||||||
}
|
}
|
||||||
MicroServiceDeleteOverrideConfiguration();
|
return BadRequest(RESTAPI::Errors::NotImplemented);
|
||||||
return OK();
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace OpenWifi
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user