mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -5,6 +5,14 @@
|
||||
#include "RESTAPI_radius_endpoint_handler.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
static inline bool ValidEndpointTypes(const std::string &T) {
|
||||
return T=="radius" || T=="radsec";
|
||||
}
|
||||
|
||||
static inline bool ValidPoolStrategy(const std::string &T) {
|
||||
return T=="none" || T=="tandom" || T=="weighted";
|
||||
}
|
||||
|
||||
void RESTAPI_radius_endpoint_handler::DoGet() {
|
||||
auto id = GetBinding("id");
|
||||
if(id.empty()) {
|
||||
@@ -44,6 +52,19 @@ namespace OpenWifi {
|
||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||
}
|
||||
|
||||
if(!ValidEndpointTypes(NewRecord.Type)) {
|
||||
return BadRequest(RESTAPI::Errors::InvalidRadiusTypeEndpoint);
|
||||
}
|
||||
if(!ValidPoolStrategy(NewRecord.PoolStrategy)) {
|
||||
return BadRequest(RESTAPI::Errors::InvalidRadiusEndpointPoolStrategy);
|
||||
}
|
||||
if(!NewRecord.RadiusServers.empty() && !NewRecord.RadsecServers.empty()) {
|
||||
return BadRequest(RESTAPI::Errors::EndpointMustHaveOneTypeOfServers);
|
||||
}
|
||||
if(NewRecord.Index.empty()) {
|
||||
return BadRequest(RESTAPI::Errors::RadiusEndpointIndexInvalid);
|
||||
}
|
||||
|
||||
ProvObjects::CreateObjectInfo(RawObject,UserInfo_.userinfo,NewRecord.info);
|
||||
if(DB_.CreateRecord(NewRecord)) {
|
||||
RecordType AddedRecord;
|
||||
|
||||
@@ -414,10 +414,12 @@ namespace OpenWifi::RESTAPI::Errors {
|
||||
};
|
||||
|
||||
static const struct msg DefFirmwareNameExists { 1175, "Firmware name already exists." };
|
||||
|
||||
static const struct msg NotAValidECKey { 1176, "Not a valid Signing Key." };
|
||||
|
||||
static const struct msg NotAValidRadiusPoolType { 1177, "Not a valid RADIUS pool type." };
|
||||
static const struct msg InvalidRadiusTypeEndpoint { 1178, "Invalid RADIUS Server Endpoint type." };
|
||||
static const struct msg InvalidRadiusEndpointPoolStrategy { 1179, "Invalid RADIUS Server Endpoint Pool strategy." };
|
||||
static const struct msg EndpointMustHaveOneTypeOfServers { 1180, "All servers must be either RADIUS or RADSEC." };
|
||||
static const struct msg RadiusEndpointIndexInvalid { 1181, "Index must be an address between 0.0.1.1 and 0.0.2.254" };
|
||||
|
||||
static const struct msg SimulationDoesNotExist {
|
||||
7000, "Simulation Instance ID does not exist."
|
||||
|
||||
Reference in New Issue
Block a user