Add database layer (EF Core + Postgres) and Blazor Server admin site

- SOR.Database: 5 bounded-context DbContexts (identity, catalog, collection,
  bazaar, chat), all entities/enums, JSONB for card abilities, ServiceRegistration
  with per-context connection string fallback to "Default"
- SOR.Admin: Blazor Server (.NET 8) — card editor, account management, bazaar
  overview, feature flags; Identity + cookie auth; FallbackPolicy requires
  Admin/SuperAdmin role; login via minimal API form POST endpoint
- Directory.Packages.props: add Microsoft.AspNetCore.Identity.EntityFrameworkCore
- SOR.slnx: add SOR.Admin + SOR.Database to solution (11 projects, 0 errors, 0 warnings)

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-02-25 07:48:24 -05:00
co-authored by Claude Happy
parent d21adbc8d0
commit ee2891d38e
45 changed files with 2490 additions and 0 deletions
@@ -0,0 +1,28 @@
namespace SOR.Database.Entities.Identity;
using Microsoft.AspNetCore.Identity;
/// <summary>
/// Extends ASP.NET Core Identity's IdentityUser with SOR-specific profile fields.
///
/// Identity manages: email, password hash, lockout, two-factor, external logins.
/// We add: display name (in-game handle), avatar CDN URL, audit timestamps.
///
/// Ban handling uses Identity's built-in LockoutEnd + LockoutEnabled — no
/// separate ban table needed for basic bans. A separate audit log of ban
/// actions can be added later.
/// </summary>
public sealed class Account : IdentityUser<Guid>
{
/// <summary>Publicly visible in-game display name (not the login email).</summary>
public string? DisplayName { get; set; }
/// <summary>CDN URL to the player's avatar image.</summary>
public string? AvatarCdnUrl { get; set; }
/// <summary>UTC time the account was first created.</summary>
public DateTimeOffset CreatedAt { get; set; }
/// <summary>UTC time of the most recent successful login.</summary>
public DateTimeOffset? LastLoginAt { get; set; }
}
@@ -0,0 +1,34 @@
namespace SOR.Database.Entities.Identity;
/// <summary>
/// Tracks an issued session token so it can be explicitly revoked
/// (logout, password change, ban) before it naturally expires.
///
/// The raw token is never stored — only its SHA-256 hash is kept so
/// that a stolen database row cannot be replayed.
///
/// The Gateway validates tokens by hashing the incoming token and
/// looking it up here, checking RevokedAt == null and ExpiresAt > now.
/// </summary>
public sealed class AccountSession
{
public Guid Id { get; set; } = Guid.NewGuid();
/// <summary>Owner of this session. No FK to preserve cross-schema flexibility.</summary>
public Guid AccountId { get; set; }
/// <summary>SHA-256 hex digest of the raw session token.</summary>
public string TokenHash { get; set; } = string.Empty;
public DateTimeOffset CreatedAt { get; set; }
public DateTimeOffset ExpiresAt { get; set; }
/// <summary>Set when the session is explicitly invalidated (logout, ban, password change).</summary>
public DateTimeOffset? RevokedAt { get; set; }
public string? IpAddress { get; set; }
public string? UserAgent { get; set; }
/// <summary>Optional opaque device identifier supplied by the client.</summary>
public string? DeviceId { get; set; }
}