From ae002af9bfe2af1c8f1663afbaaeed19b2f83a77 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Sun, 20 Feb 2022 15:13:12 -0800 Subject: [PATCH] Adding signup process. --- CMakeLists.txt | 2 +- build | 2 +- openapi/userportal.yaml | 27 ++++++++++++++++++ src/RESTAPI/RESTAPI_routers.cpp | 2 ++ src/RESTAPI/RESTAPI_signup_handler.cpp | 14 ++++++++++ src/RESTAPI/RESTAPI_signup_handler.h | 38 ++++++++++++++++++++++++++ 6 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 src/RESTAPI/RESTAPI_signup_handler.cpp create mode 100644 src/RESTAPI/RESTAPI_signup_handler.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 69ebec7..cde6557 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,7 @@ add_executable(owsub src/RESTAPI/RESTAPI_wifiClients_handler.cpp src/RESTAPI/RESTAPI_wifiClients_handler.h src/RESTObjects/RESTAPI_SubObjects.cpp src/RESTObjects/RESTAPI_SubObjects.h src/RESTAPI/RESTAPI_subscriber_handler.cpp src/RESTAPI/RESTAPI_subscriber_handler.h - src/RESTAPI/RESTAPI_oauth2_handler.cpp src/RESTAPI/RESTAPI_oauth2_handler.h src/RESTAPI/RESTAPI_action_handler.cpp src/RESTAPI/RESTAPI_action_handler.h src/RESTAPI/RESTAPI_mfa_handler.cpp src/RESTAPI/RESTAPI_mfa_handler.h src/sdks/SDK_prov.cpp src/sdks/SDK_prov.h src/sdks/SDK_gw.cpp src/sdks/SDK_gw.h src/sdks/SDK_sec.cpp src/sdks/SDK_sec.h src/RESTAPI/RESTAPI_claim_handler.cpp src/RESTAPI/RESTAPI_claim_handler.h) + src/RESTAPI/RESTAPI_oauth2_handler.cpp src/RESTAPI/RESTAPI_oauth2_handler.h src/RESTAPI/RESTAPI_action_handler.cpp src/RESTAPI/RESTAPI_action_handler.h src/RESTAPI/RESTAPI_mfa_handler.cpp src/RESTAPI/RESTAPI_mfa_handler.h src/sdks/SDK_prov.cpp src/sdks/SDK_prov.h src/sdks/SDK_gw.cpp src/sdks/SDK_gw.h src/sdks/SDK_sec.cpp src/sdks/SDK_sec.h src/RESTAPI/RESTAPI_claim_handler.cpp src/RESTAPI/RESTAPI_claim_handler.h src/RESTAPI/RESTAPI_signup_handler.cpp src/RESTAPI/RESTAPI_signup_handler.h) target_link_libraries(owsub PUBLIC ${Poco_LIBRARIES} ${MySQL_LIBRARIES} diff --git a/build b/build index e440e5c..62f9457 100644 --- a/build +++ b/build @@ -1 +1 @@ -3 \ No newline at end of file +6 \ No newline at end of file diff --git a/openapi/userportal.yaml b/openapi/userportal.yaml index 668e5bd..6022e3b 100644 --- a/openapi/userportal.yaml +++ b/openapi/userportal.yaml @@ -1085,3 +1085,30 @@ paths: type: string details: type: string + + /signup: + post: + tags: + - Subscriber Registration + summary: This call allows a new subscriber to register themselves and their devices. + operationId: postSignup + parameters: + - in: query + name: email + schema: + type: string + format: email + required: true + - in: query + name: serialNumber + schema: + type: string + required: true + responses: + 200: + $ref: '#/components/responses/Success' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/Unauthorized' + diff --git a/src/RESTAPI/RESTAPI_routers.cpp b/src/RESTAPI/RESTAPI_routers.cpp index 4054085..4ef3f1c 100644 --- a/src/RESTAPI/RESTAPI_routers.cpp +++ b/src/RESTAPI/RESTAPI_routers.cpp @@ -10,6 +10,7 @@ #include "RESTAPI/RESTAPI_action_handler.h" #include "RESTAPI/RESTAPI_mfa_handler.h" #include "RESTAPI/RESTAPI_claim_handler.h" +#include "RESTAPI/RESTAPI_signup_handler.h" namespace OpenWifi { @@ -23,6 +24,7 @@ namespace OpenWifi { RESTAPI_action_handler, RESTAPI_mfa_handler, RESTAPI_claim_handler, + RESTAPI_signup_handler, RESTAPI_system_command>(Path, Bindings, L, S, TransactionId); } diff --git a/src/RESTAPI/RESTAPI_signup_handler.cpp b/src/RESTAPI/RESTAPI_signup_handler.cpp new file mode 100644 index 0000000..8ffdc9b --- /dev/null +++ b/src/RESTAPI/RESTAPI_signup_handler.cpp @@ -0,0 +1,14 @@ +// +// Created by stephane bourque on 2022-02-20. +// + +#include "RESTAPI_signup_handler.h" +#include "framework/API_Proxy.h" + +namespace OpenWifi { + + void RESTAPI_signup_handler::DoPost() { + API_Proxy(Logger_, Request, Response, OpenWifi::uSERVICE_SECURITY.c_str(),"/api/v1/signup"); + } + +} \ No newline at end of file diff --git a/src/RESTAPI/RESTAPI_signup_handler.h b/src/RESTAPI/RESTAPI_signup_handler.h new file mode 100644 index 0000000..44f9894 --- /dev/null +++ b/src/RESTAPI/RESTAPI_signup_handler.h @@ -0,0 +1,38 @@ +// +// Created by stephane bourque on 2022-02-20. +// + +#pragma once + +#include "framework/MicroService.h" + +namespace OpenWifi { + class RESTAPI_signup_handler : public RESTAPIHandler { + public: + RESTAPI_signup_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal) + : RESTAPIHandler(bindings, L, + std::vector{ + Poco::Net::HTTPRequest::HTTP_POST, + Poco::Net::HTTPRequest::HTTP_OPTIONS}, + Server, + TransactionId, + Internal, false, true ){} + + static const std::list PathName() { return std::list{"/api/v1/action"}; }; + +/* inline bool RoleIsAuthorized(std::string & Reason) { + if(UserInfo_.userinfo.userRole != SecurityObjects::USER_ROLE::SUBSCRIBER) { + Reason = "User must be a subscriber"; + return false; + } + return true; + } +*/ + void DoGet() final {}; + void DoPost() final; + void DoPut() final {}; + void DoDelete() final {}; + private: + + }; +}