stephb9959
2023-09-27 23:07:58 -07:00
parent 8e07eeb000
commit dfc97ee8f9
2 changed files with 25 additions and 2 deletions

View File

@@ -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;

View File

@@ -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."