Writing the SecretsManager
In this section, we are going to update our SecretsManager
class so that we can safely obtain secrets.
Note
Our development environment will use a secrets.json
file. This is very serious as private credentials have been found and accessed on source code hosting sites such as GitHub before now, and we don't want to be the ones responsible for checking in code that contains secrets that should be kept private.
Follow these steps:
- Add the following NuGet packages:
Microsoft.Extensions.Configuration Microsoft.Extensions.Configuration.JsonFile Microsoft.Extensions.Configuration.EnvironmentVariables Microsoft.Extensions.Configuration.UserSecrets
We need these packages so that we can configure the project for user secrets and appsettings.json
.
- Open the
SecretsManager
class and add the followingusing
statements:using Microsoft.Extensions.Configuration; using System; using System.IO;
We need these using
statements for our...