HoneyDrunk.Vault.EventGrid
0.8.0
dotnet add package HoneyDrunk.Vault.EventGrid --version 0.8.0
NuGet\Install-Package HoneyDrunk.Vault.EventGrid -Version 0.8.0
<PackageReference Include="HoneyDrunk.Vault.EventGrid" Version="0.8.0" />
<PackageVersion Include="HoneyDrunk.Vault.EventGrid" Version="0.8.0" />
<PackageReference Include="HoneyDrunk.Vault.EventGrid" />
paket add HoneyDrunk.Vault.EventGrid --version 0.8.0
#r "nuget: HoneyDrunk.Vault.EventGrid, 0.8.0"
#:package HoneyDrunk.Vault.EventGrid@0.8.0
#addin nuget:?package=HoneyDrunk.Vault.EventGrid&version=0.8.0
#tool nuget:?package=HoneyDrunk.Vault.EventGrid&version=0.8.0
HoneyDrunk.Vault.EventGrid
Azure Event Grid webhook helpers for HoneyDrunk.Vault. This package wires Key Vault rotation events into SecretCache invalidation so running workloads refresh rotated secrets within seconds instead of waiting on TTL.
Overview
This package is the transport glue for ADR-0006 Tier 3 rotation propagation. It is designed for hosts that already use HoneyDrunk.Vault and need to receive Azure Event Grid events raised by Azure Key Vault, validate the subscription handshake, authenticate inbound webhook requests, and invalidate cached secret names through ISecretCacheInvalidator.
Features:
- Parses
Microsoft.KeyVault.SecretNewVersionCreated - Accepts Event Grid schema and CloudEvents schema payloads
- Handles Event Grid subscription validation handshake
- Authenticates webhook requests with a shared secret resolved from
ISecretStore - Exposes ASP.NET Core endpoint mapping helpers
- Exposes a Functions-friendly handler wrapper
- Never logs secret values, only secret names
Installation
dotnet add package HoneyDrunk.Vault
dotnet add package HoneyDrunk.Vault.EventGrid
Prerequisites
- Azure Key Vault configured to emit Event Grid events
- An Azure Event Grid subscription targeting your application webhook
HoneyDrunk.Vaultconfigured with a provider capable of resolvingVaultInvalidationWebhookSecret- A host application using ASP.NET Core or Azure Functions
Quick Start
ASP.NET Core Minimal API
using HoneyDrunk.Vault.EventGrid.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddVault(...);
builder.Services.AddVaultEventGridInvalidation();
var app = builder.Build();
app.MapVaultInvalidationWebhook("/internal/vault/invalidate");
app.Run();
Azure Functions Friendly Wrapper
public sealed class VaultInvalidationFunction
{
private readonly VaultInvalidationFunctionHandler _handler;
public VaultInvalidationFunction(VaultInvalidationFunctionHandler handler)
{
_handler = handler;
}
public Task<VaultInvalidationWebhookResponse> RunAsync(
IReadOnlyDictionary<string, string?> headers,
string body,
CancellationToken cancellationToken)
{
return _handler.HandleAsync(headers, body, cancellationToken);
}
}
Authentication Model
Requests are authenticated by:
- Event Grid origin and subscription validation flow
- A shared secret header,
X-HoneyDrunk-Vault-Webhook-Secret
The expected shared secret value is not hardcoded and is not read from an environment variable. It is resolved from ISecretStore using the secret name VaultInvalidationWebhookSecret.
Event Handling
For Microsoft.KeyVault.SecretNewVersionCreated, the handler reads objectName from the event payload and calls ISecretCacheInvalidator.Invalidate(secretName).
That means:
- the cache entry for that secret name is removed
- the next
ISecretStore.GetSecretAsync(new SecretIdentifier(name))call fetches from the provider - callers continue resolving the latest version without pinning, preserving invariant 21
Example Event Shapes
Event Grid Schema
[
{
"eventType": "Microsoft.KeyVault.SecretNewVersionCreated",
"data": {
"objectName": "DbPassword"
}
}
]
CloudEvents Schema
[
{
"type": "Microsoft.KeyVault.SecretNewVersionCreated",
"data": {
"objectName": "DbPassword"
}
}
]
Best Practices
- Keep the webhook endpoint internal or network-restricted where possible.
- Store
VaultInvalidationWebhookSecretin the same secure Vault system as other application secrets. - Do not pin applications to a secret version when relying on cache invalidation.
- Treat cache TTL as a fallback safety net, not the primary propagation mechanism.
- Log only secret names and operational status, never secret values.
Related Packages
- HoneyDrunk.Vault
- HoneyDrunk.Vault.Providers.AzureKeyVault
- HoneyDrunk.Vault.Providers.AppConfiguration
License
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Azure.Messaging.EventGrid (>= 5.0.0)
- HoneyDrunk.Vault (>= 0.8.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on HoneyDrunk.Vault.EventGrid:
| Package | Downloads |
|---|---|
|
HoneyDrunk.Auth.AspNetCore
ASP.NET Core integration for HoneyDrunk.Auth. Provides middleware for JWT Bearer token authentication, HttpContext identity accessors, and seamless integration with ASP.NET Core's authentication pipeline. |
|
|
HoneyDrunk.Web.Rest.AspNetCore
ASP.NET Core integration for HoneyDrunk REST conventions. Provides middleware for correlation propagation, exception mapping, and request logging. Includes MVC filters for model validation, minimal API endpoint conventions, and JSON serialization defaults. Ensures consistent API responses across all services. |
|
|
HoneyDrunk.Data.AspNetCore
ASP.NET Core integration for HoneyDrunk.Data. Provides Event Grid Vault cache invalidation endpoint helpers for ADR-0006 secret rotation propagation. |
GitHub repositories
This package is not used by any popular GitHub repositories.
v0.8.0: Version alignment with the HoneyDrunk.Vault 0.8.0 release. No behavior change. See CHANGELOG.md for details.