Where to store database credentials in a web app?

后端 未结 8 1438
离开以前
离开以前 2021-02-07 08:28

I\'m wondering what techniques you use to store the database credentials for your application. I\'m specifically concerned with java webapps, but I don\'t think there\'s any ne

相关标签:
8条回答
  • 2021-02-07 08:58

    As stated before, no platform specified, and using some ideas from earlier answers:

    I am considering a containerised application. You could store the password for the database in a file in the container. The first step of your application would be to establish the database connection, even before listening on web requests. With a successful db connection the file with the credentials is deleted and the variables containing the these, are removed. So when you start serving requests, the only thing that remains, is an open database handle to use from this moment on. If for any reason the database connection is lost, you simply quit and wait to restart the container, the credentials file will be there again.

    0 讨论(0)
  • 2021-02-07 09:08

    For asp.net:

    I store global parameters such as the connection string and repository paths in the Registry and then a reference to the registry entry in the web.config.

    The main reason being that I often find I have to write a stand alone executable to run background tasks and other automated features that require access to the same parameters. Therefore keeping everything that is truly global in one easily accessible place makes for an easier life.

    0 讨论(0)
提交回复
热议问题