Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-12954
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Sep 28, 2023
1 parent e71b83c commit 3ed97e6
Show file tree
Hide file tree
Showing 16 changed files with 1,609 additions and 758 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,14 @@ add_executable(owprov
src/ProvWebSocketClient.cpp src/ProvWebSocketClient.h
src/Tasks/VenueRebooter.h src/Tasks/VenueUpgrade.h
src/sdks/SDK_fms.cpp src/sdks/SDK_fms.h
src/RESTAPI/RESTAPI_overrides_handler.cpp src/RESTAPI/RESTAPI_overrides_handler.h src/OpenRoamin_GlobalReach.cpp src/OpenRoamin_GlobalReach.h src/storage/storage_glblraccounts.cpp src/storage/storage_glblraccounts.h src/storage/storage_glblrcerts.cpp src/storage/storage_glblrcerts.h src/RESTAPI/RESTAPI_openroaming_gr_list_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_gr_list_acct_handler.h src/RESTAPI/RESTAPI_openroaming_gr_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_gr_acct_handler.h src/RESTAPI/RESTAPI_openroaming_gr_list_certificates.cpp src/RESTAPI/RESTAPI_openroaming_gr_list_certificates.h src/RESTAPI/RESTAPI_openroaming_gr_cert_handler.cpp src/RESTAPI/RESTAPI_openroaming_gr_cert_handler.h src/RESTAPI/RESTAPI_openroaming_orion_list_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_orion_list_acct_handler.h src/RESTAPI/RESTAPI_openroaming_orion_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_orion_acct_handler.h src/storage/storage_orion_accounts.cpp src/storage/storage_orion_accounts.h)
src/RESTAPI/RESTAPI_overrides_handler.cpp src/RESTAPI/RESTAPI_overrides_handler.h src/OpenRoamin_GlobalReach.cpp src/OpenRoamin_GlobalReach.h src/storage/storage_glblraccounts.cpp src/storage/storage_glblraccounts.h src/storage/storage_glblrcerts.cpp src/storage/storage_glblrcerts.h src/RESTAPI/RESTAPI_openroaming_gr_list_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_gr_list_acct_handler.h src/RESTAPI/RESTAPI_openroaming_gr_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_gr_acct_handler.h src/RESTAPI/RESTAPI_openroaming_gr_list_certificates.cpp src/RESTAPI/RESTAPI_openroaming_gr_list_certificates.h src/RESTAPI/RESTAPI_openroaming_gr_cert_handler.cpp src/RESTAPI/RESTAPI_openroaming_gr_cert_handler.h src/RESTAPI/RESTAPI_openroaming_orion_list_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_orion_list_acct_handler.h src/RESTAPI/RESTAPI_openroaming_orion_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_orion_acct_handler.h src/storage/storage_orion_accounts.cpp src/storage/storage_orion_accounts.h
src/storage/storage_radius_endpoints.cpp
src/storage/storage_radius_endpoints.h
src/RESTAPI/RESTAPI_radiusendpoint_list_handler.cpp
src/RESTAPI/RESTAPI_radiusendpoint_list_handler.h
src/RESTAPI/RESTAPI_radius_endpoint_handler.cpp
src/RESTAPI/RESTAPI_radius_endpoint_handler.h
)

target_link_libraries(owprov PUBLIC
${Poco_LIBRARIES}
Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
32
44
284 changes: 284 additions & 0 deletions openapi/radius_tunnels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
openapi: 3.0.1
info:
title: OpenWiFi RADIUS Resource Model
description: Definitions and APIs to manage RADIUS Resources.
version: 1.0.0
license:
name: BSD3
url: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE

servers:
- url: 'https://localhost:16005/api/v1'

security:
- bearerAuth: []
- ApiKeyAuth: []

components:
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-API-KEY
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT

responses:
NotFound:
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/NotFound'
Unauthorized:
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Unauthorized'
Success:
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Success'
BadRequest:
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/BadRequest'

schemas:

RADIUSServer:
type: object
properties:
Hostname:
type: string
IP:
type: string
Port:
type: integer
format: int32
Secret:
type: string

RADIUSEndPointRadiusType:
type: object
properties:
Authentication:
$ref: '#/components/schemas/RADIUSServer'
Accounting:
$ref: '#/components/schemas/RADIUSServer'
CoA:
$ref: '#/components/schemas/RADIUSServer'
AccountingInterval:
type: integer
format: int32

RADIUSEndPointRadsecType:
type: object
properties:
Hostname:
type: string
IP:
type: string
Port:
type: string
Secret:
type: string
default: radsec
UseOpenRoamingAccount:
type: string
format: uuid
Weight:
type: integer
format: int32
Certificate:
type: string
PrivateKey:
type: string
CaCerts:
type: array
items:
type: string
AllowSelfSigned:
type: boolean
default: false
PoolType:
type: string
enum:
- globalreach
- orion
- generic

RADIUSEndPoint:
type: object
properties:
allOf:
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-owprov/blob/main/openpapi/owprov.yaml#/components/schemas/ObjectInfo'
Type:
type: string
enum:
- radius
- radsec
default: radius
RadsecServers:
type: array
items:
$ref: '#/components/schemas/RADIUSEndPointRadsecType'
RadiusServers:
type: array
items:
$ref: '#/components/schemas/RADIUSEndPointRadiusType'
PoolStrategy:
type: string
enum:
- none
- weighted
- random
UseGWProxy:
type: boolean
default: true
Index:
type: string
example:
- 0.0.1.0: a ficticious IP address that should begin with 0.0. ...
UsedBy:
type: array
description: list of configuration using this endpoint
items:
type: string
format: uuid

paths:
/RADIUSEndPoints:
get:
tags:
- RADIUS Endpoints
operationId: getRADIUSEndPoints
summary: Retrieve the lists of RADIUSendPoints
parameters:
- in: query
description: Pagination start (starts at 1. If not specified, 1 is assumed)
name: offset
schema:
type: integer
required: false
- in: query
description: Maximum number of entries to return (if absent, no limit is assumed)
name: limit
schema:
type: integer
required: false
- in: query
description: return the number of certificates
name: countOnly
schema:
type: boolean
required: false
responses:
200:
description: The list of endpoints
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/RADIUSEndPoint'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'

/RADIUSEndPoint/{id}:
get:
tags:
- RADIUS Endpoints
operationId: getRADIUSEndPoint
summary: Retrieve a RADIUSendPoint
parameters:
- in: path
name: id
schema:
type: string
format: uuid
required: true
responses:
200:
description: The endpoint
content:
application/json:
schema:
$ref: '#/components/schemas/RADIUSEndPoint'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'

delete:
tags:
- RADIUS Endpoints
operationId: deleteRADIUSEndPoint
summary: Delete a RADIUSendPoint
parameters:
- in: path
name: id
schema:
type: string
format: uuid
required: true
responses:
200:
$ref: '#/components/responses/Success'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'

post:
tags:
- RADIUS Endpoints
operationId: createRADIUSEndPoint
summary: Create a RADIUSendPoint
parameters:
- in: path
name: id
schema:
type: string
format: uuid
required: true
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RADIUSEndPoint'
responses:
200:
$ref: '#/components/schemas/RADIUSEndPoint'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'

put:
tags:
- RADIUS Endpoints
operationId: modifyRADIUSEndPoint
summary: Modify a RADIUSendPoint
parameters:
- in: path
name: id
schema:
type: string
format: uuid
required: true
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RADIUSEndPoint'
responses:
200:
$ref: '#/components/schemas/RADIUSEndPoint'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
83 changes: 83 additions & 0 deletions src/RESTAPI/RESTAPI_radius_endpoint_handler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// Created by stephane bourque on 2023-09-27.
//

#include "RESTAPI_radius_endpoint_handler.h"

namespace OpenWifi {
void RESTAPI_radius_endpoint_handler::DoGet() {
auto id = GetBinding("id");
if(id.empty()) {
return BadRequest(RESTAPI::Errors::MissingAuthenticationInformation);
}

RecordType Record;
if(DB_.GetRecord("id",id,Record)) {
return ReturnObject(Record);
}

return NotFound();
}

void RESTAPI_radius_endpoint_handler::DoDelete() {
auto id = GetBinding("id");
if(id.empty()) {
return BadRequest(RESTAPI::Errors::MissingAuthenticationInformation);
}
RecordType Record;
if(DB_.GetRecord("id",id,Record)) {
DB_.DeleteRecord("id",id);
return OK();
}
return NotFound();
}

void RESTAPI_radius_endpoint_handler::DoPost() {
auto id = GetBinding("id");
if(id.empty()) {
return BadRequest(RESTAPI::Errors::MissingAuthenticationInformation);
}

const auto &RawObject = ParsedBody_;
RecordType NewRecord;
if(!NewRecord.from_json(RawObject)) {
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
}

ProvObjects::CreateObjectInfo(RawObject,UserInfo_.userinfo,NewRecord.info);
if(DB_.CreateRecord(NewRecord)) {
RecordType AddedRecord;
DB_.GetRecord("id", NewRecord.info.id, AddedRecord);
return ReturnObject(AddedRecord);
}
return BadRequest(RESTAPI::Errors::RecordNotCreated);
}

void RESTAPI_radius_endpoint_handler::DoPut() {
auto id = GetBinding("id");
if(id.empty()) {
return BadRequest(RESTAPI::Errors::MissingAuthenticationInformation);
}

const auto &RawObject = ParsedBody_;
RecordType ModifiedRecord;
if(!ModifiedRecord.from_json(RawObject)) {
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
}

RecordType Existing;
if(!DB_.GetRecord("id",id,Existing)) {
return NotFound();
}

ProvObjects::UpdateObjectInfo(RawObject, UserInfo_.userinfo, Existing.info);
if(DB_.UpdateRecord("id", Existing.info.id, Existing)) {
RecordType AddedRecord;
DB_.GetRecord("id", Existing.info.id, AddedRecord);
return ReturnObject(AddedRecord);
}

return BadRequest(RESTAPI::Errors::NotImplemented);
}

} // OpenWifi
Loading

0 comments on commit 3ed97e6

Please sign in to comment.