Path: redb-identity/src/redb.Identity.Core/Models/WebhookSubscriptionProps.cs
Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity
Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Core/Models/WebhookSubscriptionProps.cs
----
using redb.Core.Attributes;
namespace redb.Identity.Core.Models;
///
/// W1 — outbound webhook subscription. One row per HTTP endpoint that
/// receives identity events as POST bodies, signed with HMAC-SHA256.
///
///
/// Delivery semantics:
/// * Fire-and-forget from the originating mutation's perspective:
/// WebhookDeliveryRouteConsumer picks events off a
/// WireTap of the identity-events route and dispatches them
/// async, so a slow webhook receiver never back-pressures the
/// token endpoint or admin API.
/// * Per-subscription exponential backoff with retry limit. Failures
/// after retries are logged + audited as WebhookDeliveryFailed
/// so operators can wire alerting without leaving the audit log.
///
///
///
/// Filtering:
/// * = "*" — receive every event.
/// * Comma-separated list of CamelCase IDs from
/// IdentityAuditEventIds (e.g. "UserCreated,UserDeleted").
/// * Prefix cat: matches by category instead — e.g.
/// "cat:admin,cat:authentication" delivers every admin + auth event.
///
///
///
/// Signing:
/// * Body is canonical JSON of the IdentityEvent envelope.
/// * Header X-RedbIdentity-Signature = sha256=<hex> of
/// HMAC-SHA256(secret, body). GitHub-style — covers raw body
/// bytes only, so receivers verify with the standard HMAC-SHA256
/// recipe without canonical-payload-recomposition pitfalls.
/// * Header X-RedbIdentity-Timestamp = ISO-8601 UTC.
/// * Header X-RedbIdentity-Delivery = per-attempt GUID
/// (idempotency key the receiver can dedupe on).
/// * Header X-RedbIdentity-EventType = canonical event id.
/// Receivers verify by recomputing HMAC over timestamp + "." + body
/// using the shared secret. Reject the signature window beyond ±5min to
/// dampen replay; the timestamp + delivery id make replay detection
/// trivial.
///
///
[RedbScheme("identity.webhook_subscription")]
public class WebhookSubscriptionProps
{
/// Operator-facing label rendered in the admin UI.
public string? DisplayName { get; set; }
public string? Description { get; set; }
///
/// Absolute HTTP(S) URL the event is POSTed to. Validated at create
/// time — wildcards and fragments are rejected per common-sense
/// webhook security.
///
public string Url { get; set; } = "";
///
/// Filter expression — "*" (everything), comma-separated event ids,
/// or "cat:<category>" tokens (also comma-separable). Defaults
/// to "*" so a new subscription works without a follow-up edit.
///
public string EventTypeFilter { get; set; } = "*";
///
/// HMAC-SHA256 secret. Generated server-side on create (returned
/// once in the response) and rotated through the secret-rotate
/// endpoint. Receiver verifies signatures with this value.
///
public string HmacSecret { get; set; } = "";
/// Master enable switch — disabled subscriptions are skipped.
public bool Enabled { get; set; } = true;
/// Per-attempt timeout in milliseconds. Default 5000.
public int TimeoutMs { get; set; } = 5000;
///
/// Max delivery attempts (including the first). Exponential backoff
/// between retries: base * (2 ^ attempt). Default 3.
///
public int MaxAttempts { get; set; } = 3;
/// Backoff base in milliseconds. Default 500.
public int RetryBackoffMs { get; set; } = 500;
///
/// Extra HTTP headers attached to every delivery (e.g. an
/// operator-managed shared auth header). Reserved redb-internal
/// headers (`X-RedbIdentity-*`) override any clash.
///
public Dictionary? ExtraHeaders { get; set; }
///
/// Optional self-rolled concurrency token surfaced on update so a
/// stale admin tab can't silently overwrite a fresher mutation.
///
public string? ConcurrencyToken { get; set; }
}