Katragadda.Extensions.GoogleSecretManager 0.1.1

dotnet add package Katragadda.Extensions.GoogleSecretManager --version 0.1.1
                    
NuGet\Install-Package Katragadda.Extensions.GoogleSecretManager -Version 0.1.1
                    
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="Katragadda.Extensions.GoogleSecretManager" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Katragadda.Extensions.GoogleSecretManager" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Katragadda.Extensions.GoogleSecretManager" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Katragadda.Extensions.GoogleSecretManager --version 0.1.1
                    
#r "nuget: Katragadda.Extensions.GoogleSecretManager, 0.1.1"
                    
#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.
#:package Katragadda.Extensions.GoogleSecretManager@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Katragadda.Extensions.GoogleSecretManager&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Katragadda.Extensions.GoogleSecretManager&version=0.1.1
                    
Install as a Cake Tool

Katragadda.Extensions.GoogleSecretManager

Caching, auto-refreshing, typed-configuration wrapper around Google.Cloud.SecretManager.V1 for ASP.NET Core and generic-host .NET applications.

Why

Google's official .NET client for Secret Manager is intentionally a thin, low-level gRPC/REST client — it does not provide caching, background refresh, or idiomatic IOptions<T> binding. Every application that wants those things today has to hand-roll them. This library fills that gap, the way Spring Cloud GCP's Secret Manager starter does for the Java/Spring ecosystem (which already has this out of the box).

Install

dotnet add package Katragadda.Extensions.GoogleSecretManager

Quick start

services.AddGoogleSecretManagerCaching(options =>
{
    options.ProjectId = "my-gcp-project";
    options.CacheTtl = TimeSpan.FromMinutes(10);
    options.EnableBackgroundRefresh = true; // keeps cache warm proactively
});

// Anywhere in your app:
var client = serviceProvider.GetRequiredService<ICachingSecretManagerClient>();
var apiKey = await client.GetSecretValueAsync("my-api-key");

Typed configuration binding

services.AddOptions<MyApiOptions>()
    .BindSecret(sp => sp.GetRequiredService<ICachingSecretManagerClient>(),
                secretId: "my-api-key",
                (opts, value) => opts.ApiKey = value);

React to secret rotation

services.AddGoogleSecretManagerCaching(options =>
{
    options.ProjectId = "my-gcp-project";
    options.OnSecretChanged = (secretId, newValue) =>
    {
        // e.g. re-key a downstream client, log a rotation event
    };
});

Authentication

Uses Application Default Credentials via the underlying SecretManagerServiceClient — no action needed when running on GCP infrastructure (GKE Workload Identity, Cloud Run, etc.); run gcloud auth application-default login for local development.

How it works

  • ICachingSecretManagerClient.GetSecretValueAsync serves a cached value if within CacheTtl, otherwise fetches and caches.
  • When EnableBackgroundRefresh is true (default), a hosted BackgroundService proactively re-fetches every previously-resolved secret on BackgroundRefreshInterval, so callers rarely pay a synchronous fetch-latency cost.
  • OnSecretChanged fires only when a refresh observes an actual value change (new version published upstream), not on every refresh sweep.

Status

v0.1.0 — early release. Feedback and issues welcome.

License

MIT

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 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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
0.1.1 143 9/13/2026