What are recommendations, best practices and have-to-dos regarding handling connection strings in web applications? What things one should never, ever do?
|
|
Best option: Don't use a password for the database, but instead employ (Windows) Integrated Authentication if it's possible, and of course isolate the application's identity that is authorized for the database. That way you have the OS/Webserver/SCM manage your identity, in a very secured manner. If it's not possible to go the way of IWA, you'll need to securely encrypt the connstring, preferably using something like DPAPI (so you dont have to manage the encryption key), and store the encrypted value in a protected Registry key with strong ACLs. |
|||||
|
|
things you should never do
things you should do.
|
|||||
|
|
I'd recommend storing your connection string outside of the website root directory. If you're using ASP.NET, then your web.config file will be in the website root directory, but you can encrypt a section of your web.config file using the Data Protection API, which stores the decryption key securely. Which framework are you using for your web application? |
|||
|
|
As an option, try to use application role to access sql server Benefits:
|
|||
|
|