diff --git a/build b/build index 9d60796..ca7bf83 100644 --- a/build +++ b/build @@ -1 +1 @@ -11 \ No newline at end of file +13 \ No newline at end of file diff --git a/src/RESTAPI_handler.cpp b/src/RESTAPI_handler.cpp index 2c3d3ec..a68b4b8 100644 --- a/src/RESTAPI_handler.cpp +++ b/src/RESTAPI_handler.cpp @@ -38,7 +38,7 @@ namespace OpenWifi { if (!ContinueProcessing()) return; - if (!IsAuthorized()) + if (AlwaysAuthorize_ && !IsAuthorized()) return; ParseParameters(); @@ -55,8 +55,7 @@ namespace OpenWifi { } const Poco::JSON::Object::Ptr &RESTAPIHandler::ParseStream() { - Poco::JSON::Parser IncomingParser; - return IncomingParser.parse(Request->stream()).extract(); + return IncomingParser_.parse(Request->stream()).extract(); } bool RESTAPIHandler::ParseBindings(const std::string & Request, const std::list & EndPoints, BindingMap &bindings) { diff --git a/src/RESTAPI_handler.h b/src/RESTAPI_handler.h index 996b727..d348735 100644 --- a/src/RESTAPI_handler.h +++ b/src/RESTAPI_handler.h @@ -92,8 +92,8 @@ namespace OpenWifi { typedef std::map BindingMap; - RESTAPIHandler(BindingMap map, Poco::Logger &l, std::vector Methods, bool Internal=false) - : Bindings_(std::move(map)), Logger_(l), Methods_(std::move(Methods)), Internal_(Internal) {} + RESTAPIHandler(BindingMap map, Poco::Logger &l, std::vector Methods, bool Internal=false, bool AlwaysAuthorize=true) + : Bindings_(std::move(map)), Logger_(l), Methods_(std::move(Methods)), Internal_(Internal), AlwaysAuthorize_(AlwaysAuthorize) {} static bool ParseBindings(const std::string & Request, const std::list & EndPoints, BindingMap &Keys); void PrintBindings(); @@ -171,6 +171,8 @@ namespace OpenWifi { bool QueryBlockInitialized_=false; Poco::Net::HTTPServerRequest *Request= nullptr; Poco::Net::HTTPServerResponse *Response= nullptr; + bool AlwaysAuthorize_=true; + Poco::JSON::Parser IncomingParser_; }; class RESTAPI_UnknownRequestHandler : public RESTAPIHandler {