Commit 3bb5ede1 authored by jan.koester's avatar jan.koester
Browse files

use new api

parent c75b7a90
Loading
Loading
Loading
Loading
Loading
+1 −1
Changes for client/CMakeLists.txt: 1 added line, 1 removed line.
Original line number Diff line number Diff line
add_library(client SHARED client.cpp ../src/uuid.cpp ../src/session.cpp)
add_library(client SHARED client.cpp ../src/uuid.cpp ../src/session.cpp ../src/hash.cpp ../src/hash/sha512.cpp)

target_link_libraries(client PUBLIC netplus::netplus)
+35 −0
Changes for client/client.cpp: 35 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -26,3 +26,38 @@
 *******************************************************************************/

#include "client.h"

#include "../src/hash/sha512.h"

authdb::ClientConnection::ClientConnection(){
    _Socket=nullptr;
}

authdb::ClientConnection::~ClientConnection(){
    delete _Socket;
}

void authdb::ClientConnection::setUrl(const char *url){
    _Url=url;
}

void authdb::ClientConnection::setClientname(const char *name){
    _CltName=name;
}

void authdb::ClientConnection::setClientSecret(const char *secret){
    _CltSecret=secret;
}

void authdb::ClientConnection::setUsername(const char *username){
    _UserName=username;
}

void authdb::ClientConnection::setUserPassword(const char *password){
    sha512 sha;
    sha.hash(password,_UserPasswordHash);
}

authdb::Client::Client(ClientConnection& clt){
    _Con=clt;
}
+4 −2
Changes for client/client.h: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@
namespace authdb {
    class ClientConnection {
    public:
        ClientConnection();
        ~ClientConnection();
        void setUrl(const char *url);
        void setClientname(const char *name);
        void setClientSecret(const char *secret);
@@ -47,9 +49,9 @@ namespace authdb {
        std::string _CltName;
        std::string _CltSecret;
        std::string _UserName;
        std::string _UserPassword;
        std::string _UserPasswordHash;

        netplus::socket *Socket;
        netplus::socket *_Socket;
        uuid                    _SessionID;
        uuid                    _ClientId;
        friend class Client;
+25 −25
Changes for src/admin.cpp: 25 added lines, 25 removed lines.
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ namespace authdb {
            char cdid[255];
            uuid_t did;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]",cdid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]",cdid)<0){
                throw AuthBackendError("listUsers: wrong url!");
            }

@@ -153,7 +153,7 @@ namespace authdb {
            char cdid[255];
            uuid_t did;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/*",cdid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/*",cdid)<0){
                throw AuthBackendError("createUser: wrong url!");
            }

@@ -328,7 +328,7 @@ namespace authdb {
            char cdid[128],uid[255];
            uuid_t did;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/removeuser/%s",cdid,uid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/removeuser/%s",cdid,uid)<0){
                throw AuthBackendError("listUsers: wrong url!");
            }

@@ -366,7 +366,7 @@ namespace authdb {
            char cdid[128],cuid[255];
            uuid_t did;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/edituser/%s",cdid,cuid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/edituser/%s",cdid,cuid)<0){
                throw AuthBackendError("listUsers: wrong url!");
            }

@@ -557,12 +557,12 @@ namespace authdb {
            rep.send(curreq,out.c_str(),out.size());
        }

        libhtmlpp::HtmlElement *DomainChangeForm(libhttppp::HttpRequest *curreq,const char *url,AuthBackend &backend,libhtmlpp::HtmlString &dest){
        libhtmlpp::HtmlElement *DomainChangeForm(libhttppp::HttpRequest *curreq,const std::string &url,AuthBackend &backend,libhtmlpp::HtmlString &dest){
            libhttppp::HttpForm form;
            form.parse(curreq);

            char cdid[255],suburl[128];
            if(sscanf(url,"/settings/%[^/]/%s",cdid,suburl)<0)
            if(sscanf(url.c_str(),"/settings/%[^/]/%s",cdid,suburl)<0)
                cdid[0]='\0';

            for (libhttppp::HttpForm::UrlcodedForm::Data* cururlform = form.UrlFormData.getFormData(); cururlform;
@@ -816,7 +816,7 @@ namespace authdb {

        void removeDomain(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){
            char did[255];
            sscanf(curreq->getRequestURL(),"/settings/%[^/]/removedomain",did);
            sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/removedomain",did);

            Domain domain;

@@ -852,7 +852,7 @@ namespace authdb {
            char cdid[255];
            uuid_t did;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]",cdid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]",cdid)<0){
                throw AuthBackendError("listGroups: wrong url!");
            }

@@ -929,7 +929,7 @@ namespace authdb {
            char cdid[255];
            uuid_t did;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]",cdid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]",cdid)<0){
                throw AuthBackendError("createGroups: wrong url!");
            }

@@ -1074,7 +1074,7 @@ namespace authdb {
            char cdid[128],gid[255];
            uuid_t did;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/removegroup/%s",cdid,gid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/removegroup/%s",cdid,gid)<0){
                throw AuthBackendError("removeGroup: wrong url!");
            }

@@ -1112,7 +1112,7 @@ namespace authdb {
            char cdid[128],cgid[255];
            uuid_t did;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/editgroup/%s",cdid,cgid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/editgroup/%s",cdid,cgid)<0){
                throw AuthBackendError("listUsers: wrong url!");
            }

@@ -1381,7 +1381,7 @@ namespace authdb {
            char cdid[255];
            uuid did;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/*",cdid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/*",cdid)<0){
                throw AuthBackendError("listSessions: wrong url!");
            }

@@ -1433,7 +1433,7 @@ namespace authdb {

            uuid_clear(sid);

            if(sscanf(curreq->getRequestURL(),"/settings/%*[^/]/removesession/%s",csid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%*[^/]/removesession/%s",csid)<0){
                throw AuthBackendError("removeSession: wrong url!");
            }

@@ -1455,7 +1455,7 @@ namespace authdb {

            uuid_clear(sid);

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/reloadsession/%s",cdid,csid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/reloadsession/%s",cdid,csid)<0){
                throw AuthBackendError("removeSession: wrong url!");
            }

@@ -1492,7 +1492,7 @@ namespace authdb {

            uuid_clear(did);

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/creategpo",cdid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/creategpo",cdid)<0){
                throw AuthBackendError("creatGPO: wrong url!");
            }

@@ -1669,7 +1669,7 @@ namespace authdb {

            uuid_clear(did);

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/editgpo/%s",cdid,cgpid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/editgpo/%s",cdid,cgpid)<0){
                throw AuthBackendError("creatGPO: wrong url!");
            }

@@ -1869,7 +1869,7 @@ namespace authdb {

            uuid_clear(did);

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/listgpos",cdid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/listgpos",cdid)<0){
                throw AuthBackendError("removeSession: wrong url!");
            }

@@ -1983,7 +1983,7 @@ namespace authdb {
            uuid_clear(gpid);
            uuid_clear(did);

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/removegpo/%s",cdid,cgpid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/removegpo/%s",cdid,cgpid)<0){
                throw AuthBackendError("removeGPO: wrong url!");
            }

@@ -2107,7 +2107,7 @@ namespace authdb {
            char cdid[255];
            uuid_t did;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]",cdid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]",cdid)<0){
                throw AuthBackendError("listUsers: wrong url!");
            }

@@ -2226,7 +2226,7 @@ namespace authdb {
            char cdid[255];
            uuid_t did;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]",cdid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]",cdid)<0){
                throw AuthBackendError("listUsers: wrong url!");
            }

@@ -2329,7 +2329,7 @@ namespace authdb {
            char cdid[255],ccldid[255];
            uuid_t did,cldid;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/removeclient/%s",cdid,ccldid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/removeclient/%s",cdid,ccldid)<0){
                throw AuthBackendError("remove client: wrong url!");
            }

@@ -2366,7 +2366,7 @@ namespace authdb {
            char cdid[255],cclid[255];
            uuid_t did,clid;

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/editclient/%s",cdid,cclid)<0){
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/editclient/%s",cdid,cclid)<0){
                throw AuthBackendError("editclient: wrong url!");
            }

@@ -2474,7 +2474,7 @@ namespace authdb {
                    }
                }

                if(strncmp("/settings/logout",curreq->getRequestURL(),15)==0){
                if(curreq->getRequestURL().compare(0,15,"/settings/logout")==0){
                    AuthSession.remSession(ssid);
                    libhttppp::HttpResponse rep;
                    rep.setState(HTTP303);
@@ -2549,7 +2549,7 @@ namespace authdb {

            char domain[255]={},url[255]={};

            if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/%s",domain,url)<0)
            if(sscanf(curreq->getRequestURL().c_str(),"/settings/%[^/]/%s",domain,url)<0)
                goto URLNOTFOUND;

            if(strncmp("listusers",url,9)==0){
@@ -2637,7 +2637,7 @@ URLNOTFOUND:
    }

    void AdminInterface::Request(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){
            if(strncmp("/settings",curreq->getRequestURL(),9)==0){
            if(curreq->getRequestURL().compare(0,10,"/settings")==0){
                _ctl->SettingsController(curreq,tid,args);
            }else{
                libhttppp::HttpResponse rep;
+7 −7
Changes for src/authdb.cpp: 7 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -162,13 +162,13 @@ namespace authdb {
        }

        void RequestEvent(libhttppp::HttpRequest * curreq, const int tid, ULONG_PTR args){
            if(strncmp("/authdb.js",curreq->getRequestURL(),9)==0){
            if(curreq->getRequestURL().compare(0,9,"/authdb.js")==0){
                libhttppp::HttpResponse rep;
                rep.setState(HTTP200);
                rep.setContentType("text/javascript");
                rep.send(curreq,_AuthJs.data(),_AuthJs.size());
                return;
            }else if(strncmp("/style.css",curreq->getRequestURL(),9)==0){
            }else if(curreq->getRequestURL().compare(0,9,"/style.css")==0){
                libhttppp::HttpResponse rep;
                rep.setState(HTTP200);
                rep.setContentType("text/css");
@@ -193,7 +193,7 @@ namespace authdb {

            }

            if(strncmp("/settings",curreq->getRequestURL(),9)==0){
            if(curreq->getRequestURL().compare(0,10,"/settings")==0){
                _AdminBackend.lock();
                try{
                    _AdminInterface.Request(curreq,tid,args);
@@ -204,7 +204,7 @@ namespace authdb {
                    rep.send(curreq,e.what(),strlen(e.what()));
                }
                _AdminBackend.unlock();
            }if(strncmp("/api",curreq->getRequestURL(),4)==0){
            }if(curreq->getRequestURL().compare(0,4,"/api")==0){
                _AdminBackend.lock();

                DomainBackend db(_AdminBackend);
@@ -213,7 +213,7 @@ namespace authdb {

                char domain[255]={0};

                if(sscanf(curreq->getRequestURL(),"/api/%254[^/]s",domain)<0){
                if(sscanf(curreq->getRequestURL().c_str(),"/api/%254[^/]s",domain)<0){
                    libhttppp::HttpResponse rep;
                    rep.setState(HTTP500);
                    rep.setContentType("text/html");
@@ -257,7 +257,7 @@ namespace authdb {
                    rep.setContentType("text/html");
                    rep.send(curreq,"uuid not found!",12);
                }
            }else if(strncmp("/getavatar",curreq->getRequestURL(),9)==0){
            }else if(curreq->getRequestURL().compare(0,11,"/getavatar")==0){
                _AdminBackend.lock();
                try{
                    getAvatar(curreq,tid,args);
@@ -286,7 +286,7 @@ namespace authdb {
            AuthBackend *backend=nullptr;

            char domain[255],cuid[255],ext[16];
            if(sscanf(curreq->getRequestURL(),"/getavatar/%[^/]/%[^.].%s",domain,cuid,ext)<0)
            if(sscanf(curreq->getRequestURL().c_str(),"/getavatar/%[^/]/%[^.].%s",domain,cuid,ext)<0)
                return;

            uuid_t did;