Tool to give security to the configurations of an ASPNET Core application by encrypting sensitive information and handling in a secure way
Framework | From | Latest | Current support |
---|---|---|---|
.Net Core 2.1 | 1.0.0 | 1.0.0 | :x: |
.Net Core 3.1 | 1.2.0 | Current | :heavy_check_mark: |
.NET 5.0 | 1.3.0 | Current | :heavy_check_mark: |
.NET 6.0 | 1.4.0 | Current | :heavy_check_mark: |
This tool allows to encrypt configuration sections on app.settings files, and decrypt the information in runtime adding those configuration as a singleton inside the application.
· Getting started:
Install ChustaSoft.Tools.SecureConfig package via NuGet Package manager
Setup a private key in a secure way (ie: as a environment variable), SecureConfig will use it for encrypt and decrypt the settings files
Create a Settings object inside the project, should match the section that will be encrypted
Add the AppSettings section in all the different environment appsettings
Configure the tool
If your project framework is .NET 6.0
var settings = builder.SetUpSecureConfig<AppSettings>(testApikey);
// [...] More stuff
// After build called from WebApplicationBuilder // [...] More stuff
app.EncryptSettings
If your project framework is under .NET Core 2.1, 3.1 or .NET 5.0
CreateHostBuilder(args)
.Build()
.EncryptSettings<AppSettings>(true)
.Run();
var settings = services.SetUpSecureConfig<AppSettings>(_configuration, testApikey);
In all TFM's and examples provided, for reference:
Inject the settings class object in the class that the project will need, SecureConfig manage this class as a Singleton in the application lifecycle
Configuration video tutorial (For versions under 6.0)
For deep configurations, visit this section of our current wiki
That's all!
Enjoy it and do not hesitate to contacts us for suggestions or doubts.