namespace Azaion.Common.Entities; /// /// AZ-531 — refresh-token session row. One row per issued refresh token. A /// "session family" is the chain of rotated sessions that all share the same /// ; reuse-detection keys off it. /// public class Session { public Guid Id { get; set; } public Guid UserId { get; set; } /// /// AZ-531 — sha256(opaque refresh) for interactive sessions. AZ-533 mission /// sessions have no refresh value and store NULL here. /// public string? RefreshHash { get; set; } public Guid FamilyId { get; set; } public DateTime IssuedAt { get; set; } public DateTime LastUsedAt { get; set; } public DateTime ExpiresAt { get; set; } public DateTime? RevokedAt { get; set; } public string? RevokedReason { get; set; } public Guid? ParentSessionId { get; set; } public DateTime FamilyStartedAt { get; set; } /// /// AZ-535 — audit trail for who revoked the session (user id of the admin or /// the user themselves on /logout). Null for system revocations (rotation, /// reuse detection, post-flight reconnect). /// public Guid? RevokedByUserId { get; set; } /// /// AZ-533 — session class. is the /// default refresh-backed interactive session (AZ-531); /// is a long-lived no-refresh token issued for a single UAV mission. /// public string Class { get; set; } = SessionClasses.Interactive; /// /// AZ-533 — for mission sessions: the aircraft (CompanionPC user) the mission /// token belongs to. Used by the auto-revoke-on-reconnect middleware. Null for /// interactive sessions. /// public Guid? AircraftId { get; set; } /// /// AZ-534 — true iff the session was created via an MFA-validated /login/mfa /// call. Refresh-token rotation reads this to keep the AMR claim stable across /// the session lifetime. /// public bool MfaAuthenticated { get; set; } } public static class SessionRevokedReasons { public const string Rotated = "rotated"; public const string ReuseDetected = "reuse_detected"; public const string LoggedOut = "logged_out"; public const string LoggedOutAll = "logged_out_all"; public const string AdminRevoked = "admin_revoked"; public const string PostFlightReconnect = "post_flight_reconnect"; public const string FamilyRevoked = "family_revoked"; } public static class SessionClasses { public const string Interactive = "interactive"; public const string Mission = "mission"; }