Neolution.Extensions.Configuration.GoogleSecrets 1.1.3

Prefix Reserved
There is a newer version of this package available.
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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Neolution.Extensions.Configuration.GoogleSecrets" Version="1.1.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Neolution.Extensions.Configuration.GoogleSecrets --version 1.1.3                
#r "nuget: Neolution.Extensions.Configuration.GoogleSecrets, 1.1.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 of Version
  • 1.1.0
    • Migrated from .NET Standard 2.1 to .NET 6
  • 1.0.1-alpha
    • Initial Release
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.1 8,812 3/12/2024
1.3.0 147 3/12/2024
1.2.0 17,461 6/29/2023
1.1.9 172 6/29/2023
1.1.7 4,177 9/6/2022
1.1.6 5,641 5/16/2022
1.1.5 449 5/10/2022
1.1.4 579 5/10/2022
1.1.3 632 2/16/2022