Path: redb-identity/src/redb.Identity.Core/Models/PasswordResetTokenProps.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/PasswordResetTokenProps.cs ---- using System; using redb.Core.Attributes; namespace redb.Identity.Core.Models; /// /// N-4 (Session C): server-side material backing a single-use password-reset token. /// /// The token plaintext (32 bytes of CSPRNG, base64url-encoded) is returned exactly once /// from IPasswordResetTokenStore.IssueAsync for delivery via the e-mail channel; /// what we persist is sha256(pepper || token) (lowercase hex) so a database leak /// does not disclose live reset links. is a per-issuance random /// identifier carried on the reset URL alongside the plaintext so verify can locate the /// row in O(1). /// /// /// Consumption is single-use: flips to true atomically /// under LockForUpdate during verify, and subsequent attempts against the same /// are rejected regardless of token correctness. Expired /// ( < now) or consumed rows are reaped by a periodic /// cleanup route (analogous to timer://identity-mfa-otp-cleanup). /// /// [RedbScheme("identity.password_reset_token")] public class PasswordResetTokenProps { /// Random per-issuance identifier. Travels on the reset URL as ?jti=.... public string Jti { get; set; } = ""; /// Owner user id (joined to _users). Returned to the caller by verify. public long UserId { get; set; } /// /// sha256(pepper || tokenPlaintext), lowercase hex. Never store plaintext. /// Pepper is supplied by . /// public string TokenHash { get; set; } = ""; /// /// Id of the pepper was made with (). /// Null on rows written before 4.8.0: those are checked with the current pepper, then the previous ones. /// public string? PepperId { get; set; } /// Issue timestamp (UTC). public DateTimeOffset IssuedAt { get; set; } /// Absolute expiry — verify requests after this instant fail regardless of token. public DateTimeOffset ExpiresAt { get; set; } /// /// True once a successful verify has consumed the token. Mutated under LockForUpdate /// to enforce single-use semantics even under concurrent verify attempts. /// public bool Consumed { get; set; } /// /// Count of verify attempts (success+fail). Used by diagnostics and the cleanup route to /// surface abuse; not consulted directly for rate-limiting (that lives on the HTTP facade). /// public int Attempts { get; set; } /// /// The caller-supplied reset URL captured at issue time (the page that will host the /// reset form, e.g. https://app.example.com/reset-password). Recorded for audit /// and to enable optional cross-checks at verify time; the open-redirect / whitelist /// check itself is enforced at the HTTP facade against the configured allow-list. /// public string CallerResetUrl { get; set; } = ""; }