Neolution.Extensions.Configuration.GoogleSecrets
1.1.3
Prefix Reserved
See the version list below for details.
dotnet add package Neolution.Extensions.Configuration.GoogleSecrets --version 1.1.3
NuGet\Install-Package Neolution.Extensions.Configuration.GoogleSecrets -Version 1.1.3
<PackageReference Include="Neolution.Extensions.Configuration.GoogleSecrets" Version="1.1.3" />
paket add Neolution.Extensions.Configuration.GoogleSecrets --version 1.1.3
#r "nuget: Neolution.Extensions.Configuration.GoogleSecrets, 1.1.3"
// Install Neolution.Extensions.Configuration.GoogleSecrets as a Cake Addin #addin nuget:?package=Neolution.Extensions.Configuration.GoogleSecrets&version=1.1.3 // Install Neolution.Extensions.Configuration.GoogleSecrets as a Cake Tool #tool nuget:?package=Neolution.Extensions.Configuration.GoogleSecrets&version=1.1.3
Neolution.Extensions.Configuration.GoogleSecrets
This package is a configuration provider that injects google secrets into the Microsoft.Extensions.Configuration
.
It is not recommended to store secrets like connection strings in the source code directly or in environment variables. The better approach is to use a secret provider like the secret manager for the google cloud eco system.
Usage
Install the package using your favourite method, for example:
dotnet add package Neolution.Extensions.Configuration.GoogleSecrets
Add the custom configuration provider to your IHostBuilder
:
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
...
.ConfigureAppConfiguration((_, configuration) =>
{
configuration.AddGoogleSecrets(options =>
{
options.ProjectName = "your-project-id";
});
});
}
Options
Name | Required | Description | Default |
---|---|---|---|
ProjectName | ✔️ | Specifies which project the secrets are read from. | null |
Filter | ❌ | A server side filter forwarded to the google api according to https://cloud.google.com/secret-manager/docs/filtering | null |
FilterFn | ❌ | A filter function that will be run after the secrets are read from google (client side filtering). Supplies the Google.Cloud.SecretManager.V1.Secret as parameter. If returned true the secret will be processed otherwise it will be ignored. |
secret => true |
MapFn | ❌ | A map function that will be run after the secrets have been filtered | secret.SecretName.SecretId.Replace("__", ":") |
VersionDictionary | ❌ | By default the latest version of each secret is taken. But you can specify a specific version in the form of a dictionary. Key is the secret id and value is the version to take. For example: {"MySecretId": "2"} |
null |
Overriding default appsettings.json values
You can override existing appsettings.json
values by making sure the MapFn
maps it to the correct path.
For example if we have the following appsettings.json
:
{
"Secrets": {
"MyGoogleSecret": "santa isn't real"
}
}
We can override it by making sure that the MapFn
maps it to Secrets:MyGoogleSecret
. With the default MapFn
the google secret would have to be called Secrets__MyGoogleSecret
.
Authentication
Authorization is done automatically when run inside google cloud. To test it outside of google cloud you need to set the environment variable GOOGLE_APPLICATION_CREDENTIALS
to the json file with your credentials. More details can be found here: https://cloud.google.com/docs/authentication/getting-started#setting_the_environment_variable. You can also set the environment variable via code, for example:
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "C:\\temp\\your-file.json");
Version History
- 1.1.3
- Updated nuget packages
- 1.1.2
- Fix github action to extract version from
PackageVersion
instead ofVersion
- Fix github action to extract version from
- 1.1.0
- Migrated from .NET Standard 2.1 to .NET 6
- 1.0.1-alpha
- Initial Release
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Google.Cloud.SecretManager.V1 (>= 1.8.0)
- Microsoft.Extensions.Configuration (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.