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. Qt and MySQL : What about security?
Forum Updated to NodeBB v4.3 + New Features

Qt and MySQL : What about security?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 7 Posters 3.2k Views 1 Watching
  • 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.
  • I Offline
    I Offline
    irobot
    wrote on 10 Nov 2013, 18:18 last edited by
    #1

    Hi
    I am working on a Qt C++ and MySQL application (inventory system). The problem is that when I will give it to somebody the admin username and password will be part of application source code.

    @
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("host");
    db.setDatabaseName("menudb");
    db.setUserName("root");
    db.setPassword("test");
    @

    I know that is not the right way. Can somebody give me the correct way?

    Thanks

    1 Reply Last reply
    0
    • P Offline
      P Offline
      panosk
      wrote on 10 Nov 2013, 20:10 last edited by
      #2

      Hi,

      Don't hardcode such values if the app is not meant just for your own use and for simple experiments. You should let the user give these values, for example through a dialog box.

      Also, you shouldn't give access to MySQL with the root/admin account. Create users in MySQL with specific rights for the specific database.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 11 Nov 2013, 07:38 last edited by
        #3

        you could implement a routine which reads an encrypted file containing the credentials.
        But anyway if you provide the source code it's easy to debug the application and get the credentials at runtime.
        So you would need to let the user enter the credentials and only distribute them to the people you intend to.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • P Offline
          P Offline
          puterk
          wrote on 11 Nov 2013, 09:00 last edited by
          #4

          Hello,

          Is it possible to encrypt the credentials with QSettings?

          The app would read it from an ini file then load it to textboxes (with the password encrypted) so that it can be modified by a user?

          1 Reply Last reply
          0
          • R Offline
            R Offline
            raven-worx
            Moderators
            wrote on 11 Nov 2013, 09:04 last edited by
            #5

            [quote author="puterk" date="1384160415"]
            Is it possible to encrypt the credentials with QSettings?
            [/quote]
            no QSettings saves plain values. But you can save encrypted values. You could use "QCA":http://delta.affinix.com/qca/ for example for that.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MarianMMX
              wrote on 11 Nov 2013, 09:58 last edited by
              #6

              Use QSQLITE as the database driver, in that case you don't need username and password.

              1 Reply Last reply
              0
              • O Offline
                O Offline
                OpenGL
                wrote on 11 Nov 2013, 11:33 last edited by
                #7

                I think you should have a look at the database end instead. First, don't give root access (if that is the superuser of the database), create separate account with as few access rights as possible and then create a database layer with rules that restricts what the client can do with the database.
                Then it really doesn't matter if you give the end user the password :)

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  NicuPopescu
                  wrote on 11 Nov 2013, 14:47 last edited by
                  #8

                  Hi,

                  I think you don't really need to give the end user the password or hardcode it, if you use for instance and ODBC connection as DSN system: once you have configured it, in code you just need the DSN name (the password will be provided automatically by system and is protected); may be the user name is visible in connection (i.e. ODBC administrator or registry) but without password is useless, and is better as mentioned in thread to create a user with sufficient privileges

                  1 Reply Last reply
                  0

                  1/8

                  10 Nov 2013, 18:18

                  • Login

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