| | | 1 | | using ArturRios.Data.Relational.Core.Entities; |
| | | 2 | | |
| | | 3 | | namespace ArturRios.Heimdall.Domain.Entities; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// A single-use recovery code for a person's two-factor authentication configuration (UC-37 step |
| | | 7 | | /// 4, FR-2F-05). Ten rows are created together when setup is confirmed, and again — replacing the |
| | | 8 | | /// previous ten — when UC-40 regenerates them. The plaintext code is returned to the caller |
| | | 9 | | /// exactly once, in the confirmation (or regeneration) response; only its hash is ever persisted |
| | | 10 | | /// (see §4.10 of the System Requirements Document). Never addressed by ID; reached through the |
| | | 11 | | /// owning <see cref="TwoFactorAuth" /> configuration. |
| | | 12 | | /// </summary> |
| | | 13 | | public class TwoFactorRecoveryCode : Entity<long> |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// Foreign key to the owning <see cref="TwoFactorAuth" /> configuration (internal Id). |
| | | 17 | | /// Required. |
| | | 18 | | /// </summary> |
| | 452 | 19 | | public long TwoFactorAuthId { get; set; } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Hash of the recovery code. §4.10 documents no per-code salt column — unlike |
| | | 23 | | /// <see cref="TwoFactorEmailCode" />, these are high-entropy random strings rather than |
| | | 24 | | /// user-chosen secrets, so a keyed/plain one-way hash is enough to keep the plaintext |
| | | 25 | | /// unrecoverable at rest. |
| | | 26 | | /// </summary> |
| | 1205 | 27 | | public byte[] CodeHash { get; set; } = []; |
| | | 28 | | |
| | | 29 | | /// <summary>Whether the code has already been consumed (UC-38).</summary> |
| | 435 | 30 | | public bool Used { get; set; } |
| | | 31 | | |
| | | 32 | | /// <summary>Timestamp the code was consumed; null until then.</summary> |
| | 41 | 33 | | public DateTime? UsedAt { get; set; } |
| | | 34 | | |
| | | 35 | | /// <summary>Creation timestamp.</summary> |
| | 0 | 36 | | public DateTime CreatedAt { get; set; } |
| | | 37 | | |
| | | 38 | | // Navigation properties |
| | | 39 | | |
| | | 40 | | /// <summary>The two-factor configuration this code was issued for.</summary> |
| | 0 | 41 | | public TwoFactorAuth TwoFactorAuth { get; set; } = null!; |
| | | 42 | | } |