SecureRequest.GcpSecretManager 1.0.0

dotnet add package SecureRequest.GcpSecretManager --version 1.0.0
                    
NuGet\Install-Package SecureRequest.GcpSecretManager -Version 1.0.0
                    
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="SecureRequest.GcpSecretManager" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SecureRequest.GcpSecretManager" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SecureRequest.GcpSecretManager" />
                    
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 SecureRequest.GcpSecretManager --version 1.0.0
                    
#r "nuget: SecureRequest.GcpSecretManager, 1.0.0"
                    
#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 SecureRequest.GcpSecretManager@1.0.0
                    
#: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=SecureRequest.GcpSecretManager&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SecureRequest.GcpSecretManager&version=1.0.0
                    
Install as a Cake Tool

SecureRequest.GcpSecretManager

Google Cloud Secret Manager provider for the SecureRequest NuGet package.

Stores the RSA private key inside GCP Secret Manager instead of Redis/IDistributedCache, protected by IAM access control, Cloud Audit Logs, and optional CMEK encryption.


Installation

dotnet add package SecureRequest
dotnet add package SecureRequest.GcpSecretManager

Usage

Chain .WithGcpSecretManager() onto AddSecureRequest():

builder.Services
    .AddSecureRequest(builder.Configuration)
    .WithGcpSecretManager(projectId: "my-gcp-project");

Application Default Credentials (ADC) are used automatically — picks up Workload Identity in GKE, GOOGLE_APPLICATION_CREDENTIALS environment variable, and gcloud auth application-default login in development.


Custom secret ID

builder.Services
    .AddSecureRequest(builder.Configuration)
    .WithGcpSecretManager(
        projectId : "my-gcp-project",
        secretId  : "myapp-rsa-private-key");

Bring your own client (already in DI)

builder.Services.AddSingleton(SecretManagerServiceClient.Create());

builder.Services
    .AddSecureRequest(builder.Configuration)
    .WithGcpSecretManager(
        projectId     : "my-gcp-project",
        clientFactory : sp => sp.GetRequiredService<SecretManagerServiceClient>());

Required IAM permissions

Grant the service account running the application the following roles on the secret resource:

Role Purpose
roles/secretmanager.secretAccessor Read secret versions (AccessSecretVersion)
roles/secretmanager.secretVersionAdder Add new versions (AddSecretVersion)
roles/secretmanager.admin Create secret on first startup (CreateSecret) — can be reduced to secretVersionAdder after first run

Minimum policy (after secret is created):

roles/secretmanager.secretAccessor
roles/secretmanager.secretVersionAdder

How it works

  • First startup — if the secret doesn't exist, GcpSecretManagerKeyStorageProvider creates it (Automatic replication policy) and adds the first version.
  • Subsequent startups — reads the latest version to load the private key.
  • Key rotation — adds a new version. Previous versions remain accessible (useful for auditing) but latest points to the new key.

appsettings.json

No changes needed — SecureRequest options are bound from the same section:

"SecureRequest": {
  "Enabled": true,
  "EnableBodyEncryption": true,
  "EnableHmacSigning": true,
  "TimestampToleranceSeconds": 300,
  "NonceCacheTtlSeconds": 700,
  "SecuredMethods": ["POST", "PUT", "PATCH"],
  "ExcludedPaths": []
}

Note: IDistributedCache is still required for nonce anti-replay storage. Only the RSA private key moves to Secret Manager — nonces remain in Redis/in-memory cache.


Comparison

Default (Redis) GcpSecretManagerKeyStorageProvider
Key stored in Redis (plain Base64) GCP Secret Manager (AES-256 encrypted)
Access control Redis connection string IAM roles
Audit trail None Cloud Audit Logs
Encryption at rest Depends on Redis config AES-256 (optional CMEK)
Compliance Not sufficient for PCI-DSS / HIPAA Satisfies requirements

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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
1.0.0 34,264 6/12/2026