Node.js + ws + QT QML Websocket + Authentication?The definitive guide to form-based website authenticationHow do I debug Node.js applications?How do I get started with Node.jsWriting files in Node.jsHow do I pass command line arguments to a Node.js program?Check synchronously if file/directory exists in Node.jsRead environment variables in Node.jsHow to decide when to use Node.js?How to exit in Node.jsWhat is the purpose of Node.js module.exports and how do you use it?

What are the peak hours for public transportation in Paris?

Can a user sell my software (MIT license) without modification?

What is the purpose of building foundations?

How Can I Tell The Difference Between Unmarked Sugar and Stevia?

What can plausibly explain many of my very long and low-tech bridges?

`cosf`, `sinf`, etc. are not in `std`

Do you need type ratings for private flying?

How hard would it be to convert a glider into an powered electric aircraft?

Etymology of 'calcit(r)are'?

Why is the application of an oracle function not a measurement?

Why doesn’t a normal window produce an apparent rainbow?

What's the right way to purge recursively with apt?

What LISP compilers and interpreters were available for 8-bit machines?

How do photons get into the eyes?

How to make a setting relevant?

SF novella separating the dumb majority from the intelligent part of mankind

Was the Tamarian language in "Darmok" inspired by Jack Vance's "The Asutra"?

Version 2 - print new even-length arrays from two arrays

Java guess the number

What is this solid state starting relay component?

Bent spoke design wheels — feasible?

Question about JavaScript Math.random() and basic logic

Do any instruments not produce overtones?

Deformation of rectangular plot



Node.js + ws + QT QML Websocket + Authentication?


The definitive guide to form-based website authenticationHow do I debug Node.js applications?How do I get started with Node.jsWriting files in Node.jsHow do I pass command line arguments to a Node.js program?Check synchronously if file/directory exists in Node.jsRead environment variables in Node.jsHow to decide when to use Node.js?How to exit in Node.jsWhat is the purpose of Node.js module.exports and how do you use it?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















What authentication mechanisms can be used if I have a websocket server implemented in Node.js with ws like this:



const WebSocket = require('ws');

const wss = new WebSocket.Server( port: 8080 );

let theObjects = [];

wss.on('connection', function connection(ws)
ws.on('message', function incoming(message)
if (message === 'create') theObjects[username] = CreateObject();
else if (message === 'change') theObjects[username].someParam = someVal;
);
);


and a QT QML client:



WebSocket 
id: socket
url: "ws://myhost.ru:8080"
onTextMessageReceived:
messageBox.text = messageBox.text + "nReceived message: " + message

onStatusChanged: if (socket.status == WebSocket.Error)
console.log("Error: " + socket.errorString)
else if (socket.status == WebSocket.Open)
var msg = command: 'create', authorization: '****', params: something: 'really cool'
socket.sendTextMessage(JSON.stringify(msg))
else if (socket.status == WebSocket.Closed)
messageBox.text += "nSocket closed"

active: false



I am not sure that this scenario is 100% correct, but at least I have the following idea on how my client should communicate with the server:



The client should be able to connect with user name and password (over WSS), create some server-side object, start some kind of data processing with this object and disconnect. When the user reconnects later it should be able to access its server-side object (by the user name or some token). While the user is connected the server-side object periodically sends some data to the client.



The question is what is the proper way to implement this and how to authenticate the user?



Personally, I did not find something related to authentication neither in QT Websocket nor in Node.js ws module










share|improve this question






























    0















    What authentication mechanisms can be used if I have a websocket server implemented in Node.js with ws like this:



    const WebSocket = require('ws');

    const wss = new WebSocket.Server( port: 8080 );

    let theObjects = [];

    wss.on('connection', function connection(ws)
    ws.on('message', function incoming(message)
    if (message === 'create') theObjects[username] = CreateObject();
    else if (message === 'change') theObjects[username].someParam = someVal;
    );
    );


    and a QT QML client:



    WebSocket 
    id: socket
    url: "ws://myhost.ru:8080"
    onTextMessageReceived:
    messageBox.text = messageBox.text + "nReceived message: " + message

    onStatusChanged: if (socket.status == WebSocket.Error)
    console.log("Error: " + socket.errorString)
    else if (socket.status == WebSocket.Open)
    var msg = command: 'create', authorization: '****', params: something: 'really cool'
    socket.sendTextMessage(JSON.stringify(msg))
    else if (socket.status == WebSocket.Closed)
    messageBox.text += "nSocket closed"

    active: false



    I am not sure that this scenario is 100% correct, but at least I have the following idea on how my client should communicate with the server:



    The client should be able to connect with user name and password (over WSS), create some server-side object, start some kind of data processing with this object and disconnect. When the user reconnects later it should be able to access its server-side object (by the user name or some token). While the user is connected the server-side object periodically sends some data to the client.



    The question is what is the proper way to implement this and how to authenticate the user?



    Personally, I did not find something related to authentication neither in QT Websocket nor in Node.js ws module










    share|improve this question


























      0












      0








      0








      What authentication mechanisms can be used if I have a websocket server implemented in Node.js with ws like this:



      const WebSocket = require('ws');

      const wss = new WebSocket.Server( port: 8080 );

      let theObjects = [];

      wss.on('connection', function connection(ws)
      ws.on('message', function incoming(message)
      if (message === 'create') theObjects[username] = CreateObject();
      else if (message === 'change') theObjects[username].someParam = someVal;
      );
      );


      and a QT QML client:



      WebSocket 
      id: socket
      url: "ws://myhost.ru:8080"
      onTextMessageReceived:
      messageBox.text = messageBox.text + "nReceived message: " + message

      onStatusChanged: if (socket.status == WebSocket.Error)
      console.log("Error: " + socket.errorString)
      else if (socket.status == WebSocket.Open)
      var msg = command: 'create', authorization: '****', params: something: 'really cool'
      socket.sendTextMessage(JSON.stringify(msg))
      else if (socket.status == WebSocket.Closed)
      messageBox.text += "nSocket closed"

      active: false



      I am not sure that this scenario is 100% correct, but at least I have the following idea on how my client should communicate with the server:



      The client should be able to connect with user name and password (over WSS), create some server-side object, start some kind of data processing with this object and disconnect. When the user reconnects later it should be able to access its server-side object (by the user name or some token). While the user is connected the server-side object periodically sends some data to the client.



      The question is what is the proper way to implement this and how to authenticate the user?



      Personally, I did not find something related to authentication neither in QT Websocket nor in Node.js ws module










      share|improve this question
















      What authentication mechanisms can be used if I have a websocket server implemented in Node.js with ws like this:



      const WebSocket = require('ws');

      const wss = new WebSocket.Server( port: 8080 );

      let theObjects = [];

      wss.on('connection', function connection(ws)
      ws.on('message', function incoming(message)
      if (message === 'create') theObjects[username] = CreateObject();
      else if (message === 'change') theObjects[username].someParam = someVal;
      );
      );


      and a QT QML client:



      WebSocket 
      id: socket
      url: "ws://myhost.ru:8080"
      onTextMessageReceived:
      messageBox.text = messageBox.text + "nReceived message: " + message

      onStatusChanged: if (socket.status == WebSocket.Error)
      console.log("Error: " + socket.errorString)
      else if (socket.status == WebSocket.Open)
      var msg = command: 'create', authorization: '****', params: something: 'really cool'
      socket.sendTextMessage(JSON.stringify(msg))
      else if (socket.status == WebSocket.Closed)
      messageBox.text += "nSocket closed"

      active: false



      I am not sure that this scenario is 100% correct, but at least I have the following idea on how my client should communicate with the server:



      The client should be able to connect with user name and password (over WSS), create some server-side object, start some kind of data processing with this object and disconnect. When the user reconnects later it should be able to access its server-side object (by the user name or some token). While the user is connected the server-side object periodically sends some data to the client.



      The question is what is the proper way to implement this and how to authenticate the user?



      Personally, I did not find something related to authentication neither in QT Websocket nor in Node.js ws module







      node.js authentication websocket qml






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 15:48







      Alexey Starinsky

















      asked Mar 24 at 15:34









      Alexey StarinskyAlexey Starinsky

      778212




      778212






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325446%2fnode-js-ws-qt-qml-websocket-authentication%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325446%2fnode-js-ws-qt-qml-websocket-authentication%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript