DNNMonster / WebConfigEncryptor

DNN Module to encrypt web config data base connection strings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WebConfigEncryptor

WebConfigEncryptor is a DNN module that enables a host user to encrypt/decrypt the web.config data base connectionStrings section in single server environments. It uses the Windows Data Protection API (DPAPI) to encrypt and decrypt data. [Read more...](https://docs.microsoft.com/en-ca/previous-versions/aspnet/hh8x3tas(v=vs.100)

Typically you will start with a config connectionStrings section that looks similar to this:

<connectionStrings>
    <add name="SiteSqlServer" connectionString="Data Source=XXXXXX;Initial Catalog=XXXXX;User ID=XXXXX;Password=XXXXXX"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

Your encrypted config will look simlilar to below:

 <connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">
    <EncryptedData>
      <CipherData>
        <CipherValue>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAJq8KJsBh2UGue8UHaCKEmgQAAAACAAAAAAAQZgAAAAEAACAAAAD//6TU78+QzAwBU+0E2qP5PEB8CekwNYe2ptcyPuMitwAAAAAOgAAAAAIAACAAAABpuhFfhVop/T90K86CYYd7UOCMl82nOS+X4WZ17NS/BcALAADAUnsIBb1SlrCpvD8mWD1A15TDYar9TMIaUGaUHzZeDBjruiqTuBqhDzLJ2TcwsL3aaaPUlP9tY3JAIdcywa+H5d+QzmCL1nAsZNqnvTY1tIy2jW/TVRsoRGFv74V7I3n8LmzyqE7wBly5iVlLaVE/Oa20vuiswqsSwXnqoKk4JxMO/vh5ML7HeWftzFITuIH6e4mkdFupNUE0dusa6FVcXE72TY+XN6PwIqHxxBVvGjIpT2hnfY/AzuFGtuf4GNtw/9exPorMUEhUDn/7M8tftKc3PAga90NarQWHb7HA0ckQEPqQw5WBxyJOv9yBw3AybBzRsxyuVdPah2ZcAxkml5iideTp+F6Z3fAcq3BCpfZs3jz3ti4RjPhmbOPaw/l23AgAYd4nEFbKgzLYXBcgixXAvJB7gTaiPV8i74bBGhb7qIzzAYm3i0vXBm09LgJFflUHN/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QQuh0pfjZkpTUr+Hja72U7W233lWhKcM1LehVWGz/7pa+1lZihh5uS7hlbIF/J6vRHx93aJs+BsYtPtSOcjRTV9fDRPkN8NWOQvH8KvayWSm69WSEw6mcB3rWLJHXtqUV5EdoenZfoXuaLsrbL83S47kYwVQmuwpqZsqwPjXcHGM8v7QGXV+XPJv/trgu/GYTw/XgVG8VNFCra2xhKTmxMIodrqliaghYskr4RgT4hOWKDXzAvAav6Sq55srx939gEjB3ySRTk9SM3j9NkzIzMFW1s+PP0H+z0L2oimTuGAtkugMdYIKFQSuwWwDELO4616I380AAAAAqhcsLTbdZDaadflFPsFd3xElbaL3B9klGe7mqvxh7BPxvjaB+MgnX09it3d/PrbrJe/0NjNJPTrxDYdZbissH</CipherValue>
      </CipherData>
    </EncryptedData>
  </connectionStrings>

Getting Started

This DNN MVC module will enable any DNN 9.4+ site to encrypt their web config data base connection string. It's most useful for shared hosting environments where you may not have full access to the server. With WebConfigEncryptor you can still encrypt your db connection strings provided you have host access to your DNN installation. It can be also be used for dedicated servers, virtual machines or app services to simplify the task.

About the Install

The module is a standard module installation. There is no sql provider with this installation but it's best to back up your db and file sytem before installation. You should also backup your web.config before you're initial encrypt/decrypt attempts as a precaution and to verify that the module is performing as expected.

After installation place the module onto any page that is restricted to host users. Only host users can encrypt or decrypt the web config connection string. The module will log each encrypt & decrypt action to the DNN log.

Installing

  1. Backup your db and file system. Install into DNN as a normal module. The installation process will ensure that your DNN installation is using at least v9.4.0.

  2. Navigate to an existing admin page in your site or create a new page that is restricted to admins. (ie. https://{mysite.com}/admin)

  3. Place WebConfigEncryptor module on to the page.

  4. There is just one button and clicking it will toggle the encryption/decryption depending upon the current state of your config.


Congratulations! The WebConfigEncryptor should now be ready and you can encrypt and decrypt your DNN db connection string on any server.


Screeshot

WebConfigEncryptor screenshot


Development

  1. Backup your db and file system. Install the module into your development enviroment.
  2. Clone the repo to your /DesktopModules/MVC/ directory.
  3. Navigate to directory and open the .sln with Visual Studio.
  4. You should be able to compile and attach the debugger at this point.

History

This module was used in house before it's public release at v1.0.0. DI support was added to the module which requires an installation be Dnn version 9.4 or greater.

Authors

i502 Club i502 Club

License

This project is licensed under the MIT License - see the LICENSE.txt file for details

Acknowledgments

  • All the contributors to DNN

Contribute

You can create an issue or submit a pull request to help make the module better.

About

DNN Module to encrypt web config data base connection strings

License:Other


Languages

Language:C# 81.9%Language:HTML 18.1%