Loading api/addcon.json +1 −1 Changes for api/addcon.json: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ "usersession" : "$usersession", "addconnection" : { "clientname" : "dibsi", "clientpassword" : "$clientpassword" "clientsecret" : "$clientpassword" } } ] Loading api/remcon.json +1 −1 Changes for api/remcon.json: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ { "usersession" : "$usersession", "removeconnection" : { "clientname" : "dibsi" "clientid" : "$clientid" } } ] Loading client/client.cpp +27 −0 Changes for client/client.cpp: 27 added lines, 0 removed lines. Original line number Diff line number Diff line /******************************************************************************* * Copyright (c) 2025, Jan Koester jan.koester@gmx.net * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the <organization> nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ client/client.h +67 −0 Changes for client/client.h: 67 added lines, 0 removed lines. Original line number Diff line number Diff line /******************************************************************************* * Copyright (c) 2025, Jan Koester jan.koester@gmx.net * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the <organization> nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include <uuid/uuid.h> #pragma once namespace authdb { class ClientConnection { public: void setUrl(const char *url); void setClientname(const char *name); void setClientSecret(const char *secret); void setUsername(const char *username); void setUserPassword(const char *password); private: std::string _Url; std::string _CltName; std::string _CltSecret; std::string _UserName; std::string _UserPassword; Socket Socket; uuid _SessionID; uuid _ClientId; friend class Client; }; class Client { public: void Client(ClientConnection &clt); bool UserAuth(); bool ClientAuth(); void addConnection(const std::string &clientname,const &std::string cltsecret); void remConnection(const std::string &clientname); bool checkConnection(const std::string &clientname); bool checkGPO(uuid gpoid,const SessionData &sdat); private: ClientConnection _Con; }; }; src/api.cpp +41 −2 Changes for src/api.cpp: 41 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -288,14 +288,53 @@ namespace authdb { for(int i =0; i<fcount; ++i) { json_object_object_foreach(json_object_array_get_idx(cmd,i), key, val) { if(strcmp(key,"addconnection")==0){ std::string clientname,clientsecret; int ocount = json_object_object_length(val); for(int ii =0; ii<ocount; ++ii) { json_object_object_foreach(val,okey,oval){ if(strcmp(okey,"clientname")==0){ clientname=json_object_get_string(oval); }else if( strcmp(okey,"clientsecret")==0){ clientsecret=json_object_get_string(oval); } } if(!clientname.empty() && !clientsecret.empty()){ uuid gpid; gpid.generate(); }else if(strcmp(key,"remconnection")==0){ class ClientData cdat(gpid); cdat.setName(clientname.c_str()); cdat.setKey(clientsecret.c_str()); class Client clt; clt.create(_Backend,&cdat); json_object *respid=json_object_new_object(); json_object_object_add(respid,"addclient",json_object_new_string(gpid.c_str())); json_object_array_add(response,respid); } } }else if(strcmp(key,"remconnection")==0){ uuid clientid; int ocount = json_object_object_length(val); for(int ii =0; ii<ocount; ++ii) { json_object_object_foreach(val,okey,oval){ if(strcmp(okey,"clientid")==0){ clientid.parse(json_object_get_string(oval)); } } if(!clientid.empty()){ class Client clt; clt.remove(_Backend,clientid); json_object *respid=json_object_new_object(); json_object_object_add(respid,"remclient",json_object_new_string(clientid.c_str())); json_object_array_add(response,respid); } } } } } } Api(AuthBackend &admin,class uuid did, libhttppp::HttpRequest* curreq, const int tid, ULONG_PTR args) : _Backend(admin), _Did(did){ _SessionData=nullptr; Loading Loading
api/addcon.json +1 −1 Changes for api/addcon.json: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ "usersession" : "$usersession", "addconnection" : { "clientname" : "dibsi", "clientpassword" : "$clientpassword" "clientsecret" : "$clientpassword" } } ] Loading
api/remcon.json +1 −1 Changes for api/remcon.json: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ { "usersession" : "$usersession", "removeconnection" : { "clientname" : "dibsi" "clientid" : "$clientid" } } ] Loading
client/client.cpp +27 −0 Changes for client/client.cpp: 27 added lines, 0 removed lines. Original line number Diff line number Diff line /******************************************************************************* * Copyright (c) 2025, Jan Koester jan.koester@gmx.net * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the <organization> nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/
client/client.h +67 −0 Changes for client/client.h: 67 added lines, 0 removed lines. Original line number Diff line number Diff line /******************************************************************************* * Copyright (c) 2025, Jan Koester jan.koester@gmx.net * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the <organization> nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include <uuid/uuid.h> #pragma once namespace authdb { class ClientConnection { public: void setUrl(const char *url); void setClientname(const char *name); void setClientSecret(const char *secret); void setUsername(const char *username); void setUserPassword(const char *password); private: std::string _Url; std::string _CltName; std::string _CltSecret; std::string _UserName; std::string _UserPassword; Socket Socket; uuid _SessionID; uuid _ClientId; friend class Client; }; class Client { public: void Client(ClientConnection &clt); bool UserAuth(); bool ClientAuth(); void addConnection(const std::string &clientname,const &std::string cltsecret); void remConnection(const std::string &clientname); bool checkConnection(const std::string &clientname); bool checkGPO(uuid gpoid,const SessionData &sdat); private: ClientConnection _Con; }; };
src/api.cpp +41 −2 Changes for src/api.cpp: 41 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -288,14 +288,53 @@ namespace authdb { for(int i =0; i<fcount; ++i) { json_object_object_foreach(json_object_array_get_idx(cmd,i), key, val) { if(strcmp(key,"addconnection")==0){ std::string clientname,clientsecret; int ocount = json_object_object_length(val); for(int ii =0; ii<ocount; ++ii) { json_object_object_foreach(val,okey,oval){ if(strcmp(okey,"clientname")==0){ clientname=json_object_get_string(oval); }else if( strcmp(okey,"clientsecret")==0){ clientsecret=json_object_get_string(oval); } } if(!clientname.empty() && !clientsecret.empty()){ uuid gpid; gpid.generate(); }else if(strcmp(key,"remconnection")==0){ class ClientData cdat(gpid); cdat.setName(clientname.c_str()); cdat.setKey(clientsecret.c_str()); class Client clt; clt.create(_Backend,&cdat); json_object *respid=json_object_new_object(); json_object_object_add(respid,"addclient",json_object_new_string(gpid.c_str())); json_object_array_add(response,respid); } } }else if(strcmp(key,"remconnection")==0){ uuid clientid; int ocount = json_object_object_length(val); for(int ii =0; ii<ocount; ++ii) { json_object_object_foreach(val,okey,oval){ if(strcmp(okey,"clientid")==0){ clientid.parse(json_object_get_string(oval)); } } if(!clientid.empty()){ class Client clt; clt.remove(_Backend,clientid); json_object *respid=json_object_new_object(); json_object_object_add(respid,"remclient",json_object_new_string(clientid.c_str())); json_object_array_add(response,respid); } } } } } } Api(AuthBackend &admin,class uuid did, libhttppp::HttpRequest* curreq, const int tid, ULONG_PTR args) : _Backend(admin), _Did(did){ _SessionData=nullptr; Loading