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;