mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-01 11:07:46 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -54,11 +54,17 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
Authentication:
|
Authentication:
|
||||||
$ref: '#/components/schemas/RADIUSServer'
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/RADIUSServer'
|
||||||
Accounting:
|
Accounting:
|
||||||
$ref: '#/components/schemas/RADIUSServer'
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/RADIUSServer'
|
||||||
CoA:
|
CoA:
|
||||||
$ref: '#/components/schemas/RADIUSServer'
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/RADIUSServer'
|
||||||
AccountingInterval:
|
AccountingInterval:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ namespace OpenWifi {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool ValidRadiusServer(const std::vector<ProvObjects::RADIUSServer> &ServerList) {
|
||||||
|
return std::all_of(ServerList.begin(),ServerList.end(),[](const ProvObjects::RADIUSServer &Server)->bool { return ValidRadiusServer(Server); });
|
||||||
|
}
|
||||||
|
|
||||||
void RESTAPI_radius_endpoint_handler::DoPost() {
|
void RESTAPI_radius_endpoint_handler::DoPost() {
|
||||||
auto id = GetBinding("id");
|
auto id = GetBinding("id");
|
||||||
if(id.empty()) {
|
if(id.empty()) {
|
||||||
|
|||||||
@@ -860,9 +860,9 @@ namespace OpenWifi::ProvObjects {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct RADIUSEndPointRadiusType {
|
struct RADIUSEndPointRadiusType {
|
||||||
RADIUSServer Authentication;
|
std::vector<RADIUSServer> Authentication;
|
||||||
RADIUSServer Accounting;
|
std::vector<RADIUSServer> Accounting;
|
||||||
RADIUSServer CoA;
|
std::vector<RADIUSServer> CoA;
|
||||||
std::uint64_t AccountingInterval = 60;
|
std::uint64_t AccountingInterval = 60;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
|||||||
@@ -12,6 +12,28 @@
|
|||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RadiusEndpointUpdater {
|
class RadiusEndpointUpdater {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
void AddServers(const std::vector<ProvObjects::RADIUSServer> &ServerList, Poco::JSON::Object &O) {
|
||||||
|
O.set("methodParameters", Poco::JSON::Array());
|
||||||
|
O.set("monitor" , false);
|
||||||
|
O.set("monitorMethod", "none");
|
||||||
|
O.set("strategy", "random");
|
||||||
|
Poco::JSON::Array ServerArray;
|
||||||
|
for(const auto &server:ServerList) {
|
||||||
|
Poco::JSON::Object InnerServer;
|
||||||
|
InnerServer.set("allowSelfSigned", false);
|
||||||
|
InnerServer.set("certificate", "");
|
||||||
|
InnerServer.set("ignore", false);
|
||||||
|
InnerServer.set("ip",server.IP);
|
||||||
|
InnerServer.set("port", server.Port);
|
||||||
|
InnerServer.set("secret", server.Secret);
|
||||||
|
InnerServer.set("name", server.Hostname);
|
||||||
|
InnerServer.set("radsec", false);
|
||||||
|
ServerArray.add(InnerServer);
|
||||||
|
}
|
||||||
|
O.set("servers", ServerArray);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool UpdateEndpoints( [[maybe_unused]] std::string & Error,
|
inline bool UpdateEndpoints( [[maybe_unused]] std::string & Error,
|
||||||
[[maybe_unused]] uint64_t &ErrorNum ) {
|
[[maybe_unused]] uint64_t &ErrorNum ) {
|
||||||
|
|
||||||
@@ -45,6 +67,7 @@ namespace OpenWifi {
|
|||||||
InnerServer.set("name", fmt::format("Server {}",i));
|
InnerServer.set("name", fmt::format("Server {}",i));
|
||||||
InnerServer.set("ip", Server.Hostname);
|
InnerServer.set("ip", Server.Hostname);
|
||||||
InnerServer.set("radsecPort", Server.Port);
|
InnerServer.set("radsecPort", Server.Port);
|
||||||
|
InnerServer.set("radsec", true);
|
||||||
InnerServer.set("radsecCert", Utils::base64encode((const u_char *)OA.certificate.c_str(),OA.certificate.size()));
|
InnerServer.set("radsecCert", Utils::base64encode((const u_char *)OA.certificate.c_str(),OA.certificate.size()));
|
||||||
InnerServer.set("radsecKey", Utils::base64encode((const u_char *)OA.privateKey.c_str(),OA.privateKey.size()));
|
InnerServer.set("radsecKey", Utils::base64encode((const u_char *)OA.privateKey.c_str(),OA.privateKey.size()));
|
||||||
Poco::JSON::Array CaCerts;
|
Poco::JSON::Array CaCerts;
|
||||||
@@ -79,6 +102,7 @@ namespace OpenWifi {
|
|||||||
InnerServer.set("ignore", false);
|
InnerServer.set("ignore", false);
|
||||||
InnerServer.set("name", fmt::format("Server {}",i));
|
InnerServer.set("name", fmt::format("Server {}",i));
|
||||||
InnerServer.set("ip", Server.Hostname);
|
InnerServer.set("ip", Server.Hostname);
|
||||||
|
InnerServer.set("radsec", true);
|
||||||
InnerServer.set("radsecPort", Server.Port);
|
InnerServer.set("radsecPort", Server.Port);
|
||||||
InnerServer.set("radsecCert", Utils::base64encode((const u_char *)GRCertificate.certificate.c_str(),GRCertificate.certificate.size()));
|
InnerServer.set("radsecCert", Utils::base64encode((const u_char *)GRCertificate.certificate.c_str(),GRCertificate.certificate.size()));
|
||||||
InnerServer.set("radsecKey", Utils::base64encode((const u_char *)GRAccountInfo.CSRPrivateKey.c_str(),GRAccountInfo.CSRPrivateKey.size()));
|
InnerServer.set("radsecKey", Utils::base64encode((const u_char *)GRAccountInfo.CSRPrivateKey.c_str(),GRAccountInfo.CSRPrivateKey.size()));
|
||||||
@@ -105,6 +129,7 @@ namespace OpenWifi {
|
|||||||
InnerServer.set("ignore", false);
|
InnerServer.set("ignore", false);
|
||||||
InnerServer.set("name", fmt::format("Server {}",i));
|
InnerServer.set("name", fmt::format("Server {}",i));
|
||||||
InnerServer.set("ip", Server.Hostname);
|
InnerServer.set("ip", Server.Hostname);
|
||||||
|
InnerServer.set("radsec", true);
|
||||||
InnerServer.set("radsecPort", Server.Port);
|
InnerServer.set("radsecPort", Server.Port);
|
||||||
InnerServer.set("radsecCert", Utils::base64encode((const u_char *)Server.Certificate.c_str(), Server.Certificate.size()));
|
InnerServer.set("radsecCert", Utils::base64encode((const u_char *)Server.Certificate.c_str(), Server.Certificate.size()));
|
||||||
InnerServer.set("radsecKey", Utils::base64encode((const u_char *)Server.PrivateKey.c_str(), Server.PrivateKey.size()));
|
InnerServer.set("radsecKey", Utils::base64encode((const u_char *)Server.PrivateKey.c_str(), Server.PrivateKey.size()));
|
||||||
@@ -122,9 +147,15 @@ namespace OpenWifi {
|
|||||||
RadiusPools.add(PoolEntry);
|
RadiusPools.add(PoolEntry);
|
||||||
} else if(Endpoint.Type=="radius") {
|
} else if(Endpoint.Type=="radius") {
|
||||||
PoolEntry.set("radsecPoolType", "radius");
|
PoolEntry.set("radsecPoolType", "radius");
|
||||||
for (const auto &Server: Endpoint.RadsecServers) {
|
const auto &server = Endpoint.RadiusServers[0];
|
||||||
|
Poco::JSON::Object ServerEntry;
|
||||||
}
|
Poco::JSON::Object AcctConfig, AuthConfig, CoAConfig, InnerServer;
|
||||||
|
AddServers(server.Authentication,AuthConfig);
|
||||||
|
AddServers(server.Accounting,AcctConfig);
|
||||||
|
AddServers(server.CoA,CoAConfig);
|
||||||
|
PoolEntry.set("authConfig", AuthConfig);
|
||||||
|
PoolEntry.set("acctConfig", AcctConfig);
|
||||||
|
PoolEntry.set("coaConfig", CoAConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user