Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Server with model-, view-clients & authentication
QtWS25 Last Chance

Server with model-, view-clients & authentication

Scheduled Pinned Locked Moved Solved General and Desktop
qt networkingqthreadauthenticationserver - clientmongodb
6 Posts 3 Posters 4.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    danyright
    wrote on 4 Jan 2017, 18:04 last edited by
    #1

    Hi everybody,

    I'm working on an application to monitor data coming from a raspberry pi (model) on a smartphone / desktop (view).
    The "view(s)" will be used to connect to the user's account, add new devices, configure these devices, monitor them and receive notifications from them.
    These two clients will be written in Qt C++ and QML respectively.

    I'm trying to find out what the best tools for the server side of all that would be.

    I've looked around quite a bit to find the perfect fit for my needs but no existing project convinced me so far (except maybe disawoed Engin.io).

    Here are the features I'll need :
    · Some kind of user authentication
    · An easy way to store user data/settings - MongoDB or another NoSQL DB seems a good fit
    · Idealy a WebSocket compatible server (with TLS)
    · I'd like to be able to write it in Qt C++ for ease of maintenance

    Since it's finally not that complicated, I thought I might just create it myself.

    However, since networking is not really my area of expertise, I'd love to have your input on the architecture I thought of.

    1. Create a multi-threaded WebSocket server.
    2. Use one QWebSocketServer on port X for the connections from the models.
      One other QWebSocketServer on port Y for the connections from the views.
      cf: https://stackoverflow.com/questions/13566026/server-with-different-clients-in-qt
    3. Connection to MongoDB to load and store user data
    4. Authenticate the user
    5. Create one thread per connected user to handle all the communication between a user's view(s) / models (attach the user's new WebSockets to 'his' thread).
      This should also help avoid users getting data from other accounts, right ?

    That's it !

    Now, it's pretty clear how I would need to do most of this, except part 4) - user authentication.
    I saw this library with a Qt based API: https://gitlab.com/accounts-sso
    which seems to offer pretty complete account/authentication services (developed by Canonical), but I'm open for suggestions.
    At one point I wondered if I could not maybe 'pervert' the QNetworkProxy to use it as authentication system... is that completely crazy ?

    Of course, another solution is to write a complete authentication system, but that seems quite hazardous and time consuming.

    One other solution might also be to use the newly implemented (5.8 RC) Qt Network Authorization classes, but that would mean that I would need to install and configure an OAuth identification server as well.

    Any suggestions ?
    Anything I would be doing plain wrong ?
    Let me know what you think.

    Thanks for your help.

    D

    PS: I did check frameworks like Wt, Cutelyst, Silk, or posts like https://forum.qt.io/topic/63777/looking-for-engin-io-replacement-joining-our-effort-initiative/31 but I'd really like to avoid using another language to develop the server part + avoid being dependent on a cloud platform that might not be around in 2+ years...

    1 Reply Last reply
    0
    • D Offline
      D Offline
      danyright
      wrote on 8 Apr 2017, 14:14 last edited by
      #4

      So, after much reading, discovering & testing, I was about to start writing the server code with Wt but then I finally stumbled upon TreeFrog (http://www.treefrogframework.org/), which is exactly what I was actually looking for !

      A Qt C++ web framework, implementing user authentication, WebSockets and a MongoDB mapper and very nice skeleton generator to help you get started with projects.

      Too bad it took me that long to find it - but it seems like it is not widely known.
      So I hope this post can help someone else looking for a similar solution.

      Cheers,
      D

      1 Reply Last reply
      1
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 4 Jan 2017, 23:02 last edited by
        #2

        Hi and welcome to devnet,

        Are you looking for something like the qhttp project ?

        Even though you wrote that you would like to avoid other languages, doing a full web service from scratch might not be the best idea since you're also not used to network programming and would like to handle SSO, encryption, user management etc. You should consider something like Flask or Django for your backend. Both have related libraries for websocket communication. Django might be easier to get started quickly since you already have the user management part integrated.

        Hope it helps

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        D 1 Reply Last reply 5 Jan 2017, 22:28
        0
        • S SGaist
          4 Jan 2017, 23:02

          Hi and welcome to devnet,

          Are you looking for something like the qhttp project ?

          Even though you wrote that you would like to avoid other languages, doing a full web service from scratch might not be the best idea since you're also not used to network programming and would like to handle SSO, encryption, user management etc. You should consider something like Flask or Django for your backend. Both have related libraries for websocket communication. Django might be easier to get started quickly since you already have the user management part integrated.

          Hope it helps

          D Offline
          D Offline
          danyright
          wrote on 5 Jan 2017, 22:28 last edited by danyright 1 May 2017, 22:29
          #3

          Hi,
          @SGaist thanks for your message and your suggestions !

          The QHttp project can certainly be an good reference regarding a well built server.
          Based on your suggestion I checked Flask and Django out - the latter being very interesting indeed.

          I did also realise that Wt would actually fit my needs as well, since it can actually work with WebSockets and it does include an authentication system. Since this framework is quite similar to Qt, it would still be easier than getting back to Python (haven't touched it in years...).

          At the same time I did also find this library encapsulating an OAuth and OAuth2 client (https://github.com/pipacs/o2) which could be used in conjunction with an oauthd NodeJS server (https://github.com/oauth-io/oauthd) that could easily be setup in a docker image. (Or also with the new Qt Network Authorization module)

          I'll try to take a deeper look and run a few tests this week-end, hopefully.

          Thanks,
          D

          1 Reply Last reply
          0
          • D Offline
            D Offline
            danyright
            wrote on 8 Apr 2017, 14:14 last edited by
            #4

            So, after much reading, discovering & testing, I was about to start writing the server code with Wt but then I finally stumbled upon TreeFrog (http://www.treefrogframework.org/), which is exactly what I was actually looking for !

            A Qt C++ web framework, implementing user authentication, WebSockets and a MongoDB mapper and very nice skeleton generator to help you get started with projects.

            Too bad it took me that long to find it - but it seems like it is not widely known.
            So I hope this post can help someone else looking for a similar solution.

            Cheers,
            D

            1 Reply Last reply
            1
            • danttiD Offline
              danttiD Offline
              dantti
              wrote on 30 May 2017, 14:08 last edited by
              #5

              I'm curious why you say you would need to use another language if you were to use Cutelyst or Wt (both are C++)? Cutelyst is even written in Qt, and is a top performer https://www.techempower.com/benchmarks/

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 30 May 2017, 21:00 last edited by
                #6

                Frankly, I forgot about it.

                Then it also depends also on what tools fits best your needs. There's no silver bullet that will cover everything you need.

                Also limiting yourself to only one language is not a good idea in the long run. There are good and bad things in every language thus knowing more than one allows to have a better grasp at what can be done, how easy/hard the maintenance would be etc.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved