Loading src/auth.cpp +22 −19 Changes for src/auth.cpp: 22 added lines, 19 removed lines. Original line number Diff line number Diff line Loading @@ -166,6 +166,26 @@ void blogi::Auth::Apilogin(const int tid,const char *username,const char *passwo } } bool blogi::Auth::isLoggedIn(const int tid,const uuid::uuid &authid){ authdb::client::ClientConnection authcon; authcon.setUrl( _config.getAuthUrl()); authcon.setClientName(_config.getClientName()); authcon.setClientSecret(_config.getClientSecret()); authcon.setSessionID(authid); std::unique_ptr<authdb::client::Client>clt; try{ clt=std::make_unique<authdb::client::Client>(authcon); }catch(...){ authcon.reConnect(); clt=std::make_unique<authdb::client::Client>(authcon); } if(clt->ClientAuth() && clt->GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6")){ return true; } return false; } bool blogi::Auth::isLoggedIn(const int tid,libhttppp::HttpRequest &curreq,const std::string &ssid){ try{ Loading @@ -183,25 +203,8 @@ bool blogi::Auth::isLoggedIn(const int tid,libhttppp::HttpRequest &curreq,const if(sessid.empty()) return false; authdb::client::ClientConnection authcon; authcon.setUrl( _config.getAuthUrl()); authcon.setClientName(_config.getClientName()); authcon.setClientSecret(_config.getClientSecret()); authcon.setSessionID(sessid); std::unique_ptr<authdb::client::Client>clt; try{ clt=std::make_unique<authdb::client::Client>(authcon); return isLoggedIn(tid,sessid); }catch(...){ authcon.reConnect(); clt=std::make_unique<authdb::client::Client>(authcon); } if(clt->ClientAuth() && clt->GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6")){ return true; } }catch(...){}; return false; } } src/auth.h +1 −0 Changes for src/auth.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ namespace blogi { ~Auth(); void login(const int tid,const char *username,const char *password,uuid::uuid &authid,const std::string &ssid); void Apilogin(const int tid,const char *username,const char *password,uuid::uuid &authid); bool isLoggedIn(const int tid,const uuid::uuid &authid); bool isLoggedIn(const int tid,libhttppp::HttpRequest &curreq,const std::string &ssid); private: std::vector<std::unique_ptr<dbpp::Database>> &_dbconn; Loading src/blogi.cpp +32 −13 Changes for src/blogi.cpp: 32 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -190,6 +190,7 @@ void blogi::Blogi::api(libhttppp::HttpRequest& curreq, const int tid){ return; } bool asuccess = false; std::vector<char> content; // Copy only the content length number of bytes std::copy(curreq.RecvData.begin(), curreq.RecvData.begin() + clen, std::back_inserter(content)); Loading Loading @@ -258,7 +259,7 @@ void blogi::Blogi::api(libhttppp::HttpRequest& curreq, const int tid){ json_object* jsuccess = json_object_new_object(); json_object_object_add(jsuccess, "authid", json_object_new_string(aid.c_str())); json_object_object_add(respid, "login_success", jsuccess); asuccess=true; } catch (libhttppp::HTTPException &e) { // Failure response (e.g., invalid credentials, GPO check failed) json_object* jfail = json_object_new_object(); Loading @@ -279,19 +280,22 @@ void blogi::Blogi::api(libhttppp::HttpRequest& curreq, const int tid){ } } else if (strcmp(key, "auth") == 0) { // --- AUTH CHECK COMMAND (Placeholder for existing authid status check) --- // This block is based on the original snippet's intent to check an existing auth ID. // In a full implementation, you would check if the session is still valid. // --- AUTH CHECK COMMAND (Check for existing authid validity) --- json_object* value_obj = json_object_new_object(); // Assuming `val` contains the auth ID string or an object with the ID. const char* id = json_object_get_string(val); // Simplified extraction const char* id = json_object_get_string(val); // Placeholder: Assume success for GPO status check if(id && PlgArgs->auth->isLoggedIn(tid,id)){ // Success asuccess=true; json_object_object_add(value_obj, "authid", json_object_new_string(id)); json_object_object_add(value_obj, "gpo_status", json_object_new_string("active")); json_object_object_add(respid, "gpo", value_obj); json_object_object_add(value_obj, "is_valid", json_object_new_boolean(1)); json_object_object_add(respid, "auth_success", value_obj); } else { // Failure json_object_object_add(value_obj, "authid", json_object_new_string(id ? id : "")); json_object_object_add(value_obj, "is_valid", json_object_new_boolean(0)); json_object_object_add(respid, "auth_failure", value_obj); } } // Add the response for this specific command to the response array Loading @@ -306,11 +310,26 @@ void blogi::Blogi::api(libhttppp::HttpRequest& curreq, const int tid){ size_t outsize = 0; const char* out = json_object_to_json_string_length(jresponse, 0, &outsize); resp.setContentType("application/json"); // Correct Content-Type for API resp.setContentType("application/json"); if (!asuccess && fcount > 0) { resp.setState(HTTP401); resp.send(curreq, out, outsize); json_object_put(jresponse); json_object_put(jrequest); return; } testedit.JsonApi(tid,jrequest,jresponse,aid); for(const blogi::Plugin::PluginData *curplg=BlogiPlg->getFirstPlugin(); curplg; curplg=curplg->getNextPlg()){ curplg->getInstace()->JsonApi(tid,jrequest,jresponse,aid); } resp.setState(HTTP200); resp.send(curreq, out, outsize); // 5. Cleanup json_object_put(jresponse); json_object_put(jrequest); } Loading src/webedit/edit.cpp +4 −0 Changes for src/webedit/edit.cpp: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -53,6 +53,10 @@ void blogi::webedit::WebEditor::Editor(PluginArgs &plgars,libhttppp::HttpRequest curres.send(curreq,ouput.data(),ouput.size()); } void blogi::webedit::WebEditor::JsonApi(const int tid,json_object *request,json_object *response,const uuid::uuid &authid){ } void blogi::webedit::WebEditor::Renderer(PluginArgs &plgars,libhttppp::HttpRequest& curreq, const int tid, const std::string &sessionid,const libhtmlpp::HtmlElement &index){ libhtmlpp::HtmlString out; libhtmlpp::HtmlElement ridx=index; Loading src/webedit/edit.h +1 −0 Changes for src/webedit/edit.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ namespace blogi { WebEditor() = default; void Editor(PluginArgs &plgars,libhttppp::HttpRequest& curreq, const int tid, const std::string &sessionid); void Renderer(PluginArgs &plgars,libhttppp::HttpRequest& curreq, const int tid, const std::string &sessionid,const libhtmlpp::HtmlElement &index); void JsonApi(const int tid,json_object *request,json_object *response,const uuid::uuid &authid); private: tinyxml2::XMLDocument CurDoc; tinyxml2::XMLElement *CurRootEl=nullptr; Loading Loading
src/auth.cpp +22 −19 Changes for src/auth.cpp: 22 added lines, 19 removed lines. Original line number Diff line number Diff line Loading @@ -166,6 +166,26 @@ void blogi::Auth::Apilogin(const int tid,const char *username,const char *passwo } } bool blogi::Auth::isLoggedIn(const int tid,const uuid::uuid &authid){ authdb::client::ClientConnection authcon; authcon.setUrl( _config.getAuthUrl()); authcon.setClientName(_config.getClientName()); authcon.setClientSecret(_config.getClientSecret()); authcon.setSessionID(authid); std::unique_ptr<authdb::client::Client>clt; try{ clt=std::make_unique<authdb::client::Client>(authcon); }catch(...){ authcon.reConnect(); clt=std::make_unique<authdb::client::Client>(authcon); } if(clt->ClientAuth() && clt->GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6")){ return true; } return false; } bool blogi::Auth::isLoggedIn(const int tid,libhttppp::HttpRequest &curreq,const std::string &ssid){ try{ Loading @@ -183,25 +203,8 @@ bool blogi::Auth::isLoggedIn(const int tid,libhttppp::HttpRequest &curreq,const if(sessid.empty()) return false; authdb::client::ClientConnection authcon; authcon.setUrl( _config.getAuthUrl()); authcon.setClientName(_config.getClientName()); authcon.setClientSecret(_config.getClientSecret()); authcon.setSessionID(sessid); std::unique_ptr<authdb::client::Client>clt; try{ clt=std::make_unique<authdb::client::Client>(authcon); return isLoggedIn(tid,sessid); }catch(...){ authcon.reConnect(); clt=std::make_unique<authdb::client::Client>(authcon); } if(clt->ClientAuth() && clt->GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6")){ return true; } }catch(...){}; return false; } }
src/auth.h +1 −0 Changes for src/auth.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ namespace blogi { ~Auth(); void login(const int tid,const char *username,const char *password,uuid::uuid &authid,const std::string &ssid); void Apilogin(const int tid,const char *username,const char *password,uuid::uuid &authid); bool isLoggedIn(const int tid,const uuid::uuid &authid); bool isLoggedIn(const int tid,libhttppp::HttpRequest &curreq,const std::string &ssid); private: std::vector<std::unique_ptr<dbpp::Database>> &_dbconn; Loading
src/blogi.cpp +32 −13 Changes for src/blogi.cpp: 32 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -190,6 +190,7 @@ void blogi::Blogi::api(libhttppp::HttpRequest& curreq, const int tid){ return; } bool asuccess = false; std::vector<char> content; // Copy only the content length number of bytes std::copy(curreq.RecvData.begin(), curreq.RecvData.begin() + clen, std::back_inserter(content)); Loading Loading @@ -258,7 +259,7 @@ void blogi::Blogi::api(libhttppp::HttpRequest& curreq, const int tid){ json_object* jsuccess = json_object_new_object(); json_object_object_add(jsuccess, "authid", json_object_new_string(aid.c_str())); json_object_object_add(respid, "login_success", jsuccess); asuccess=true; } catch (libhttppp::HTTPException &e) { // Failure response (e.g., invalid credentials, GPO check failed) json_object* jfail = json_object_new_object(); Loading @@ -279,19 +280,22 @@ void blogi::Blogi::api(libhttppp::HttpRequest& curreq, const int tid){ } } else if (strcmp(key, "auth") == 0) { // --- AUTH CHECK COMMAND (Placeholder for existing authid status check) --- // This block is based on the original snippet's intent to check an existing auth ID. // In a full implementation, you would check if the session is still valid. // --- AUTH CHECK COMMAND (Check for existing authid validity) --- json_object* value_obj = json_object_new_object(); // Assuming `val` contains the auth ID string or an object with the ID. const char* id = json_object_get_string(val); // Simplified extraction const char* id = json_object_get_string(val); // Placeholder: Assume success for GPO status check if(id && PlgArgs->auth->isLoggedIn(tid,id)){ // Success asuccess=true; json_object_object_add(value_obj, "authid", json_object_new_string(id)); json_object_object_add(value_obj, "gpo_status", json_object_new_string("active")); json_object_object_add(respid, "gpo", value_obj); json_object_object_add(value_obj, "is_valid", json_object_new_boolean(1)); json_object_object_add(respid, "auth_success", value_obj); } else { // Failure json_object_object_add(value_obj, "authid", json_object_new_string(id ? id : "")); json_object_object_add(value_obj, "is_valid", json_object_new_boolean(0)); json_object_object_add(respid, "auth_failure", value_obj); } } // Add the response for this specific command to the response array Loading @@ -306,11 +310,26 @@ void blogi::Blogi::api(libhttppp::HttpRequest& curreq, const int tid){ size_t outsize = 0; const char* out = json_object_to_json_string_length(jresponse, 0, &outsize); resp.setContentType("application/json"); // Correct Content-Type for API resp.setContentType("application/json"); if (!asuccess && fcount > 0) { resp.setState(HTTP401); resp.send(curreq, out, outsize); json_object_put(jresponse); json_object_put(jrequest); return; } testedit.JsonApi(tid,jrequest,jresponse,aid); for(const blogi::Plugin::PluginData *curplg=BlogiPlg->getFirstPlugin(); curplg; curplg=curplg->getNextPlg()){ curplg->getInstace()->JsonApi(tid,jrequest,jresponse,aid); } resp.setState(HTTP200); resp.send(curreq, out, outsize); // 5. Cleanup json_object_put(jresponse); json_object_put(jrequest); } Loading
src/webedit/edit.cpp +4 −0 Changes for src/webedit/edit.cpp: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -53,6 +53,10 @@ void blogi::webedit::WebEditor::Editor(PluginArgs &plgars,libhttppp::HttpRequest curres.send(curreq,ouput.data(),ouput.size()); } void blogi::webedit::WebEditor::JsonApi(const int tid,json_object *request,json_object *response,const uuid::uuid &authid){ } void blogi::webedit::WebEditor::Renderer(PluginArgs &plgars,libhttppp::HttpRequest& curreq, const int tid, const std::string &sessionid,const libhtmlpp::HtmlElement &index){ libhtmlpp::HtmlString out; libhtmlpp::HtmlElement ridx=index; Loading
src/webedit/edit.h +1 −0 Changes for src/webedit/edit.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ namespace blogi { WebEditor() = default; void Editor(PluginArgs &plgars,libhttppp::HttpRequest& curreq, const int tid, const std::string &sessionid); void Renderer(PluginArgs &plgars,libhttppp::HttpRequest& curreq, const int tid, const std::string &sessionid,const libhtmlpp::HtmlElement &index); void JsonApi(const int tid,json_object *request,json_object *response,const uuid::uuid &authid); private: tinyxml2::XMLDocument CurDoc; tinyxml2::XMLElement *CurRootEl=nullptr; Loading