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:
@@ -227,8 +227,8 @@ add_executable(owprov
|
||||
src/RESTAPI/RESTAPI_radius_endpoint_handler.h
|
||||
src/RadiusEndpointTypes/GlobalReach.cpp src/RadiusEndpointTypes/GlobalReach.h
|
||||
src/RadiusEndpointTypes/OrionWifi.h
|
||||
src/RadiusEndpoint.cpp
|
||||
src/RadiusEndpoint.h
|
||||
src/RadiusEndpointUpdater.cpp
|
||||
src/RadiusEndpointUpdater.h
|
||||
)
|
||||
|
||||
target_link_libraries(owprov PUBLIC
|
||||
|
||||
@@ -165,15 +165,58 @@ paths:
|
||||
schema:
|
||||
type: boolean
|
||||
required: false
|
||||
- in: query
|
||||
description: return the last update time
|
||||
name: lastUpdate
|
||||
schema:
|
||||
type: boolean
|
||||
required: false
|
||||
responses:
|
||||
200:
|
||||
description: The list of endpoints
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
oneOf:
|
||||
- type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/RADIUSEndPoint'
|
||||
- type: object
|
||||
properties:
|
||||
lastUpdate:
|
||||
type: integer
|
||||
format: int64
|
||||
400:
|
||||
$ref: '#/components/responses/BadRequest'
|
||||
403:
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
404:
|
||||
$ref: '#/components/responses/NotFound'
|
||||
|
||||
put:
|
||||
tags:
|
||||
- RADIUS Endpoints
|
||||
operationId: updateRADIUSEndpoints
|
||||
summary: Force an Update to teh RADIUSendPoints in the controller
|
||||
parameters:
|
||||
- in: query
|
||||
name: updateEndpoints
|
||||
schema:
|
||||
type: boolean
|
||||
required: false
|
||||
responses:
|
||||
200:
|
||||
description: The list of endpoints
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
Error:
|
||||
type: string
|
||||
ErrorNum:
|
||||
type: integer
|
||||
$ref: '#/components/responses/Success'
|
||||
400:
|
||||
$ref: '#/components/responses/BadRequest'
|
||||
403:
|
||||
|
||||
@@ -59,26 +59,19 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
bool APConfig::InsertRadiusEndPoint(const ProvObjects::RADIUSEndPoint &RE, Poco::JSON::Object &Result) {
|
||||
DBGLINE
|
||||
if(RE.UseGWProxy) {
|
||||
DBGLINE
|
||||
Poco::JSON::Object ServerSettings;
|
||||
if (RE.Type == "orion") {
|
||||
DBGLINE
|
||||
return OpenRoaming_Orion()->Render(RE, Result);
|
||||
} else if (RE.Type == "globalreach") {
|
||||
DBGLINE
|
||||
return OpenRoaming_GlobalReach()->Render(RE, Result);
|
||||
} else if (RE.Type == "radsec") {
|
||||
DBGLINE
|
||||
|
||||
} else if (RE.Type == "radius") {
|
||||
DBGLINE
|
||||
|
||||
}
|
||||
Result.set( "radius" , ServerSettings);
|
||||
}
|
||||
DBGLINE
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -87,7 +80,6 @@ namespace OpenWifi {
|
||||
// get all the names and expand
|
||||
auto Names = Original.getNames();
|
||||
for (const auto &i : Names) {
|
||||
DBGLINE
|
||||
if (i == "__variableBlock") {
|
||||
if (Original.isArray(i)) {
|
||||
auto UUIDs = Original.getArray(i);
|
||||
@@ -101,13 +93,14 @@ namespace OpenWifi {
|
||||
auto VarNames = VariableBlockInfo->getNames();
|
||||
for (const auto &j: VarNames) {
|
||||
std::cout << "Name: " << j << std::endl;
|
||||
Poco::JSON::Object InnerEval;
|
||||
if(VariableBlockInfo->isArray(j)) {
|
||||
auto Arr = VariableBlockInfo->getArray(j);
|
||||
// ReplaceVariablesInObject(,InnerEval);
|
||||
// Result->set(j, InnerEval);
|
||||
auto Elements = VariableBlockInfo->getArray(j);
|
||||
Poco::JSON::Array InnerArray;
|
||||
ReplaceVariablesInArray(*Elements,InnerArray);
|
||||
Result.set(j,InnerArray);
|
||||
std::cout << "Array!!!" << std::endl;
|
||||
} else if(VariableBlockInfo->isObject(j)) {
|
||||
Poco::JSON::Object InnerEval;
|
||||
std::cout << "Visiting object " << j << std::endl;
|
||||
auto O = VariableBlockInfo->getObject(j);
|
||||
ReplaceVariablesInObject(*O,InnerEval);
|
||||
@@ -121,40 +114,27 @@ namespace OpenWifi {
|
||||
}
|
||||
}
|
||||
} else if (i == "__radiusEndpoint") {
|
||||
DBGLINE
|
||||
auto EndPointId = Original.get(i).toString();
|
||||
DBGLINE
|
||||
ProvObjects::RADIUSEndPoint RE;
|
||||
DBGLINE
|
||||
std::cout << "ID->" << EndPointId << std::endl;
|
||||
if(StorageService()->RadiusEndpointDB().GetRecord("id",EndPointId,RE)) {
|
||||
DBGLINE
|
||||
InsertRadiusEndPoint(RE, Result);
|
||||
DBGLINE
|
||||
} else {
|
||||
DBGLINE
|
||||
poco_error(Logger_, fmt::format("RADIUS Endpoint {} could not be found. Please delete this configuration and recreate it."));
|
||||
return false;
|
||||
}
|
||||
DBGLINE
|
||||
} else if (Original.isArray(i)) {
|
||||
DBGLINE
|
||||
Poco::JSON::Array Arr;
|
||||
auto Obj = Original.getArray(i);
|
||||
ReplaceVariablesInArray(*Obj, Arr);
|
||||
Result.set(i, Arr);
|
||||
DBGLINE
|
||||
} else if (Original.isObject(i)) {
|
||||
DBGLINE
|
||||
Poco::JSON::Object Expanded;
|
||||
auto Obj = Original.getObject(i);
|
||||
ReplaceVariablesInObject(*Obj, Expanded);
|
||||
Result.set(i, Expanded);
|
||||
DBGLINE
|
||||
} else {
|
||||
DBGLINE
|
||||
Result.set(i, Original.get(i));
|
||||
DBGLINE
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -12,6 +12,17 @@ namespace OpenWifi {
|
||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||
}
|
||||
|
||||
if(Account=="*") {
|
||||
std::vector< ProvObjects::GLBLRCertificateInfo> Arr;
|
||||
for(const auto &cert:QB_.Select) {
|
||||
ProvObjects::GLBLRCertificateInfo CInfo;
|
||||
if(StorageService()->GLBLRCertsDB().GetRecord("id",cert,CInfo)) {
|
||||
Arr.emplace_back(CInfo);
|
||||
}
|
||||
}
|
||||
return ReturnObject(Arr);
|
||||
}
|
||||
|
||||
auto Where = fmt::format(" accountId='{}'", Account);
|
||||
if(GetBoolParameter("countOnly")) {
|
||||
return ReturnCountOnly(DB_.Count(Where));
|
||||
|
||||
@@ -3,10 +3,20 @@
|
||||
//
|
||||
|
||||
#include "RESTAPI_radiusendpoint_list_handler.h"
|
||||
#include "framework/AppServiceRegistry.h"
|
||||
#include "RadiusEndpointUpdater.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
void RESTAPI_radiusendpoint_list_handler::DoGet() {
|
||||
if(GetBoolParameter("lastUpdate")) {
|
||||
uint64_t LastUpdate=0;
|
||||
AppServiceRegistry().Get("radiusEndpointLastUpdate", LastUpdate);
|
||||
Poco::JSON::Object Answer;
|
||||
Answer.set("lastUpdate",LastUpdate);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
|
||||
if(QB_.CountOnly) {
|
||||
return ReturnCountOnly(DB_.Count());
|
||||
}
|
||||
@@ -15,4 +25,25 @@ namespace OpenWifi {
|
||||
return ReturnObject(Records);
|
||||
}
|
||||
|
||||
void RESTAPI_radiusendpoint_list_handler::DoPut() {
|
||||
if( UserInfo_.userinfo.userRole!=SecurityObjects::ROOT &&
|
||||
UserInfo_.userinfo.userRole!=SecurityObjects::ADMIN) {
|
||||
return BadRequest(RESTAPI::Errors::ACCESS_DENIED);
|
||||
}
|
||||
|
||||
if(GetBoolParameter("updateEndpoints")) {
|
||||
RadiusEndpointUpdater R;
|
||||
|
||||
std::string Error;
|
||||
uint64_t ErrorNum = 0;
|
||||
R.UpdateEndpoints(Error, ErrorNum);
|
||||
|
||||
Poco::JSON::Object Answer;
|
||||
Answer.set("Error", Error);
|
||||
Answer.set("ErrorNum", ErrorNum);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
return BadRequest(RESTAPI::Errors::MissingAuthenticationInformation);
|
||||
}
|
||||
|
||||
} // OpenWifi
|
||||
@@ -14,6 +14,7 @@ namespace OpenWifi {
|
||||
bool Internal)
|
||||
: RESTAPIHandler(bindings, L,
|
||||
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
|
||||
Poco::Net::HTTPRequest::HTTP_PUT,
|
||||
Poco::Net::HTTPRequest::HTTP_OPTIONS},
|
||||
Server, TransactionId, Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/RADIUSEndPoints"}; };
|
||||
@@ -23,7 +24,7 @@ namespace OpenWifi {
|
||||
RadiusEndpointDB &DB_ = StorageService()->RadiusEndpointDB();
|
||||
void DoGet() final;
|
||||
void DoPost() final{};
|
||||
void DoPut() final{};
|
||||
void DoPut() final;
|
||||
void DoDelete() final{};
|
||||
};
|
||||
} // namespace OpenWifi
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
//
|
||||
// Created by stephane bourque on 2023-10-02.
|
||||
//
|
||||
|
||||
#include "RadiusEndpoint.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
} // OpenWifi
|
||||
5
src/RadiusEndpointUpdater.cpp
Normal file
5
src/RadiusEndpointUpdater.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by stephane bourque on 2023-10-02.
|
||||
//
|
||||
|
||||
#include "RadiusEndpointUpdater.h"
|
||||
@@ -2,8 +2,9 @@
|
||||
// Created by stephane bourque on 2023-10-02.
|
||||
//
|
||||
|
||||
#ifndef OWPROV_RADIUSENDPOINT_H
|
||||
#define OWPROV_RADIUSENDPOINT_H
|
||||
#pragma once
|
||||
#include <framework/AppServiceRegistry.h>
|
||||
#include <framework/utils.h>
|
||||
|
||||
/*
|
||||
|
||||
@@ -110,12 +111,18 @@
|
||||
|
||||
|
||||
*/
|
||||
namespace OpenWifi {
|
||||
#include <string>
|
||||
|
||||
class RadiusEndpoint {
|
||||
namespace OpenWifi {
|
||||
class RadiusEndpointUpdater {
|
||||
public:
|
||||
inline bool UpdateEndpoints( [[maybe_unused]] std::string & Error,
|
||||
[[maybe_unused]] uint64_t &ErrorNum ) {
|
||||
|
||||
AppServiceRegistry().Set("radiusEndpointLastUpdate", Utils::Now());
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} // OpenWifi
|
||||
|
||||
#endif //OWPROV_RADIUSENDPOINT_H
|
||||
Reference in New Issue
Block a user