From f7333470a935a97369bf625ba0883fb6e5c968e4 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 3 May 2016 10:26:08 -0400 Subject: [PATCH] API Change: Add a new API call to the sysadm-server: rpc/identify (no arguments) This generates a responce identifying the type of sysadm system ("server" in this case). This will be important and I am going to be adding this same API call to all the various sysadm utilities so they can identify which one they are ("server", "bridge", "client"). REST Request: ------------------------------- PUT /rpc/identify {} WebSocket Request: ------------------------------- { "args" : {}, "namespace" : "rpc", "id" : "fooid", "name" : "identify" } Response: ------------------------------- { "args": { "type": "server" }, "id": "fooid", "name": "response", "namespace": "rpc" } --- src/server/WebSocket.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/server/WebSocket.cpp b/src/server/WebSocket.cpp index f42d614..27396b2 100644 --- a/src/server/WebSocket.cpp +++ b/src/server/WebSocket.cpp @@ -121,8 +121,8 @@ void WebSocket::EvaluateREST(QString msg){ this->sendReply(out.assembleMessage()); }else{ //EvaluateRequest(IN); - if(IN.name.startsWith("auth") ){ - //Keep auth system requests in order + if(IN.name.startsWith("auth") || (IN.namesp.toLower()=="rpc" && IN.name.toLower()=="identify") ){ + //Keep auth/pre-auth system requests in order EvaluateRequest(IN); }else{ QtConcurrent::run(this, &WebSocket::EvaluateRequest, IN); @@ -153,7 +153,12 @@ void WebSocket::EvaluateRequest(const RestInputStruct &REQ){ //Now check the body of the message and do what it needs if(out.in_struct.namesp.toLower() == "rpc"){ - if(out.in_struct.name.startsWith("auth")){ + if(out.in_struct.name == "identify"){ + QJsonObject obj; + obj.insert("type", "server"); + out.out_args = obj; + out.CODE = RestOutputStruct::OK; + }else if(out.in_struct.name.startsWith("auth")){ //Now perform authentication based on type of auth given //Note: This sets/changes the current SockAuthToken AUTHSYSTEM->clearAuth(SockAuthToken); //new auth requested - clear any old token