Loading src/api.cpp +26 −7 Changes for src/api.cpp: 26 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ #include "api.h" #include "user.h" #include "client.h" #include "session.h" namespace authdb { class Api { Loading @@ -58,15 +59,19 @@ namespace authdb { } } bool userLogin(json_object *request,json_object *response){ return Login(request,response,"user"); bool checkConnection(json_object *request,json_object *response){ return false; } bool userLogin(uuid &did,json_object *request,json_object *response){ return Login(did,request,response,"user"); } bool clientLogin(json_object *request,json_object *response){ return Login(request,response,"client"); bool clientLogin (uuid &did,json_object *request,json_object *response){ return Login(did,request,response,"client"); } bool Login(json_object *request,json_object *response,const char *type){ bool Login( uuid &did,json_object *request,json_object *response,const char *type){ json_object *cmd=json_object_object_get(request,"commands"); if(!cmd) throw(AuthBackendError("Invalid Api Commands")); Loading Loading @@ -111,8 +116,16 @@ namespace authdb { user.info(*_Backend,udat,upos); if(name==udat.getUsername()){ if(pwsalt==udat.getPwHash()) if(pwsalt==udat.getPwHash()){ Session session; const SessionData *sdat=session.addSession(*_Backend,did.value,cur.uuid); json_object *respid=json_object_new_object(); uuid sessid; sdat->getSid(sessid.value); json_object_object_add(respid,"sessionid",json_object_new_string(sessid.c_str())); json_object_array_add(response,respid); return true; } return false; } }else if(strcmp(type,"client") == 0 && cur.type == ClientData && strcmp(cur.fieldname,"clientname")==0){ Loading Loading @@ -162,7 +175,13 @@ namespace authdb { jresponse = json_object_new_array(); if(!clientLogin(jrequest,jresponse)){ char cdid[sizeof(uuid_t)]; sscanf(curreq->getRequestURL(),"/api/%[^/]",cdid); uuid did; uuid_parse(cdid,did.value); if(!clientLogin(did, jrequest,jresponse)){ const char *ret=json_object_to_json_string(jresponse); rep.setState(HTTP401); rep.setContentType("text/json"); Loading src/session.cpp +4 −0 Changes for src/session.cpp: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,10 @@ #include "types.h" #include "uuid.h" namespace authdb { std::shared_ptr<SessionData> _firstData; std::shared_ptr<SessionData> _lastData; } authdb::SessionData::SessionData(uuid_t sessionid, uuid_t userid, uuid_t domainid,std::vector<uuid> &members) : _members(members){ uuid_copy(_sid,sessionid); Loading src/session.h +0 −4 Changes for src/session.h: 0 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -78,9 +78,5 @@ namespace authdb { void relSession(AuthBackend &backend,uuid_t sessionid); const SessionData *firstData() const; private: std::shared_ptr<SessionData> _firstData; std::shared_ptr<SessionData> _lastData; }; }; src/uuid.h +3 −1 Changes for src/uuid.h: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -46,8 +46,10 @@ namespace authdb{ void operator=(const uuid &src); bool operator==(const uuid_t src) const; bool operator==(const uuid src) const; private: uuid_t value; private: char nvalue[sizeof(uuid_t)+1]; }; }; Loading Loading
src/api.cpp +26 −7 Changes for src/api.cpp: 26 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ #include "api.h" #include "user.h" #include "client.h" #include "session.h" namespace authdb { class Api { Loading @@ -58,15 +59,19 @@ namespace authdb { } } bool userLogin(json_object *request,json_object *response){ return Login(request,response,"user"); bool checkConnection(json_object *request,json_object *response){ return false; } bool userLogin(uuid &did,json_object *request,json_object *response){ return Login(did,request,response,"user"); } bool clientLogin(json_object *request,json_object *response){ return Login(request,response,"client"); bool clientLogin (uuid &did,json_object *request,json_object *response){ return Login(did,request,response,"client"); } bool Login(json_object *request,json_object *response,const char *type){ bool Login( uuid &did,json_object *request,json_object *response,const char *type){ json_object *cmd=json_object_object_get(request,"commands"); if(!cmd) throw(AuthBackendError("Invalid Api Commands")); Loading Loading @@ -111,8 +116,16 @@ namespace authdb { user.info(*_Backend,udat,upos); if(name==udat.getUsername()){ if(pwsalt==udat.getPwHash()) if(pwsalt==udat.getPwHash()){ Session session; const SessionData *sdat=session.addSession(*_Backend,did.value,cur.uuid); json_object *respid=json_object_new_object(); uuid sessid; sdat->getSid(sessid.value); json_object_object_add(respid,"sessionid",json_object_new_string(sessid.c_str())); json_object_array_add(response,respid); return true; } return false; } }else if(strcmp(type,"client") == 0 && cur.type == ClientData && strcmp(cur.fieldname,"clientname")==0){ Loading Loading @@ -162,7 +175,13 @@ namespace authdb { jresponse = json_object_new_array(); if(!clientLogin(jrequest,jresponse)){ char cdid[sizeof(uuid_t)]; sscanf(curreq->getRequestURL(),"/api/%[^/]",cdid); uuid did; uuid_parse(cdid,did.value); if(!clientLogin(did, jrequest,jresponse)){ const char *ret=json_object_to_json_string(jresponse); rep.setState(HTTP401); rep.setContentType("text/json"); Loading
src/session.cpp +4 −0 Changes for src/session.cpp: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,10 @@ #include "types.h" #include "uuid.h" namespace authdb { std::shared_ptr<SessionData> _firstData; std::shared_ptr<SessionData> _lastData; } authdb::SessionData::SessionData(uuid_t sessionid, uuid_t userid, uuid_t domainid,std::vector<uuid> &members) : _members(members){ uuid_copy(_sid,sessionid); Loading
src/session.h +0 −4 Changes for src/session.h: 0 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -78,9 +78,5 @@ namespace authdb { void relSession(AuthBackend &backend,uuid_t sessionid); const SessionData *firstData() const; private: std::shared_ptr<SessionData> _firstData; std::shared_ptr<SessionData> _lastData; }; };
src/uuid.h +3 −1 Changes for src/uuid.h: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -46,8 +46,10 @@ namespace authdb{ void operator=(const uuid &src); bool operator==(const uuid_t src) const; bool operator==(const uuid src) const; private: uuid_t value; private: char nvalue[sizeof(uuid_t)+1]; }; }; Loading