feat(website): stand up SOR.Website public game site

Adds the complete SOR.Website ASP.NET Core Razor Pages project:

Security architecture:
- SecurityHeadersMiddleware sets strict CSP (script-src/style-src 'self',
  form-action 'self', frame-ancestors 'none', object-src 'none')
  — all XSS injection is dead on arrival
- __Host- cookie prefix on session + CSRF cookies (forces Secure, Path=/,
  no Domain — prevents subdomain-compromise cookie theft)
- Anti-forgery tokens on every POST by default (Razor Pages default)
- AuthorizeFolder("/Account") — unauthenticated access to any /account/*
  redirected to login at the routing layer, no per-page [Authorize] needed
- Rate limiting per-IP: login (10/5min), register (5/hr), reset (3/15min)
- Open redirect prevention: all returnUrl values checked with Url.IsLocalUrl
- Anti-enumeration: ForgotPassword/Register never reveal whether email exists
- Account lockout: 5 failed login attempts → 30min lockout
- ChangePasswordAsync requires current password before accepting new one
- Leaderboard only projects DisplayName + RankScore (email/ID never exposed)
- Data Protection keys in Redis (shared key ring across pods)
- ForwardedHeaders middleware for accurate IP under TLS-terminating ingress

Pages implemented:
- Public: Home, Story, How To Play, Cards (catalog + detail), Leaderboard,
  AI Assets (explanation + report), News, Support, Privacy, Terms, Webclient
- Auth: Login, Register, Logout (POST-only), ForgotPassword, ResetPassword,
  VerifyEmail — all with rate limiting and anti-enumeration controls
- Account (auth-gated): Overview, Profile (display name), Security
  (change password), Game stats

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-04-22 19:51:04 -04:00
co-authored by Claude Happy
parent 08ef638950
commit c972b8687e
56 changed files with 4121 additions and 0 deletions
+1
View File
@@ -1,6 +1,7 @@
<Solution>
<Folder Name="/src/">
<Project Path="src/SOR.Admin/SOR.Admin.csproj" />
<Project Path="src/SOR.Website/SOR.Website.csproj" />
<Project Path="src/SOR.Tools/SOR.Tools.csproj" />
<Project Path="src/SOR.Auth/SOR.Auth.csproj" />
<Project Path="src/SOR.Bazaar/SOR.Bazaar.csproj" />
@@ -0,0 +1,44 @@
@page
@model GameModel
@{
ViewData["Title"] = "Game Stats";
var account = Model.AccountData!;
}
<div class="page-header">
<div class="container">
<h1>Game Stats</h1>
</div>
</div>
<div class="container account-layout">
<nav class="account-nav" aria-label="Account navigation">
<a href="/account" class="account-nav-link">Overview</a>
<a href="/account/profile" class="account-nav-link">Profile</a>
<a href="/account/security" class="account-nav-link">Security</a>
<a href="/account/game" class="account-nav-link active">Game Stats</a>
</nav>
<div class="account-content">
<div class="stat-grid">
<div class="stat-card">
<div class="stat-label">Rank Score</div>
<div class="stat-value">@account.RankScore</div>
</div>
<div class="stat-card">
<div class="stat-label">Origin Points</div>
<div class="stat-value">@account.OriginPoints</div>
</div>
</div>
@if (account.LastLoginAt.HasValue)
{
<p class="text-muted">Last session: @account.LastLoginAt.Value.ToString("f")</p>
}
<div class="coming-soon-block">
<p>Full match history and collection stats are coming in a future update.</p>
<a href="/leaderboard" class="btn btn-ghost">View Leaderboard</a>
</div>
</div>
</div>
@@ -0,0 +1,18 @@
namespace SOR.Website.Pages.Account;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using SOR.Database.Entities.Identity;
public sealed class GameModel(UserManager<Account> userManager) : PageModel
{
public Account? AccountData { get; private set; }
public async Task<IActionResult> OnGetAsync()
{
AccountData = await userManager.GetUserAsync(User);
if (AccountData is null) return RedirectToPage("/Auth/Logout");
return Page();
}
}
@@ -0,0 +1,46 @@
@page
@model IndexModel
@{
ViewData["Title"] = "Account";
var account = Model.AccountData!;
}
<div class="page-header">
<div class="container">
<h1>@(account.DisplayName ?? "Channeler")</h1>
<p class="account-since">Channeler since @account.CreatedAt.ToString("MMMM yyyy")</p>
</div>
</div>
<div class="container account-layout">
<nav class="account-nav" aria-label="Account navigation">
<a href="/account" class="account-nav-link active">Overview</a>
<a href="/account/profile" class="account-nav-link">Profile</a>
<a href="/account/security" class="account-nav-link">Security</a>
<a href="/account/game" class="account-nav-link">Game Stats</a>
</nav>
<div class="account-content">
<div class="stat-grid">
<div class="stat-card">
<div class="stat-label">Rank Score</div>
<div class="stat-value">@account.RankScore</div>
</div>
<div class="stat-card">
<div class="stat-label">Email</div>
@* Email shown only to the authenticated owner — never to other players. *@
<div class="stat-value stat-email">@account.Email</div>
@if (!account.EmailConfirmed)
{
<span class="badge badge-warn">Unverified</span>
}
</div>
</div>
<div class="quick-actions">
<a href="/webclient" class="btn btn-primary">Enter Mindscape</a>
<a href="/account/profile" class="btn btn-ghost">Edit Profile</a>
<a href="/account/security" class="btn btn-ghost">Security</a>
</div>
</div>
</div>
@@ -0,0 +1,36 @@
namespace SOR.Website.Pages.Account;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using SOR.Database.Entities.Identity;
/// <summary>
/// Account dashboard — authenticated users only.
/// Authorization is enforced by the AuthorizeFolder("/Account") convention in Program.cs.
///
/// Security controls:
/// - Data shown is scoped to the currently signed-in account only.
/// - Account ID comes from the validated session cookie, never from query string or form.
/// - Fields that must not be public (email, internal ID, moderation state) are only
/// accessible here behind authentication.
/// </summary>
public sealed class IndexModel(UserManager<Account> userManager) : PageModel
{
public Account? AccountData { get; private set; }
public async Task<IActionResult> OnGetAsync()
{
// GetUserAsync reads the account ID from the signed-in claims principal.
// It never trusts a user-supplied ID — the ID comes from the session cookie.
AccountData = await userManager.GetUserAsync(User);
if (AccountData is null)
{
// Session exists but account was deleted — sign out cleanly.
return RedirectToPage("/Auth/Logout");
}
return Page();
}
}
@@ -0,0 +1,40 @@
@page
@model ProfileModel
@{
ViewData["Title"] = "Edit Profile";
}
<div class="page-header">
<div class="container">
<h1>Profile</h1>
</div>
</div>
<div class="container account-layout">
<nav class="account-nav" aria-label="Account navigation">
<a href="/account" class="account-nav-link">Overview</a>
<a href="/account/profile" class="account-nav-link active">Profile</a>
<a href="/account/security" class="account-nav-link">Security</a>
<a href="/account/game" class="account-nav-link">Game Stats</a>
</nav>
<div class="account-content">
@if (Model.Saved)
{
<div class="alert alert-success" role="status">Profile updated.</div>
}
<form method="post" novalidate>
<div asp-validation-summary="ModelOnly" class="alert alert-error"></div>
<div class="form-group">
<label asp-for="Input.DisplayName">Display Name</label>
<input asp-for="Input.DisplayName" type="text" class="form-control">
<span asp-validation-for="Input.DisplayName" class="field-error"></span>
<small class="form-hint">This is your public in-game name. 3–32 characters.</small>
</div>
<button type="submit" class="btn btn-primary">Save Changes</button>
</form>
</div>
</div>
@@ -0,0 +1,74 @@
namespace SOR.Website.Pages.Account;
using System.ComponentModel.DataAnnotations;
using System.Security.Claims;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using SOR.Database.Entities.Identity;
/// <summary>
/// Allows the authenticated player to update their display name.
///
/// Security controls:
/// - Account ID comes from the session cookie (GetUserAsync), never from the form.
/// - DisplayName validation mirrors registration rules — no special characters
/// that could cause downstream injection.
/// - UpdateSecurityStampAsync after profile change causes existing sessions on
/// other devices to be re-validated within 30 minutes (the ValidationInterval).
/// - Anti-forgery token validated on POST.
/// </summary>
public sealed class ProfileModel(
UserManager<Account> userManager,
SignInManager<Account> signInManager) : PageModel
{
[BindProperty]
public InputModel Input { get; set; } = new();
public bool Saved { get; private set; }
public sealed class InputModel
{
[Required(ErrorMessage = "Display name is required.")]
[MinLength(3, ErrorMessage = "Display name must be at least 3 characters.")]
[MaxLength(32, ErrorMessage = "Display name cannot exceed 32 characters.")]
[RegularExpression(@"^[\w\- ]+$",
ErrorMessage = "Display name may only contain letters, digits, spaces, hyphens, and underscores.")]
public string DisplayName { get; set; } = string.Empty;
}
public async Task<IActionResult> OnGetAsync()
{
var account = await userManager.GetUserAsync(User);
if (account is null) return RedirectToPage("/Auth/Logout");
Input.DisplayName = account.DisplayName ?? string.Empty;
return Page();
}
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
return Page();
var account = await userManager.GetUserAsync(User);
if (account is null) return RedirectToPage("/Auth/Logout");
account.DisplayName = Input.DisplayName.Trim();
var result = await userManager.UpdateAsync(account);
if (!result.Succeeded)
{
foreach (var err in result.Errors)
ModelState.AddModelError(string.Empty, err.Description);
return Page();
}
// Refresh the session cookie so the nav bar immediately shows the new name.
var claims = new[] { new Claim("display_name", account.DisplayName ?? string.Empty) };
await signInManager.SignInWithClaimsAsync(account, isPersistent: false, claims);
Saved = true;
return Page();
}
}
@@ -0,0 +1,64 @@
@page
@model SecurityModel
@{
ViewData["Title"] = "Security";
}
<div class="page-header">
<div class="container">
<h1>Security</h1>
</div>
</div>
<div class="container account-layout">
<nav class="account-nav" aria-label="Account navigation">
<a href="/account" class="account-nav-link">Overview</a>
<a href="/account/profile" class="account-nav-link">Profile</a>
<a href="/account/security" class="account-nav-link active">Security</a>
<a href="/account/game" class="account-nav-link">Game Stats</a>
</nav>
<div class="account-content">
<h2>Change Password</h2>
@if (Model.Saved)
{
<div class="alert alert-success" role="status">
Password updated. All other active sessions will be signed out shortly.
</div>
}
<form method="post" novalidate>
<div asp-validation-summary="ModelOnly" class="alert alert-error"></div>
<div class="form-group">
<label asp-for="Input.CurrentPassword">Current Password</label>
<input asp-for="Input.CurrentPassword"
type="password"
autocomplete="current-password"
class="form-control">
<span asp-validation-for="Input.CurrentPassword" class="field-error"></span>
</div>
<div class="form-group">
<label asp-for="Input.NewPassword">New Password</label>
<input asp-for="Input.NewPassword"
type="password"
autocomplete="new-password"
class="form-control">
<span asp-validation-for="Input.NewPassword" class="field-error"></span>
</div>
<div class="form-group">
<label asp-for="Input.ConfirmPassword">Confirm New Password</label>
<input asp-for="Input.ConfirmPassword"
type="password"
autocomplete="new-password"
class="form-control">
<span asp-validation-for="Input.ConfirmPassword" class="field-error"></span>
</div>
<button type="submit" class="btn btn-primary">Update Password</button>
</form>
</div>
</div>
@@ -0,0 +1,80 @@
namespace SOR.Website.Pages.Account;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using SOR.Database.Entities.Identity;
/// <summary>
/// Allows the authenticated player to change their password.
///
/// Security controls:
/// - Requires the current password before accepting a new one. This prevents
/// an attacker who has seized an unlocked browser session from silently changing
/// credentials without knowing the existing password.
/// - ChangePasswordAsync validates both the current password and the new password's
/// strength rules via Identity.
/// - UpdateSecurityStampAsync is called by ChangePasswordAsync — this invalidates
/// all other active sessions within 30 minutes (the cookie ValidationInterval).
/// - Account ID from session, not from form input.
/// - Anti-forgery token validated on POST.
/// </summary>
public sealed class SecurityModel(
UserManager<Account> userManager,
SignInManager<Account> signInManager) : PageModel
{
[BindProperty]
public InputModel Input { get; set; } = new();
public bool Saved { get; private set; }
public sealed class InputModel
{
[Required(ErrorMessage = "Current password is required.")]
[DataType(DataType.Password)]
[MaxLength(128)]
public string CurrentPassword { get; set; } = string.Empty;
[Required(ErrorMessage = "New password is required.")]
[MinLength(8, ErrorMessage = "Password must be at least 8 characters.")]
[MaxLength(128)]
[DataType(DataType.Password)]
public string NewPassword { get; set; } = string.Empty;
[Required(ErrorMessage = "Please confirm your new password.")]
[DataType(DataType.Password)]
[Compare(nameof(NewPassword), ErrorMessage = "Passwords do not match.")]
public string ConfirmPassword { get; set; } = string.Empty;
}
public void OnGet() { }
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
return Page();
var account = await userManager.GetUserAsync(User);
if (account is null) return RedirectToPage("/Auth/Logout");
var result = await userManager.ChangePasswordAsync(
account, Input.CurrentPassword, Input.NewPassword);
if (result.Succeeded)
{
// Re-sign-in to refresh the cookie after the security stamp changes.
// Without this the cookie is rejected on the next request (30 min gap).
await signInManager.RefreshSignInAsync(account);
Saved = true;
return Page();
}
// Generic: "Incorrect current password" is acceptable — it does not help
// an attacker because they must first be authenticated to reach this page.
foreach (var err in result.Errors)
ModelState.AddModelError(string.Empty, err.Description);
return Page();
}
}
@@ -0,0 +1,79 @@
@page
@model IndexModel
@{
ViewData["Title"] = "AI Asset Disclosure";
ViewData["MetaDescription"] = "Aeternalis AI asset usage disclosure. How AI tools are used, reviewed, and tracked.";
}
<div class="page-header">
<div class="container">
<h1>AI Asset Disclosure</h1>
<p class="page-subtitle">How AI tools are used in Aeternalis, and how we track them.</p>
</div>
</div>
<div class="container prose-page">
<section class="prose-section">
<h2>Summary</h2>
<p>
Some visual and audio assets in Aeternalis were created with the assistance of AI generation tools.
Every AI-assisted asset has been reviewed and modified by a human before being used in the game.
This page explains how and why, and links to the full asset report.
</p>
</section>
<section class="prose-section">
<h2>Asset Categories That May Use AI Assistance</h2>
<ul>
<li><strong>Card art (2D illustrations)</strong> — some card art was generated or edited with AI tools.</li>
<li><strong>Placeholder assets</strong> — early development assets may be AI-generated pending final art.</li>
<li><strong>Promotional imagery</strong> — some marketing images may use AI assistance.</li>
</ul>
</section>
<section class="prose-section">
<h2>Asset Categories That Do Not Use AI Generation</h2>
<ul>
<li>Game rules, card text, and mechanics.</li>
<li>Lore, story, and world-building content.</li>
<li>Code and game systems.</li>
<li>3D board models (hand-crafted geometry).</li>
</ul>
</section>
<section class="prose-section">
<h2>Human Review and Editing Process</h2>
<p>
No AI-generated asset enters the game without human review. Reviewers check for:
inappropriate content, factual or lore inconsistencies, visual quality, and alignment
with the game's aesthetic. Assets may be edited, reprompted, or replaced entirely.
</p>
<p>
The status of each asset (Active, Replaced, Placeholder, Deprecated) is tracked in
the full report below.
</p>
</section>
<section class="prose-section">
<h2>Player-Facing Impact</h2>
<p>
AI-assisted assets are used for visual presentation only and have no effect on gameplay,
card mechanics, rules, or balance. The game's competitive systems are entirely human-designed.
</p>
</section>
<section class="prose-section">
<h2>Reporting and Contact</h2>
<p>
If you notice an asset that appears to be AI-generated but is not listed in the report,
or if you have questions about our AI asset policy, please contact us via the
<a href="/support">support page</a>.
</p>
</section>
<div class="prose-cta">
<a href="/ai-assets/report" class="btn btn-primary">View Full Asset Report</a>
</div>
</div>
@@ -0,0 +1,8 @@
namespace SOR.Website.Pages.AiAssets;
using Microsoft.AspNetCore.Mvc.RazorPages;
public sealed class IndexModel : PageModel
{
public void OnGet() { }
}
@@ -0,0 +1,87 @@
@page
@model ReportModel
@{
ViewData["Title"] = "AI Asset Report";
ViewData["MetaDescription"] = "Full searchable report of AI-assisted assets in Aeternalis.";
}
<div class="page-header">
<div class="container">
<h1>AI Asset Report</h1>
<p class="page-subtitle">@Model.TotalCount AI-assisted asset@(Model.TotalCount == 1 ? "" : "s") on record.</p>
</div>
</div>
<div class="container">
<form method="get" class="search-form" novalidate>
<div class="form-group form-inline">
<label for="search">Search assets</label>
<input type="search"
id="search"
name="search"
value="@Model.Search"
placeholder="Object key or prefix"
class="form-control"
maxlength="200">
<button type="submit" class="btn btn-primary">Search</button>
@if (!string.IsNullOrWhiteSpace(Model.Search))
{
<a href="/ai-assets/report" class="btn btn-ghost">Clear</a>
}
</div>
</form>
@if (!Model.Records.Any())
{
<div class="empty-state">
<p>No AI-assisted assets found@(!string.IsNullOrWhiteSpace(Model.Search) ? " matching your search" : "").</p>
</div>
}
else
{
<div class="table-wrapper">
<table class="data-table" aria-label="AI asset report">
<thead>
<tr>
<th scope="col">Object Key</th>
<th scope="col">Prefix</th>
<th scope="col">Type</th>
<th scope="col">Uploaded</th>
</tr>
</thead>
<tbody>
@foreach (var record in Model.Records)
{
<tr>
@* All values auto-encoded by Razor — no XSS *@
<td class="mono">@record.ObjectKey</td>
<td>@record.Prefix</td>
<td>@(record.ContentType ?? "—")</td>
<td>@record.UploadedAt.ToString("yyyy-MM-dd")</td>
</tr>
}
</tbody>
</table>
</div>
@if (Model.TotalPages > 1)
{
<nav class="pagination" aria-label="Page navigation">
@if (Model.CurrentPage > 1)
{
<a href="?page=@(Model.CurrentPage - 1)&search=@Model.Search" class="pagination-btn">Previous</a>
}
<span class="pagination-info">Page @Model.CurrentPage of @Model.TotalPages</span>
@if (Model.CurrentPage < Model.TotalPages)
{
<a href="?page=@(Model.CurrentPage + 1)&search=@Model.Search" class="pagination-btn">Next</a>
}
</nav>
}
}
<div class="report-footer">
<a href="/ai-assets" class="btn btn-ghost">AI Asset Overview</a>
</div>
</div>
@@ -0,0 +1,57 @@
namespace SOR.Website.Pages.AiAssets;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using SOR.Database.Contexts;
using SOR.Database.Entities.Catalog;
/// <summary>
/// Full searchable AI asset report sourced from the CdnUploadRecord table.
/// Records with IsAiGenerated = true are the AI-assisted assets.
///
/// Security controls:
/// - Read-only query from catalog — no user input modifies data.
/// - Search parameter used in a parameterized EF Core query only.
/// - Pagination prevents resource exhaustion.
/// </summary>
public sealed class ReportModel(CatalogDbContext catalog) : PageModel
{
public const int PageSize = 50;
public IReadOnlyList<CdnUploadRecord> Records { get; private set; } = [];
public int TotalCount { get; private set; }
public int CurrentPage { get; private set; } = 1;
public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
public string? Search { get; private set; }
public int PageNumber { get; private set; } = 1;
public async Task OnGetAsync(
[Microsoft.AspNetCore.Mvc.FromQuery] string? search,
[Microsoft.AspNetCore.Mvc.FromQuery] int page = 1)
{
Search = search;
PageNumber = Math.Max(1, page);
CurrentPage = PageNumber;
var query = catalog.CdnUploadRecords
.Where(r => r.IsAiGenerated)
.AsNoTracking();
if (!string.IsNullOrWhiteSpace(search))
{
var term = search.Trim();
query = query.Where(r =>
EF.Functions.ILike(r.ObjectKey, $"%{term}%") ||
EF.Functions.ILike(r.Prefix, $"%{term}%"));
}
TotalCount = await query.CountAsync();
Records = await query
.OrderByDescending(r => r.UploadedAt)
.Skip((CurrentPage - 1) * PageSize)
.Take(PageSize)
.ToListAsync();
}
}
@@ -0,0 +1,42 @@
@page
@model ForgotPasswordModel
@{
ViewData["Title"] = "Forgot Password";
}
<div class="auth-page">
<div class="auth-card">
<h1 class="auth-title">Reset Password</h1>
@if (Model.EmailSent)
{
<div class="alert alert-success" role="status">
If an account exists with that email, you'll receive a reset link shortly.
Check your spam folder if it doesn't arrive within a few minutes.
</div>
<a href="/auth/login" class="btn btn-ghost btn-block">Back to Login</a>
}
else
{
<p>Enter your account email and we'll send you a reset link.</p>
<form method="post" novalidate>
<div class="form-group">
<label asp-for="Input.Email">Email</label>
<input asp-for="Input.Email"
type="email"
autocomplete="email"
autofocus
class="form-control"
placeholder="you@example.com">
<span asp-validation-for="Input.Email" class="field-error"></span>
</div>
<button type="submit" class="btn btn-primary btn-block">Send Reset Link</button>
</form>
<div class="auth-links">
<a href="/auth/login">Back to Login</a>
</div>
}
</div>
</div>
@@ -0,0 +1,74 @@
namespace SOR.Website.Pages.Auth;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.RateLimiting;
using SOR.Database.Entities.Identity;
/// <summary>
/// Initiates password reset by sending a reset link to the supplied email.
///
/// Security controls:
/// - [EnableRateLimiting]: 3 attempts per IP per 15 minutes — limits reset spam.
/// - Anti-enumeration: ALWAYS shows the same success message regardless of whether
/// the email is registered. An attacker cannot probe which emails have accounts.
/// - Reset token generated by ASP.NET Core Identity's built-in TOTP token provider
/// (time-limited, single-use). The raw token is sent in the email link only.
/// - TODO: wire up an actual email provider. Until then the reset link is logged
/// (only in Development) so developers can test the flow.
/// </summary>
[EnableRateLimiting("auth-reset")]
public sealed class ForgotPasswordModel(
UserManager<Account> userManager,
ILogger<ForgotPasswordModel> logger) : PageModel
{
[BindProperty]
public InputModel Input { get; set; } = new();
public bool EmailSent { get; private set; }
public sealed class InputModel
{
[Required(ErrorMessage = "Email is required.")]
[EmailAddress(ErrorMessage = "Enter a valid email address.")]
[MaxLength(254)]
public string Email { get; set; } = string.Empty;
}
public void OnGet() { }
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
return Page();
// Look up the user — but do not reveal whether the email is registered.
var user = await userManager.FindByEmailAsync(Input.Email);
if (user is not null && !user.IsAi)
{
var token = await userManager.GeneratePasswordResetTokenAsync(user);
var resetLink = Url.Page(
"/Auth/ResetPassword",
pageHandler: null,
values: new { token, email = Input.Email },
protocol: Request.Scheme);
// TODO: send resetLink via email provider.
// Log in development only so the link is accessible for manual testing.
if (HttpContext.RequestServices
.GetRequiredService<IWebHostEnvironment>()
.IsDevelopment())
{
logger.LogWarning("DEV ONLY — password reset link for {Email}: {Link}",
Input.Email, resetLink);
}
}
// Always show the same message — anti-enumeration.
EmailSent = true;
return Page();
}
}
@@ -0,0 +1,55 @@
@page
@model LoginModel
@{
ViewData["Title"] = "Log In";
}
<div class="auth-page">
<div class="auth-card">
<h1 class="auth-title">Log In</h1>
@if (Model.ErrorMessage is not null)
{
<div class="alert alert-error" role="alert">@Model.ErrorMessage</div>
}
@* asp-page-handler is omitted — Razor Pages routes POST to OnPostAsync by default.
The form tag helper automatically injects the anti-forgery hidden field. *@
<form method="post" novalidate>
<input type="hidden" asp-for="ReturnUrl">
<div class="form-group">
<label asp-for="Input.Email">Email</label>
<input asp-for="Input.Email"
type="email"
autocomplete="email"
autofocus
class="form-control"
placeholder="you@example.com">
<span asp-validation-for="Input.Email" class="field-error"></span>
</div>
<div class="form-group">
<label asp-for="Input.Password">Password</label>
<input asp-for="Input.Password"
type="password"
autocomplete="current-password"
class="form-control">
<span asp-validation-for="Input.Password" class="field-error"></span>
</div>
<div class="form-group form-check">
<input asp-for="Input.RememberMe" type="checkbox" class="form-check-input" id="remember-me">
<label for="remember-me" class="form-check-label">Keep me signed in</label>
</div>
<button type="submit" class="btn btn-primary btn-block">Log In</button>
</form>
<div class="auth-links">
<a href="/auth/forgot-password">Forgot password?</a>
<span class="auth-sep" aria-hidden="true">&middot;</span>
<a href="/auth/register">Create an account</a>
</div>
</div>
</div>
@@ -0,0 +1,111 @@
namespace SOR.Website.Pages.Auth;
using System.ComponentModel.DataAnnotations;
using System.Security.Claims;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.RateLimiting;
using SOR.Database.Entities.Identity;
/// <summary>
/// Handles player login via email + password.
///
/// Security controls:
/// - [EnableRateLimiting]: 10 attempts per IP per 5 minutes.
/// - lockoutOnFailure: true in PasswordSignInAsync — Identity locks the account
/// after 5 failures, defeating unlimited brute-force.
/// - ReturnUrl validated with Url.IsLocalUrl before redirect — no open redirect.
/// - Anti-forgery token validated by Razor Pages on every POST (default behavior).
/// - Generic error message: does NOT confirm whether the email exists (no enumeration).
/// - SignInWithClaimsAsync adds the display_name custom claim so the nav bar can
/// show the player's handle without a DB round-trip per request.
/// </summary>
[EnableRateLimiting("auth-login")]
public sealed class LoginModel(
SignInManager<Account> signInManager,
UserManager<Account> userManager) : PageModel
{
[BindProperty]
public InputModel Input { get; set; } = new();
// returnUrl is injected by ASP.NET Core's cookie auth middleware when it
// redirects an unauthenticated request to the login page.
[BindProperty(SupportsGet = true)]
public string? ReturnUrl { get; set; }
public string? ErrorMessage { get; private set; }
public sealed class InputModel
{
[Required(ErrorMessage = "Email is required.")]
[EmailAddress(ErrorMessage = "Enter a valid email address.")]
[MaxLength(254)]
public string Email { get; set; } = string.Empty;
[Required(ErrorMessage = "Password is required.")]
[DataType(DataType.Password)]
[MaxLength(128)]
public string Password { get; set; } = string.Empty;
public bool RememberMe { get; set; }
}
public IActionResult OnGet()
{
// Already signed in — send them where they were going.
if (User.Identity?.IsAuthenticated == true)
return SafeRedirect(ReturnUrl);
return Page();
}
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
return Page();
// PasswordSignInAsync with lockoutOnFailure:true — after 5 failures the
// account is locked for 30 minutes (configured in Program.cs).
var result = await signInManager.PasswordSignInAsync(
Input.Email,
Input.Password,
Input.RememberMe,
lockoutOnFailure: true);
if (result.Succeeded)
{
// Add the display_name claim to the cookie so the layout can show
// the player's handle without a DB hit on every request.
var user = await userManager.FindByEmailAsync(Input.Email);
if (user is not null)
{
var extraClaims = new[]
{
new Claim("display_name", user.DisplayName ?? user.Email ?? string.Empty),
};
await signInManager.SignInWithClaimsAsync(user, Input.RememberMe, extraClaims);
}
return SafeRedirect(ReturnUrl);
}
if (result.IsLockedOut)
{
// Generic message — does not reveal whether the email exists.
ErrorMessage = "Too many failed attempts. Please try again later.";
return Page();
}
// Generic: do not confirm whether the email is registered (prevents enumeration).
ErrorMessage = "Invalid email or password.";
return Page();
}
// Ensures the redirect target is local to this application.
// Url.IsLocalUrl rejects absolute URLs and protocol-relative URLs,
// preventing open redirect attacks where an attacker crafts a link like
// /auth/login?returnUrl=https://evil.com
private IActionResult SafeRedirect(string? url)
=> Url.IsLocalUrl(url) ? LocalRedirect(url) : RedirectToPage("/Index");
}
@@ -0,0 +1,18 @@
@page
@model LogoutModel
@{
ViewData["Title"] = "Sign Out";
}
<div class="auth-page">
<div class="auth-card">
<h1 class="auth-title">Sign Out</h1>
<p>Are you sure you want to sign out?</p>
@* POST-only sign-out prevents CSRF-based forced logout via crafted GET links. *@
<form method="post">
<button type="submit" class="btn btn-primary">Sign Out</button>
<a href="/" class="btn btn-ghost">Cancel</a>
</form>
</div>
</div>
@@ -0,0 +1,33 @@
namespace SOR.Website.Pages.Auth;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using SOR.Database.Entities.Identity;
/// <summary>
/// Handles sign-out.
///
/// Security controls:
/// - Only responds to POST requests. A GET to /auth/logout shows a confirmation
/// page rather than signing out immediately. This prevents CSRF-based forced
/// logout via a crafted link (e.g., &lt;img src="/auth/logout"&gt; on an external site).
/// - Anti-forgery token is validated on POST (Razor Pages default).
/// - After sign-out, redirects to the home page — no returnUrl accepted here to
/// prevent the sign-out endpoint from being used as an open redirector.
/// </summary>
public sealed class LogoutModel(SignInManager<Account> signInManager) : PageModel
{
// GET: show a confirmation button.
// The confirmation step is a minor UX protection; the real protection is POST-only sign-out.
public void OnGet() { }
public async Task<IActionResult> OnPostAsync()
{
await signInManager.SignOutAsync();
// Always redirect to home — do not accept a returnUrl parameter here,
// as sign-out is a natural session termination point and accepting redirects
// would allow the endpoint to be used as an open redirector.
return RedirectToPage("/Index");
}
}
@@ -0,0 +1,71 @@
@page
@model RegisterModel
@{
ViewData["Title"] = "Create Account";
}
<div class="auth-page">
<div class="auth-card">
<h1 class="auth-title">Create Account</h1>
<p class="auth-subtitle">Begin your journey as a Channeler.</p>
<form method="post" novalidate>
<div asp-validation-summary="ModelOnly" class="alert alert-error"></div>
<div class="form-group">
<label asp-for="Input.Email">Email</label>
<input asp-for="Input.Email"
type="email"
autocomplete="email"
autofocus
class="form-control"
placeholder="you@example.com">
<span asp-validation-for="Input.Email" class="field-error"></span>
</div>
<div class="form-group">
<label asp-for="Input.DisplayName">Display Name</label>
<input asp-for="Input.DisplayName"
type="text"
autocomplete="nickname"
class="form-control"
placeholder="Your in-game handle">
<span asp-validation-for="Input.DisplayName" class="field-error"></span>
<small class="form-hint">3–32 characters. Letters, digits, spaces, hyphens, underscores.</small>
</div>
<div class="form-group">
<label asp-for="Input.Password">Password</label>
<input asp-for="Input.Password"
type="password"
autocomplete="new-password"
class="form-control">
<span asp-validation-for="Input.Password" class="field-error"></span>
<small class="form-hint">At least 8 characters, including an uppercase letter, digit, and symbol.</small>
</div>
<div class="form-group">
<label asp-for="Input.ConfirmPassword">Confirm Password</label>
<input asp-for="Input.ConfirmPassword"
type="password"
autocomplete="new-password"
class="form-control">
<span asp-validation-for="Input.ConfirmPassword" class="field-error"></span>
</div>
<div class="form-group form-check">
<input asp-for="Input.AcceptTerms" type="checkbox" class="form-check-input" id="accept-terms">
<label for="accept-terms" class="form-check-label">
I agree to the <a href="/terms">Terms of Service</a> and <a href="/privacy">Privacy Policy</a>.
</label>
<span asp-validation-for="Input.AcceptTerms" class="field-error"></span>
</div>
<button type="submit" class="btn btn-primary btn-block">Create Account</button>
</form>
<div class="auth-links">
Already have an account? <a href="/auth/login">Log in</a>
</div>
</div>
</div>
@@ -0,0 +1,114 @@
namespace SOR.Website.Pages.Auth;
using System.ComponentModel.DataAnnotations;
using System.Security.Claims;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.RateLimiting;
using SOR.Database.Entities.Identity;
/// <summary>
/// Handles new player registration.
///
/// Security controls:
/// - [EnableRateLimiting]: 5 registrations per IP per hour.
/// - Anti-forgery token validated on every POST.
/// - Generic error response: does NOT distinguish "email taken" from validation errors
/// so an attacker cannot probe whether an email is registered.
/// - DisplayName length and character restrictions prevent injection into downstream
/// systems that consume this value.
/// - Password strength is enforced by Identity (RequireDigit, RequireUppercase, etc.).
/// - CreatedAt set server-side — never from user input.
/// </summary>
[EnableRateLimiting("auth-register")]
public sealed class RegisterModel(
UserManager<Account> userManager,
SignInManager<Account> signInManager) : PageModel
{
[BindProperty]
public InputModel Input { get; set; } = new();
public bool Success { get; private set; }
public sealed class InputModel
{
[Required(ErrorMessage = "Email is required.")]
[EmailAddress(ErrorMessage = "Enter a valid email address.")]
[MaxLength(254)]
public string Email { get; set; } = string.Empty;
[Required(ErrorMessage = "Display name is required.")]
[MinLength(3, ErrorMessage = "Display name must be at least 3 characters.")]
[MaxLength(32, ErrorMessage = "Display name cannot exceed 32 characters.")]
// Allow letters, digits, spaces, hyphens, underscores only.
// This prevents special characters that could cause issues in downstream display.
[RegularExpression(@"^[\w\- ]+$",
ErrorMessage = "Display name may only contain letters, digits, spaces, hyphens, and underscores.")]
public string DisplayName { get; set; } = string.Empty;
[Required(ErrorMessage = "Password is required.")]
[MinLength(8, ErrorMessage = "Password must be at least 8 characters.")]
[MaxLength(128)]
[DataType(DataType.Password)]
public string Password { get; set; } = string.Empty;
[Required(ErrorMessage = "Please confirm your password.")]
[DataType(DataType.Password)]
[Compare(nameof(Password), ErrorMessage = "Passwords do not match.")]
public string ConfirmPassword { get; set; } = string.Empty;
[Range(typeof(bool), "true", "true",
ErrorMessage = "You must accept the terms and privacy policy.")]
public bool AcceptTerms { get; set; }
}
public void OnGet() { }
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
return Page();
var account = new Account
{
UserName = Input.Email, // Identity uses UserName as the login key
Email = Input.Email,
DisplayName = Input.DisplayName.Trim(),
CreatedAt = DateTimeOffset.UtcNow,
RankScore = 1000,
};
var result = await userManager.CreateAsync(account, Input.Password);
if (result.Succeeded)
{
// Sign in immediately with the display_name claim.
var claims = new[] { new Claim("display_name", account.DisplayName ?? string.Empty) };
await signInManager.SignInWithClaimsAsync(account, isPersistent: false, claims);
return RedirectToPage("/Account/Index");
}
// Do NOT enumerate specific errors back to the user (e.g. "email already taken").
// Instead surface a single generic message. Detailed validation errors (password
// strength, display name format) are acceptable — they don't expose account info.
//
// We do add Identity errors but filter out DuplicateEmail/DuplicateUserName to
// prevent account enumeration.
foreach (var error in result.Errors)
{
if (error.Code is "DuplicateEmail" or "DuplicateUserName")
{
// Generic message: attacker cannot learn whether the email is taken.
ModelState.AddModelError(string.Empty,
"Unable to create account. Please check your details and try again.");
}
else
{
ModelState.AddModelError(string.Empty, error.Description);
}
}
return Page();
}
}
@@ -0,0 +1,56 @@
@page
@model ResetPasswordModel
@{
ViewData["Title"] = "Reset Password";
}
<div class="auth-page">
<div class="auth-card">
<h1 class="auth-title">Reset Password</h1>
@if (Model.InvalidLink)
{
<div class="alert alert-error" role="alert">
This reset link is missing required parameters. Please request a new one.
</div>
<a href="/auth/forgot-password" class="btn btn-ghost btn-block">Request Reset Link</a>
}
else if (Model.Success)
{
<div class="alert alert-success" role="status">
Your password has been reset. You can now log in with your new password.
</div>
<a href="/auth/login" class="btn btn-primary btn-block">Log In</a>
}
else
{
<form method="post" novalidate>
@* Token and email from the reset link are hidden — not displayed to user. *@
<input type="hidden" asp-for="Input.Token">
<input type="hidden" asp-for="Input.Email">
<div asp-validation-summary="ModelOnly" class="alert alert-error"></div>
<div class="form-group">
<label asp-for="Input.NewPassword">New Password</label>
<input asp-for="Input.NewPassword"
type="password"
autocomplete="new-password"
class="form-control">
<span asp-validation-for="Input.NewPassword" class="field-error"></span>
</div>
<div class="form-group">
<label asp-for="Input.ConfirmPassword">Confirm New Password</label>
<input asp-for="Input.ConfirmPassword"
type="password"
autocomplete="new-password"
class="form-control">
<span asp-validation-for="Input.ConfirmPassword" class="field-error"></span>
</div>
<button type="submit" class="btn btn-primary btn-block">Set New Password</button>
</form>
}
</div>
</div>
@@ -0,0 +1,97 @@
namespace SOR.Website.Pages.Auth;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.RateLimiting;
using SOR.Database.Entities.Identity;
/// <summary>
/// Validates the reset token and applies a new password.
///
/// Security controls:
/// - [EnableRateLimiting]: 3 per IP per 15 minutes (shared with forgot-password policy).
/// - Anti-forgery token validated on POST.
/// - Token validated by Identity's built-in TOTP provider — single-use, time-limited.
/// - Generic error on invalid/expired token — no detail about why it failed.
/// - Email is supplied via query string from the reset link (not from user input).
/// It is bound server-side only for the lookup, not displayed back to the user
/// in a way that could introduce reflected content.
/// - Password must meet the same strength rules as registration (Identity enforces this).
/// </summary>
[EnableRateLimiting("auth-reset")]
public sealed class ResetPasswordModel(UserManager<Account> userManager) : PageModel
{
[BindProperty]
public InputModel Input { get; set; } = new();
public bool Success { get; private set; }
public bool InvalidLink { get; private set; }
public sealed class InputModel
{
// These two come from the query string in the emailed link.
// They are not displayed to the user — only used server-side.
[Required]
public string Token { get; set; } = string.Empty;
[Required]
[EmailAddress]
[MaxLength(254)]
public string Email { get; set; } = string.Empty;
[Required(ErrorMessage = "New password is required.")]
[MinLength(8, ErrorMessage = "Password must be at least 8 characters.")]
[MaxLength(128)]
[DataType(DataType.Password)]
public string NewPassword { get; set; } = string.Empty;
[Required(ErrorMessage = "Please confirm your new password.")]
[DataType(DataType.Password)]
[Compare(nameof(NewPassword), ErrorMessage = "Passwords do not match.")]
public string ConfirmPassword { get; set; } = string.Empty;
}
public IActionResult OnGet([FromQuery] string? token, [FromQuery] string? email)
{
if (string.IsNullOrWhiteSpace(token) || string.IsNullOrWhiteSpace(email))
{
InvalidLink = true;
return Page();
}
Input.Token = token;
Input.Email = email;
return Page();
}
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
return Page();
var user = await userManager.FindByEmailAsync(Input.Email);
// If the user doesn't exist, still show success (anti-enumeration).
if (user is null || user.IsAi)
{
Success = true;
return Page();
}
var result = await userManager.ResetPasswordAsync(user, Input.Token, Input.NewPassword);
if (result.Succeeded)
{
Success = true;
return Page();
}
// Generic message — does not reveal whether the token expired, was already used,
// or the email was wrong. All failure modes look the same to the requester.
ModelState.AddModelError(string.Empty,
"This reset link is invalid or has expired. Please request a new one.");
return Page();
}
}
@@ -0,0 +1,34 @@
@page
@model VerifyEmailModel
@{
ViewData["Title"] = "Verify Email";
}
<div class="auth-page">
<div class="auth-card">
<h1 class="auth-title">Email Verification</h1>
@if (Model.Success)
{
<div class="alert alert-success" role="status">
Your email has been verified. Your account is fully active.
</div>
<a href="/account" class="btn btn-primary btn-block">Go to Account</a>
}
else if (Model.AlreadyVerified)
{
<div class="alert alert-info" role="status">
Your email is already verified.
</div>
<a href="/account" class="btn btn-ghost btn-block">Go to Account</a>
}
else
{
<div class="alert alert-error" role="alert">
This verification link is invalid or has expired.
Please log in and request a new verification email.
</div>
<a href="/auth/login" class="btn btn-ghost btn-block">Log In</a>
}
</div>
</div>
@@ -0,0 +1,55 @@
namespace SOR.Website.Pages.Auth;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using SOR.Database.Entities.Identity;
/// <summary>
/// Confirms a player's email address via a one-time token link.
///
/// Security controls:
/// - Token validated by Identity's built-in provider (single-use, time-limited).
/// - Generic error shown on failure — no detail about whether email or token was wrong.
/// - This page does not require authentication — players reach it by clicking a link
/// in their registration email before they're signed in.
/// </summary>
public sealed class VerifyEmailModel(UserManager<Account> userManager) : PageModel
{
public bool Success { get; private set; }
public bool AlreadyVerified { get; private set; }
public bool Failed { get; private set; }
public async Task<IActionResult> OnGetAsync(
[FromQuery] string? userId,
[FromQuery] string? token)
{
if (string.IsNullOrWhiteSpace(userId) || string.IsNullOrWhiteSpace(token))
{
Failed = true;
return Page();
}
var user = await userManager.FindByIdAsync(userId);
if (user is null)
{
// Anti-enumeration: don't reveal that the userId is invalid.
Failed = true;
return Page();
}
if (user.EmailConfirmed)
{
AlreadyVerified = true;
return Page();
}
var result = await userManager.ConfirmEmailAsync(user, token);
if (result.Succeeded)
Success = true;
else
Failed = true;
return Page();
}
}
@@ -0,0 +1,113 @@
@page "{id:guid}"
@model DetailsModel
@{
var card = Model.Card!;
}
<div class="page-header">
<div class="container">
<nav class="breadcrumb" aria-label="Breadcrumb">
<a href="/cards">Cards</a>
<span aria-hidden="true">/</span>
<span aria-current="page">@card.Name</span>
</nav>
</div>
</div>
<div class="container card-detail-layout">
<div class="card-detail-art">
@* Art loaded from CDN — URL auto-encoded by Razor *@
@{
var art = card.Assets.FirstOrDefault(a => a.AssetType == SOR.Database.Enums.CardAssetType.Art2D);
}
@if (art is not null)
{
<img src="@art.CdnUrl" alt="Art for @card.Name" class="card-art-full" loading="lazy">
}
else
{
<div class="card-art-placeholder" aria-label="No art available"></div>
}
</div>
<div class="card-detail-info">
<h1 class="card-detail-name">@card.Name</h1>
<div class="card-detail-meta">
<span class="card-badge card-type">@card.CardType</span>
<span class="card-badge card-affinity affinity-@card.Affinity.ToString().ToLower()">@card.Affinity</span>
<span class="card-badge card-rarity rarity-@card.Rarity.ToString().ToLower()">@card.Rarity</span>
@if (card.Set is not null)
{
<span class="card-badge card-set">@card.Set.Name</span>
}
</div>
@if (card.SpCost > 0 || card.StCost > 0)
{
<div class="card-costs">
@if (card.SpCost > 0) { <span class="cost-chip cost-sp">@card.SpCost SP</span> }
@if (card.StCost > 0) { <span class="cost-chip cost-st">@card.StCost ST</span> }
</div>
}
@if (card.MaxHealth.HasValue || card.Damage.HasValue)
{
<div class="card-stats">
@if (card.Damage.HasValue) { <div class="stat"><span>ATK</span><strong>@card.Damage</strong></div> }
@if (card.MaxHealth.HasValue) { <div class="stat"><span>HP</span><strong>@card.MaxHealth</strong></div> }
@if (card.MaxDefense.HasValue) { <div class="stat"><span>DEF</span><strong>@card.MaxDefense</strong></div> }
@if (card.MovementPoints.HasValue) { <div class="stat"><span>MOV</span><strong>@card.MovementPoints</strong></div> }
</div>
}
<div class="card-description">
@* card.Description is plain text from the database — Razor auto-encodes it *@
<p>@card.Description</p>
</div>
@if (card.Genus is { Length: > 0 })
{
<div class="card-genus">
@foreach (var g in card.Genus)
{
<span class="genus-tag">@g</span>
}
</div>
}
@if (card.PreviousTier is not null)
{
<div class="card-chain">
<span>Ascends from:</span>
<a href="/cards/@card.PreviousTier.Id" class="card-chain-link">@card.PreviousTier.Name</a>
</div>
}
<div class="card-detail-actions">
<a href="/cards" class="btn btn-ghost">Back to Catalog</a>
</div>
</div>
</div>
@if (Model.RelatedCards.Any())
{
<section class="container related-cards">
<h2>Related Cards</h2>
<div class="card-grid card-grid-compact">
@foreach (var related in Model.RelatedCards)
{
<a href="/cards/@related.Id" class="card-tile">
<div class="card-tile-info">
<div class="card-tile-name">@related.Name</div>
<div class="card-tile-meta">
<span class="card-type">@related.CardType</span>
<span class="card-affinity">@related.Affinity</span>
</div>
</div>
</a>
}
</div>
</section>
}
@@ -0,0 +1,58 @@
namespace SOR.Website.Pages.Cards;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using SOR.Database.Contexts;
using SOR.Database.Entities.Catalog;
using SOR.Database.Enums;
/// <summary>
/// Individual card detail page.
///
/// Security controls:
/// - Card ID is a GUID — cannot be manipulated to traverse to other resources.
/// - Only published, non-retired cards are shown; unpublished cards return 404.
/// - All card data rendered through Razor's auto-encoding (no Html.Raw).
/// </summary>
public sealed class DetailsModel(CatalogDbContext catalog) : PageModel
{
public CardDefinition? Card { get; private set; }
public IList<CardDefinition> RelatedCards { get; private set; } = [];
public async Task<IActionResult> OnGetAsync(Guid id)
{
Card = await catalog.CardDefinitions
.Include(c => c.Set)
.Include(c => c.Assets)
.Include(c => c.PreviousTier)
.Where(c => c.Id == id && c.IsPublished && !c.IsRetired && c.CardType != CardType.SpiritToken)
.AsNoTracking()
.FirstOrDefaultAsync();
if (Card is null)
return NotFound();
// Load related cards: same set, same type, different card
if (Card.SetId.HasValue)
{
RelatedCards = await catalog.CardDefinitions
.Where(c => c.SetId == Card.SetId
&& c.CardType == Card.CardType
&& c.Id != Card.Id
&& c.IsPublished
&& !c.IsRetired)
.OrderBy(c => c.Name)
.Take(6)
.AsNoTracking()
.ToListAsync();
}
ViewData["Title"] = Card.Name;
ViewData["MetaDescription"] = Card.Description.Length > 160
? Card.Description[..160]
: Card.Description;
return Page();
}
}
@@ -0,0 +1,145 @@
@page
@model IndexModel
@{
ViewData["Title"] = "Card Catalog";
ViewData["MetaDescription"] = "Browse the complete Aeternalis card catalog. Filter by type, affinity, set, and rarity.";
}
<div class="page-header">
<div class="container">
<h1>Card Catalog</h1>
<p class="page-subtitle">@Model.TotalCount card@(Model.TotalCount == 1 ? "" : "s") found</p>
</div>
</div>
<div class="container catalog-layout">
<aside class="catalog-filters">
<form method="get" id="filter-form" novalidate>
<div class="filter-group">
<label for="Search">Search</label>
@* Search value auto-encoded by Razor — no XSS *@
<input type="search"
id="Search"
name="Search"
value="@Model.Search"
placeholder="Name or rules text"
class="form-control"
maxlength="100">
</div>
<div class="filter-group">
<label for="Type">Card Type</label>
<select id="Type" name="Type" class="form-control">
<option value="">All Types</option>
@foreach (var t in Enum.GetValues<SOR.Database.Enums.CardType>()
.Where(t => t != SOR.Database.Enums.CardType.SpiritToken))
{
<option value="@t" selected="@(Model.Type == t)">@t</option>
}
</select>
</div>
<div class="filter-group">
<label for="FilterAffinity">Affinity</label>
<select id="FilterAffinity" name="FilterAffinity" class="form-control">
<option value="">All Affinities</option>
@foreach (var a in Enum.GetValues<SOR.Database.Enums.Affinity>())
{
<option value="@a" selected="@(Model.FilterAffinity == a)">@a</option>
}
</select>
</div>
<div class="filter-group">
<label for="SetId">Set</label>
<select id="SetId" name="SetId" class="form-control">
<option value="">All Sets</option>
@foreach (var s in Model.CardSets)
{
<option value="@s.Id" selected="@(Model.SetId == s.Id)">@s.Name</option>
}
</select>
</div>
<div class="filter-group">
<label for="Rarity">Rarity</label>
<select id="Rarity" name="Rarity" class="form-control">
<option value="">All Rarities</option>
@foreach (var r in Enum.GetValues<SOR.Database.Enums.CardRarity>())
{
<option value="@r" selected="@(Model.Rarity == r)">@r</option>
}
</select>
</div>
<div class="filter-group">
<label for="Sort">Sort</label>
<select id="Sort" name="Sort" class="form-control">
<option value="name" selected="@(Model.Sort == "name" || Model.Sort == null)">Name (A–Z)</option>
<option value="cost-asc" selected="@(Model.Sort == "cost-asc")">Cost (Low–High)</option>
<option value="cost-desc" selected="@(Model.Sort == "cost-desc")">Cost (High–Low)</option>
<option value="rarity" selected="@(Model.Sort == "rarity")">Rarity</option>
<option value="newest" selected="@(Model.Sort == "newest")">Newest</option>
</select>
</div>
<button type="submit" class="btn btn-primary btn-block">Apply Filters</button>
<a href="/cards" class="btn btn-ghost btn-block">Clear All</a>
</form>
</aside>
<section class="catalog-results" aria-label="Card results">
@if (!Model.Cards.Any())
{
<div class="empty-state">
<p>No cards match your filters.</p>
<a href="/cards" class="btn btn-ghost">Clear Filters</a>
</div>
}
else
{
<div class="card-grid">
@foreach (var card in Model.Cards)
{
<a href="/cards/@card.Id" class="card-tile" aria-label="@card.Name">
<div class="card-tile-art" aria-hidden="true">
@* Art URL rendered as-is from CDN; Razor encodes it automatically *@
</div>
<div class="card-tile-info">
<div class="card-tile-name">@card.Name</div>
<div class="card-tile-meta">
<span class="card-type">@card.CardType</span>
<span class="card-affinity">@card.Affinity</span>
</div>
@if (card.SpCost > 0 || card.StCost > 0)
{
<div class="card-cost">
@if (card.SpCost > 0) { <span class="cost-sp">@card.SpCost SP</span> }
@if (card.StCost > 0) { <span class="cost-st">@card.StCost ST</span> }
</div>
}
</div>
</a>
}
</div>
@if (Model.TotalPages > 1)
{
<nav class="pagination" aria-label="Page navigation">
@if (Model.CurrentPage > 1)
{
<a href="?pageNumber=@(Model.CurrentPage - 1)&search=@Model.Search&type=@Model.Type&filterAffinity=@Model.FilterAffinity&setId=@Model.SetId&rarity=@Model.Rarity&sort=@Model.Sort"
class="pagination-btn">Previous</a>
}
<span class="pagination-info">Page @Model.CurrentPage of @Model.TotalPages</span>
@if (Model.CurrentPage < Model.TotalPages)
{
<a href="?pageNumber=@(Model.CurrentPage + 1)&search=@Model.Search&type=@Model.Type&filterAffinity=@Model.FilterAffinity&setId=@Model.SetId&rarity=@Model.Rarity&sort=@Model.Sort"
class="pagination-btn">Next</a>
}
</nav>
}
}
</section>
</div>
@@ -0,0 +1,106 @@
namespace SOR.Website.Pages.Cards;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using SOR.Database.Contexts;
using SOR.Database.Entities.Catalog;
using SOR.Database.Enums;
/// <summary>
/// Public card catalog. Displays published, non-retired cards with filtering and search.
///
/// Security controls:
/// - Only published, non-retired, non-SpiritToken cards are returned (server-side filter).
/// - All query parameters are strongly typed and validated — no raw SQL injection surface.
/// - Search input is passed as an EF Core parameterized query (never string-concatenated).
/// - Pagination prevents resource exhaustion from loading the entire catalog at once.
/// </summary>
public sealed class IndexModel(CatalogDbContext catalog) : PageModel
{
public const int PageSize = 32;
public IReadOnlyList<CardDefinition> Cards { get; private set; } = [];
public int TotalCount { get; private set; }
public int CurrentPage { get; private set; } = 1;
public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
// Filter state (all bound from query string — never from POST body)
[BindProperty(SupportsGet = true)]
public string? Search { get; set; }
[BindProperty(SupportsGet = true)]
public CardType? Type { get; set; }
[BindProperty(SupportsGet = true)]
public Affinity? FilterAffinity { get; set; }
[BindProperty(SupportsGet = true)]
public CardRarity? Rarity { get; set; }
[BindProperty(SupportsGet = true)]
public int PageNumber { get; set; } = 1;
[BindProperty(SupportsGet = true)]
public string? Sort { get; set; }
public IList<CardSet> CardSets { get; private set; } = [];
[BindProperty(SupportsGet = true)]
public Guid? SetId { get; set; }
public async Task OnGetAsync()
{
// Clamp page to valid range
CurrentPage = Math.Max(1, PageNumber);
CardSets = await catalog.CardSets
.OrderBy(s => s.Name)
.AsNoTracking()
.ToListAsync();
// Base query: published + non-retired + no SpiritToken (internal engine card type)
var query = catalog.CardDefinitions
.Include(c => c.Set)
.Where(c => c.IsPublished && !c.IsRetired && c.CardType != CardType.SpiritToken)
.AsNoTracking();
// Filters — all applied as parameterized predicates (no string formatting)
if (!string.IsNullOrWhiteSpace(Search))
{
var term = Search.Trim().ToLower();
query = query.Where(c =>
EF.Functions.ILike(c.Name, $"%{term}%") ||
EF.Functions.ILike(c.Description, $"%{term}%"));
}
if (Type.HasValue)
query = query.Where(c => c.CardType == Type.Value);
if (FilterAffinity.HasValue)
query = query.Where(c => c.Affinity == FilterAffinity.Value);
if (Rarity.HasValue)
query = query.Where(c => c.Rarity == Rarity.Value);
if (SetId.HasValue)
query = query.Where(c => c.SetId == SetId.Value);
// Sorting
query = (Sort ?? "name") switch
{
"cost-asc" => query.OrderBy(c => c.SpCost).ThenBy(c => c.Name),
"cost-desc" => query.OrderByDescending(c => c.SpCost).ThenBy(c => c.Name),
"rarity" => query.OrderByDescending(c => c.Rarity).ThenBy(c => c.Name),
"newest" => query.OrderByDescending(c => c.CreatedAt),
_ => query.OrderBy(c => c.Name),
};
TotalCount = await query.CountAsync();
Cards = await query
.Skip((CurrentPage - 1) * PageSize)
.Take(PageSize)
.ToListAsync();
}
}
@@ -0,0 +1,170 @@
@page
@model HowToPlayModel
@{
ViewData["Title"] = "How To Play";
ViewData["MetaDescription"] = "Learn the rules of Aeternalis. Channel Archspirits, shape the mindscape with Terramorpha, and survive the psychic assault.";
}
<div class="page-header">
<div class="container">
<h1>How To Play</h1>
<p class="page-subtitle">Everything you need to know to enter the mindscape.</p>
</div>
</div>
<div class="container howto-page">
<nav class="howto-nav" aria-label="Rules sections">
<a href="#what-is-aeternalis">What is Aeternalis?</a>
<a href="#channelers">Channelers</a>
<a href="#how-to-win">How to Win</a>
<a href="#card-types">Card Types</a>
<a href="#resources">Resources</a>
<a href="#turn-structure">Turn Structure</a>
<a href="#combat">Combat</a>
<a href="#terramorpha">Terramorpha</a>
<a href="#sacrifice">Sacrifice</a>
<a href="#glossary">Glossary</a>
</nav>
<div class="howto-content">
<section id="what-is-aeternalis" class="howto-section">
<h2>What is Aeternalis?</h2>
<p>
Aeternalis is a tactical strategy card game played in a constructed mindscape.
Two Channelers face off, each commanding Archspirits, Spirits, Terramorpha, and other cards
drawn from their deck. The battlefield is a grid of affinity tiles that both players shape
during play.
</p>
</section>
<section id="channelers" class="howto-section">
<h2>What is a Channeler?</h2>
<p>
You are the Channeler — the player. You reach into the Origin Stone to summon Archspirits,
cast Instincts, lay Terramorpha, and shape the battlefield. Your Channeler does not have
its own card: you <em>are</em> the will behind every action.
</p>
</section>
<section id="how-to-win" class="howto-section">
<h2>How to Win</h2>
<p>
Reduce your opponent's Channeler to zero life points. Life is lost when your opponent's
units deal unblocked damage to you directly. Build your board, control the terrain, and
press the assault.
</p>
</section>
<section id="card-types" class="howto-section">
<h2>Card Types</h2>
<dl class="card-type-list">
<dt>ArchSpirit</dt>
<dd>Powerful multi-tier units that evolve through Ascension. The core of most strategies.</dd>
<dt>Spirit</dt>
<dd>Smaller units that can be sacrificed to fuel growth and resource mechanics.</dd>
<dt>Terramorpha</dt>
<dd>Land-shaping cards that change the affinity of tiles on the battlefield.</dd>
<dt>Instinct</dt>
<dd>Instant-speed effects that can be played during your opponent's turn.</dd>
<dt>Repentance</dt>
<dd>Slow powerful effects that require preparation and setup.</dd>
<dt>Ruin</dt>
<dd>Persistent enchantments that modify the rules of the game while in play.</dd>
</dl>
</section>
<section id="resources" class="howto-section">
<h2>Resources and Costs</h2>
<p>
Cards cost <strong>SP</strong> (Spirit Points) and <strong>ST</strong> (Soul Tokens) to play.
SP regenerates each turn. ST is earned through sacrifice and specific card effects.
Managing both resources is the central economic challenge of Aeternalis.
</p>
</section>
<section id="turn-structure" class="howto-section">
<h2>Turn Structure</h2>
<ol class="turn-steps">
<li><strong>Draw</strong> — Draw one card from your deck.</li>
<li><strong>Upkeep</strong> — Trigger start-of-turn effects. SP regenerates.</li>
<li><strong>Main Phase</strong> — Play cards, move units, use abilities.</li>
<li><strong>Combat Phase</strong> — Declare attackers. Opponent declares blockers.</li>
<li><strong>End Phase</strong> — Discard down to hand limit. End-of-turn effects trigger.</li>
</ol>
</section>
<section id="combat" class="howto-section">
<h2>Combat and Targeting</h2>
<p>
Units attack in the direction they face. Melee units must be adjacent to their target.
Ranged units attack within their range, requiring line-of-sight unless otherwise stated.
Flight units can only be blocked by other Flight units.
</p>
</section>
<section id="terramorpha" class="howto-section">
<h2>Terramorpha and Land Shaping</h2>
<p>
Terramorpha cards reshape the affinity tiles on the battlefield. Units require matching
affinity tiles to be channeled. Control the terrain to control what your opponent can summon.
Mono Terramorpha changes one tile; Di changes two adjacent tiles; Tri changes three.
</p>
</section>
<section id="sacrifice" class="howto-section">
<h2>Sacrifice and Spirit Growth</h2>
<p>
Spirits can be sacrificed to generate Soul Tokens and power high-cost abilities.
Strategic sacrifice is a core resource loop — spending small units to fuel larger threats.
</p>
</section>
<section id="glossary" class="howto-section">
<h2>Glossary</h2>
<dl class="glossary">
<dt>Channeler</dt>
<dd>The player. The will behind every card played.</dd>
<dt>Origin Stone</dt>
<dd>The cosmic vessel that stores memories of all that has been and may yet be.</dd>
<dt>Archspirit</dt>
<dd>A mighty being of ages past, temporarily revived through channeling.</dd>
<dt>Terramorpha</dt>
<dd>The art of shaping mindscape terrain through will and memory.</dd>
<dt>Mindscape</dt>
<dd>The constructed psychic battlefield where all matches take place.</dd>
<dt>Spirit</dt>
<dd>A lesser being summoned through channeling. Can be sacrificed for resources.</dd>
<dt>Ruin</dt>
<dd>A persistent card type that modifies game rules while in play.</dd>
<dt>Instinct</dt>
<dd>An instant-speed card playable at any time, including your opponent's turn.</dd>
<dt>Repentance</dt>
<dd>A slow, powerful card that takes time to resolve after being played.</dd>
<dt>Fifth Star</dt>
<dd>The impossible new star that appeared after the first encounter with the unknown entity. A symbol of hope.</dd>
</dl>
</section>
<div class="howto-cta">
<a href="/auth/register" class="btn btn-primary">Create Account and Play</a>
<a href="/cards" class="btn btn-ghost">Browse Cards</a>
</div>
</div>
</div>
@@ -0,0 +1,8 @@
namespace SOR.Website.Pages;
using Microsoft.AspNetCore.Mvc.RazorPages;
public sealed class HowToPlayModel : PageModel
{
public void OnGet() { }
}
+102
View File
@@ -0,0 +1,102 @@
@page
@model IndexModel
@{
ViewData["Title"] = null; // Home page title is just "Aeternalis"
ViewData["MetaDescription"] = "Channel the Archspirits. Shape the mindscape. Fill the void with stars. Aeternalis is a tactical strategy card game.";
ViewData["OgTitle"] = "Aeternalis";
ViewData["OgDescription"] = "Channel the Archspirits. Shape the mindscape. Fill the void with stars.";
}
<section class="hero">
<div class="hero-content">
<h1 class="hero-title">Aeternalis</h1>
<p class="hero-tagline">Channel the Archspirits. Shape the mindscape. Fill the void with stars.</p>
<div class="hero-actions">
<a href="/webclient" class="btn btn-primary btn-lg">Play Now</a>
<a href="/story" class="btn btn-ghost btn-lg">Learn the Origin</a>
</div>
</div>
<div class="hero-scroll-hint" aria-hidden="true"></div>
</section>
<section class="story-teaser section">
<div class="container">
<div class="story-beats">
<div class="story-beat">
<div class="beat-number">I</div>
<p>Four stars were all humanity knew. The Sun and three distant sisters, fixed in an endless dark.</p>
</div>
<div class="story-beat">
<div class="beat-number">II</div>
<p>The Origin Stone opened a path through living memory. Channelers learned to reach into what had been.</p>
</div>
<div class="story-beat">
<div class="beat-number">III</div>
<p>The fifth star proved the void could be changed. Every battle in the mindscape leaves a light in the sky.</p>
</div>
</div>
<a href="/story" class="btn btn-ghost">Read the Full Story</a>
</div>
</section>
<section class="how-teaser section section-dark">
<div class="container">
<h2>How a Match Unfolds</h2>
<ol class="match-steps">
<li class="match-step">
<span class="step-icon" aria-hidden="true">✦</span>
<div>
<strong>Channel an Archspirit</strong>
<p>Reach into the Origin Stone and revive a mighty being of ages past.</p>
</div>
</li>
<li class="match-step">
<span class="step-icon" aria-hidden="true">✦</span>
<div>
<strong>Shape terrain with Terramorpha</strong>
<p>Construct mindscape worlds through thought and will. The land obeys.</p>
</div>
</li>
<li class="match-step">
<span class="step-icon" aria-hidden="true">✦</span>
<div>
<strong>Sacrifice and empower Spirits</strong>
<p>Every sacrifice fuels something greater. Growth through loss.</p>
</div>
</li>
<li class="match-step">
<span class="step-icon" aria-hidden="true">✦</span>
<div>
<strong>Survive the psychic assault</strong>
<p>An unknown corrosive entity attacks through the mindscape. Hold the line.</p>
</div>
</li>
<li class="match-step">
<span class="step-icon" aria-hidden="true">✦</span>
<div>
<strong>Birth a new star</strong>
<p>Victory creates a world. The sky fills with proof of your will.</p>
</div>
</li>
</ol>
<a href="/how-to-play" class="btn btn-ghost">Learn the Rules</a>
</div>
</section>
<section class="cta-section section">
<div class="container cta-container">
<div class="cta-block">
<h2>Begin Channeling</h2>
<p>Create your account and enter the mindscape.</p>
<div class="cta-actions">
<a href="/auth/register" class="btn btn-primary">Create Account</a>
<a href="/webclient" class="btn btn-ghost">Play as Guest</a>
</div>
</div>
<div class="cta-block">
<h2>Browse the Cards</h2>
<p>Explore Archspirits, Spirits, Terramorpha, and more.</p>
<a href="/cards" class="btn btn-ghost">Open Card Catalog</a>
</div>
</div>
</section>
@@ -0,0 +1,8 @@
namespace SOR.Website.Pages;
using Microsoft.AspNetCore.Mvc.RazorPages;
public sealed class IndexModel : PageModel
{
public void OnGet() { }
}
@@ -0,0 +1,64 @@
@page
@model LeaderboardModel
@{
ViewData["Title"] = "Leaderboard";
ViewData["MetaDescription"] = "Top Channelers ranked by score. Who has filled the most stars?";
}
<div class="page-header">
<div class="container">
<h1>Leaderboard</h1>
<p class="page-subtitle">The Channelers who have shaped the most stars.</p>
</div>
</div>
<div class="container">
@if (!Model.Entries.Any())
{
<div class="empty-state">
<p>No ranked games have been played yet. Be the first Channeler.</p>
<a href="/webclient" class="btn btn-primary">Play Now</a>
</div>
}
else
{
<table class="leaderboard-table" aria-label="Player rankings">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Channeler</th>
<th scope="col">Rank Score</th>
</tr>
</thead>
<tbody>
@for (int i = 0; i < Model.Entries.Count; i++)
{
var entry = Model.Entries[i];
var rank = i + 1;
var isSelf = Model.CurrentUserDisplayName is not null
&& entry.DisplayName == Model.CurrentUserDisplayName;
<tr class="@(isSelf ? "leaderboard-self" : "") @(rank <= 3 ? $"rank-top rank-{rank}" : "")">
<td class="rank-cell">
@if (rank <= 3)
{
@* Rank icons use plain text fallbacks — no image dependency *@
<span class="rank-badge rank-badge-@rank" aria-label="Rank @rank">@rank</span>
}
else
{
@rank
}
</td>
@* DisplayName auto-encoded by Razor *@
<td class="name-cell">
@entry.DisplayName
@if (isSelf) { <span class="self-tag" aria-label="You">(you)</span> }
</td>
<td class="score-cell">@entry.RankScore</td>
</tr>
}
</tbody>
</table>
}
</div>
@@ -0,0 +1,52 @@
namespace SOR.Website.Pages;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using SOR.Database.Contexts;
using SOR.Database.Entities.Identity;
/// <summary>
/// Public leaderboard showing top ranked players.
///
/// Security controls:
/// - Only exposes: DisplayName, RankScore. Never: Email, AccountId, or internal fields.
/// - AI accounts and accounts hidden from leaderboard are excluded at query level.
/// - Pagination limits response size.
/// </summary>
public sealed class LeaderboardModel(SorIdentityDbContext identity) : PageModel
{
public const int PageSize = 50;
public IReadOnlyList<LeaderboardEntry> Entries { get; private set; } = [];
public string? CurrentUserDisplayName { get; private set; }
public async Task OnGetAsync()
{
// Only safe-to-display fields are projected — email and internal IDs are excluded.
Entries = await identity.Users
.Where(a => !a.IsAi && !a.IsHiddenFromLeaderboard)
.OrderByDescending(a => a.RankScore)
.Take(PageSize)
.Select(a => new LeaderboardEntry
{
DisplayName = a.DisplayName ?? "Channeler",
RankScore = a.RankScore,
})
.AsNoTracking()
.ToListAsync();
// Current user's display name (to highlight their entry)
if (User.Identity?.IsAuthenticated == true)
CurrentUserDisplayName = User.FindFirst("display_name")?.Value;
}
/// <summary>
/// Public-safe projection: only display name and rank score.
/// Email, AccountId, and moderation state are intentionally excluded.
/// </summary>
public sealed class LeaderboardEntry
{
public string DisplayName { get; init; } = string.Empty;
public int RankScore { get; init; }
}
}
@@ -0,0 +1,19 @@
@page
@model IndexModel
@{
ViewData["Title"] = "News";
}
<div class="page-header">
<div class="container">
<h1>News</h1>
<p class="page-subtitle">Patch notes, set releases, and announcements.</p>
</div>
</div>
<div class="container">
<div class="coming-soon-block">
<p>News and patch notes are coming soon. Check back after launch.</p>
<a href="/" class="btn btn-ghost">Back to Home</a>
</div>
</div>
@@ -0,0 +1,8 @@
namespace SOR.Website.Pages.News;
using Microsoft.AspNetCore.Mvc.RazorPages;
public sealed class IndexModel : PageModel
{
public void OnGet() { }
}
@@ -0,0 +1,74 @@
@page
@model PrivacyModel
@{
ViewData["Title"] = "Privacy Policy";
}
<div class="page-header">
<div class="container">
<h1>Privacy Policy</h1>
<p class="page-subtitle">Last updated: @DateTime.UtcNow.ToString("MMMM yyyy")</p>
</div>
</div>
<div class="container prose-page">
<section class="prose-section">
<h2>What We Collect</h2>
<ul>
<li><strong>Account data:</strong> email address, display name, and password hash.</li>
<li><strong>Game data:</strong> match results, rank score, and card collection.</li>
<li><strong>Technical data:</strong> IP address (for security and rate limiting), user agent string, and session metadata.</li>
</ul>
</section>
<section class="prose-section">
<h2>What We Do Not Collect</h2>
<ul>
<li>We do not sell your data to third parties.</li>
<li>We do not collect payment information directly (payments processed by third-party providers).</li>
<li>We do not use tracking pixels or third-party advertising cookies.</li>
</ul>
</section>
<section class="prose-section">
<h2>How We Use Your Data</h2>
<ul>
<li>To operate your account and game access.</li>
<li>To provide customer support.</li>
<li>To detect and prevent abuse, cheating, and unauthorized access.</li>
<li>To display your display name on the public leaderboard (opt-out available in account settings).</li>
</ul>
</section>
<section class="prose-section">
<h2>Data Retention</h2>
<p>
Account data is retained while your account is active. You may request account deletion
by contacting support. Game match records may be retained for statistical purposes in
anonymized form after deletion.
</p>
</section>
<section class="prose-section">
<h2>Security</h2>
<p>
Passwords are hashed using industry-standard algorithms (bcrypt via ASP.NET Core Identity).
Session cookies are encrypted, HTTP-only, and marked Secure. Communication with this site
is encrypted via HTTPS.
</p>
</section>
<section class="prose-section">
<h2>Contact</h2>
<p>
For privacy questions or data deletion requests, contact us via the
<a href="/support">support page</a>.
</p>
</section>
<p class="prose-disclaimer">
This is a placeholder privacy policy. A complete policy will be provided before public launch.
</p>
</div>
@@ -0,0 +1,8 @@
namespace SOR.Website.Pages;
using Microsoft.AspNetCore.Mvc.RazorPages;
public sealed class PrivacyModel : PageModel
{
public void OnGet() { }
}
@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@(ViewData["Title"] != null ? ViewData["Title"] + " — " : "")Aeternalis</title>
@if (ViewData["MetaDescription"] != null)
{
<meta name="description" content="@ViewData["MetaDescription"]">
}
@if (ViewData["OgTitle"] != null)
{
<meta property="og:title" content="@ViewData["OgTitle"]">
<meta property="og:type" content="website">
@if (ViewData["OgImage"] != null)
{
<meta property="og:image" content="@ViewData["OgImage"]">
}
@if (ViewData["OgDescription"] != null)
{
<meta property="og:description" content="@ViewData["OgDescription"]">
}
}
@* No inline styles — required for strict style-src 'self' CSP. All styles in site.css. *@
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true">
</head>
<body>
<header class="site-header">
<nav class="site-nav" aria-label="Main navigation">
<a href="/" class="nav-brand" aria-label="Aeternalis home">
<span class="brand-name">Aeternalis</span>
</a>
<button class="nav-toggle" aria-expanded="false" aria-controls="nav-links" aria-label="Open navigation">
<span></span><span></span><span></span>
</button>
<ul class="nav-links" id="nav-links" role="list">
<li><a href="/webclient" class="nav-play-btn">Play</a></li>
<li><a href="/story" class="nav-link">Story</a></li>
<li><a href="/cards" class="nav-link">Cards</a></li>
<li><a href="/how-to-play" class="nav-link">How To Play</a></li>
<li><a href="/leaderboard" class="nav-link">Leaderboard</a></li>
<li><a href="/news" class="nav-link">News</a></li>
<li><a href="/ai-assets" class="nav-link">AI Assets</a></li>
</ul>
<div class="nav-account">
@if (User.Identity?.IsAuthenticated == true)
{
// Display name comes from the "display_name" claim set at sign-in.
// Razor auto-encodes this — no XSS risk.
var displayName = User.FindFirstValue("display_name") ?? User.Identity.Name ?? "Account";
<a href="/account" class="nav-account-name" aria-label="Your account">@displayName</a>
@* Logout is a POST to prevent CSRF logout via GET request. *@
<form method="post" asp-page="/Auth/Logout" class="nav-logout-form">
<button type="submit" class="nav-btn-ghost">Sign Out</button>
</form>
}
else
{
<a href="/auth/login" class="nav-btn-ghost">Log In</a>
<a href="/auth/register" class="nav-btn-primary">Create Account</a>
}
</div>
</nav>
</header>
<main id="main-content">
@RenderBody()
</main>
<footer class="site-footer">
<div class="footer-inner">
<p class="footer-copy">&copy; @DateTime.UtcNow.Year Aeternalis Games</p>
<nav class="footer-links" aria-label="Footer navigation">
<a href="/privacy">Privacy</a>
<a href="/terms">Terms</a>
<a href="/support">Support</a>
<a href="/ai-assets">AI Assets</a>
</nav>
</div>
</footer>
@* No inline scripts — required for strict script-src 'self' CSP. *@
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
+121
View File
@@ -0,0 +1,121 @@
@page
@model StoryModel
@{
ViewData["Title"] = "Story";
ViewData["MetaDescription"] = "The story of Origin: Stone of Revival. Channel Archspirits. Shape the mindscape. Fill the void with stars.";
}
<div class="page-header story-header">
<div class="container">
<h1>Origin: Stone of Revival</h1>
<p class="page-subtitle">The story of the Channelers and the impossible fifth star.</p>
</div>
</div>
<article class="story-page">
<div class="container">
<section class="story-section">
<h2>That We Know</h2>
<div class="story-panel">
<h3>The Four Stars</h3>
<p>
From time immemorial, the sky held only four stars: the life-giving Sun and three
distant sister planets, fixed in an endless dark. Humanity believed it was alone.
The void beyond was assumed to be desolate, empty, and permanent.
</p>
</div>
<div class="story-panel">
<h3>The Origin Stone</h3>
<p>
The Origin Stone is a cosmic vessel whose surface protects the memories of what
has been, what is, and what may yet be. It remembers what reality has forgotten.
To touch it is to reach into living memory itself.
</p>
</div>
<div class="story-panel">
<h3>Channelers</h3>
<p>
Channelers are those who have learned to reach into the Origin Stone — to recover
knowledge from the past and strengthen the present. Great Channelers can commune
directly with the Stone, accessing the memories of entire worlds.
</p>
</div>
<div class="story-panel">
<h3>Archspirits</h3>
<p>
Through the Origin Stone, Channelers connect with Archspirits: mighty beings of
ages past whose memories, worlds, experiences, and powers can be temporarily
revived. To channel an Archspirit is to revive a world for one decisive moment.
</p>
</div>
<div class="story-panel">
<h3>Terramorpha</h3>
<p>
Channelers use Terramorpha to shape constructed mindscape worlds — bringing lands,
paths, and battlefields into being through thought and will. The terrain obeys.
Every tile of the mindscape is an act of intention.
</p>
</div>
</section>
<section class="story-section">
<h2>That We Do Not</h2>
<div class="story-panel story-panel-threat">
<h3>The Unknown Entity</h3>
<p>
During one communion, the player encounters an unknown corrosive entity deep within
the Origin Stone. It attacks through psychic space with strange spirits, impossible
powers, and violence from lands never seen. It should not exist.
</p>
</div>
<div class="story-panel story-panel-threat">
<h3>Survival</h3>
<p>
The Channeler forms defensive worlds, summons Archspirits, sacrifices spirits to fuel
growth, and reshapes terrain mid-conflict. Victory forces the entity back. But the
mindscape is changed.
</p>
</div>
<div class="story-panel story-panel-threat">
<h3>The Fifth Star</h3>
<p>
The trance breaks. The night sky now holds a fifth star — a new planet that should
not exist, yet does. Other Channelers begin encountering the same menace. Every fight
in the mindscape, even a loss, creates another star in the night sky.
</p>
</div>
</section>
<section class="story-section">
<h2>Your Role</h2>
<div class="story-panel story-panel-call">
<p>
What began as survival becomes hope. The endless void can be undone. The sky can be
filled with worlds. The lost experiences beyond the Origin Stone can be restored.
</p>
<blockquote class="story-quote">
Every battle in the mindscape leaves a light in the sky.
</blockquote>
<p>
You are a Channeler. Channel the Archspirits. Shape the mindscape. Fight the menace.
Restore worlds to the sky. Turn every battle into a testament of will.
</p>
<div class="story-cta">
<a href="/auth/register" class="btn btn-primary">Begin Channeling</a>
<a href="/how-to-play" class="btn btn-ghost">Learn the Rules</a>
</div>
</div>
</section>
</div>
</article>
@@ -0,0 +1,8 @@
namespace SOR.Website.Pages;
using Microsoft.AspNetCore.Mvc.RazorPages;
public sealed class StoryModel : PageModel
{
public void OnGet() { }
}
@@ -0,0 +1,49 @@
@page
@model SupportModel
@{
ViewData["Title"] = "Support";
}
<div class="page-header">
<div class="container">
<h1>Support</h1>
<p class="page-subtitle">Bug reports, account help, and contact.</p>
</div>
</div>
<div class="container prose-page">
<section class="prose-section">
<h2>Account Help</h2>
<ul>
<li>Forgot your password? <a href="/auth/forgot-password">Reset it here</a>.</li>
<li>Need to verify your email? Log in and check your account page.</li>
<li>Want to delete your account? Contact us at the address below.</li>
</ul>
</section>
<section class="prose-section">
<h2>Bug Reports</h2>
<p>
Found a bug? Please describe what happened, what you expected, and the steps to reproduce it.
Include your platform and any relevant error messages.
</p>
</section>
<section class="prose-section">
<h2>Contact</h2>
<p>
Full support contact details will be listed here before public launch.
For now, reach out via community channels.
</p>
</section>
<section class="prose-section">
<h2>AI Asset Reports</h2>
<p>
Noticed an asset that appears AI-generated but is not in our disclosure?
<a href="/ai-assets">Review our AI asset policy</a> and contact support.
</p>
</section>
</div>
@@ -0,0 +1,8 @@
namespace SOR.Website.Pages;
using Microsoft.AspNetCore.Mvc.RazorPages;
public sealed class SupportModel : PageModel
{
public void OnGet() { }
}
+75
View File
@@ -0,0 +1,75 @@
@page
@model TermsModel
@{
ViewData["Title"] = "Terms of Service";
}
<div class="page-header">
<div class="container">
<h1>Terms of Service</h1>
<p class="page-subtitle">Last updated: @DateTime.UtcNow.ToString("MMMM yyyy")</p>
</div>
</div>
<div class="container prose-page">
<section class="prose-section">
<h2>Acceptance</h2>
<p>
By creating an account or using Aeternalis, you agree to these Terms of Service.
If you do not agree, do not use the service.
</p>
</section>
<section class="prose-section">
<h2>Accounts</h2>
<ul>
<li>One account per person. Sharing accounts is not permitted.</li>
<li>You are responsible for maintaining the security of your credentials.</li>
<li>You must be at least 13 years old to create an account.</li>
<li>Accurate registration information is required.</li>
</ul>
</section>
<section class="prose-section">
<h2>Conduct</h2>
<ul>
<li>No cheating, exploiting, or using unauthorized third-party software.</li>
<li>No harassment, hate speech, or abusive behaviour toward other players.</li>
<li>No activity that disrupts the service or other players' experience.</li>
</ul>
</section>
<section class="prose-section">
<h2>Intellectual Property</h2>
<p>
All game content, art, and systems are the property of Aeternalis Games.
Your account data is yours; game content remains ours.
</p>
</section>
<section class="prose-section">
<h2>Termination</h2>
<p>
We reserve the right to suspend or terminate accounts that violate these terms,
with or without prior notice.
</p>
</section>
<section class="prose-section">
<h2>Changes</h2>
<p>
We may update these terms. Continued use after changes constitutes acceptance.
</p>
</section>
<section class="prose-section">
<h2>Contact</h2>
<p>Questions about these terms? Visit the <a href="/support">support page</a>.</p>
</section>
<p class="prose-disclaimer">
This is a placeholder terms document. Complete legal terms will be provided before public launch.
</p>
</div>
@@ -0,0 +1,8 @@
namespace SOR.Website.Pages;
using Microsoft.AspNetCore.Mvc.RazorPages;
public sealed class TermsModel : PageModel
{
public void OnGet() { }
}
@@ -0,0 +1,21 @@
@page
@model WebclientModel
@{
ViewData["Title"] = "Play";
}
<div class="auth-page">
<div class="auth-card">
<h1 class="auth-title">Enter the Mindscape</h1>
<p>Sign in to your Channeler account to begin.</p>
<div class="webclient-actions">
<a href="/auth/login?returnUrl=/webclient" class="btn btn-primary btn-lg btn-block">Log In</a>
<a href="/auth/register" class="btn btn-ghost btn-lg btn-block">Create Account</a>
</div>
<div class="auth-links">
<a href="/how-to-play">New? Learn the rules first</a>
</div>
</div>
</div>
@@ -0,0 +1,30 @@
namespace SOR.Website.Pages;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
/// <summary>
/// Canonical route for launching the game client.
///
/// Security controls:
/// - Authenticated users are redirected directly (return URL preserved via cookie auth).
/// - Unauthenticated users see a login gate — not an automatic redirect to the webclient
/// URL, which prevents the webclient from being embedded without a session.
/// - No dynamic content injected from query string into the page (no XSS surface).
/// </summary>
public sealed class WebclientModel : PageModel
{
// The actual webclient URL is configured separately and may live on a subdomain.
// For Phase 1 this is a placeholder. Replace with the real client URL when deployed.
public const string ClientUrl = "/webclient/app";
public bool IsAuthenticated => User.Identity?.IsAuthenticated == true;
public IActionResult OnGet()
{
if (IsAuthenticated)
return Redirect(ClientUrl);
return Page();
}
}
@@ -0,0 +1,5 @@
@namespace SOR.Website.Pages
@using System.Security.Claims
@using SOR.Database.Entities.Identity
@using SOR.Database.Enums
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}
+267
View File
@@ -0,0 +1,267 @@
// SOR.Website — Public game website and player account portal
//
// This is the entry point for aeternalisgames.com. It runs independently of
// SOR.Host and connects to the same databases (Identity, Catalog) so player
// accounts created here work immediately in the game client.
//
// Security design:
// - All HTML rendered by Razor Pages is HTML-encoded by default (XSS impossible).
// - Content-Security-Policy blocks all inline scripts/styles (SecurityHeadersMiddleware).
// - Anti-forgery tokens are validated on every POST handler (Razor Pages default).
// - Auth cookie uses __Host- prefix: forces Secure, Path=/, and no Domain attribute.
// - Data Protection keys stored in Redis: all pods decrypt each other's cookies.
// - Rate limiting applied per-IP to all auth endpoints.
// - Forwarded-header trust enables accurate IP tracking behind the ingress.
using System.Threading.RateLimiting;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.DataProtection;
using Serilog;
using StackExchange.Redis;
using SOR.Database;
using SOR.Database.Contexts;
using SOR.Database.Entities.Identity;
using SOR.Website;
var builder = WebApplication.CreateBuilder(args);
// ── Logging ───────────────────────────────────────────────────────────────────
builder.Host.UseSerilog((ctx, cfg) =>
cfg.ReadFrom.Configuration(ctx.Configuration));
// ── Redis ─────────────────────────────────────────────────────────────────────
// Create the Redis connection eagerly so DataProtection can share it.
var redisConnectionString = builder.Configuration.GetConnectionString("Redis") ?? "localhost:6379";
var redisConfig = ConfigurationOptions.Parse(redisConnectionString);
redisConfig.AbortOnConnectFail = false;
var redis = ConnectionMultiplexer.Connect(redisConfig);
builder.Services.AddSingleton<IConnectionMultiplexer>(redis);
// ── DataProtection ────────────────────────────────────────────────────────────
// Persist keys in Redis so all pod replicas can decrypt each other's session cookies.
// SetApplicationName ensures cookie protection is scoped to this app — different apps
// sharing the same Redis instance cannot accidentally decrypt each other's cookies.
builder.Services.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "SOR.Website:DataProtection-Keys")
.SetApplicationName("SOR.Website");
// ── Identity databases ────────────────────────────────────────────────────────
builder.Services.AddIdentityDatabase(builder.Configuration);
builder.Services.AddCatalogDatabase(builder.Configuration);
// ── ASP.NET Core Identity ─────────────────────────────────────────────────────
// Registers UserManager<Account>, SignInManager<Account>, and all token providers.
// Password rules and lockout here MUST match SOR.Auth/ServiceRegistration.cs so that
// passwords set via the website are accepted by the game client and vice versa.
builder.Services.AddIdentity<Account, IdentityRole<Guid>>(options =>
{
// Password policy (must match SOR.Auth)
options.Password.RequireDigit = true;
options.Password.RequireUppercase = true;
options.Password.RequireNonAlphanumeric = true;
options.Password.RequiredLength = 8;
// Account lockout after 5 failed attempts
options.Lockout.MaxFailedAccessAttempts = 5;
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(30);
options.Lockout.AllowedForNewUsers = true;
// Email is the unique login identifier
options.User.RequireUniqueEmail = true;
// Email verification is advisory for now (players can play before verifying).
// Set RequireConfirmedEmail = true when an email provider is configured.
options.SignIn.RequireConfirmedEmail = false;
})
.AddEntityFrameworkStores<SorIdentityDbContext>()
.AddDefaultTokenProviders();
// ── Cookie configuration ──────────────────────────────────────────────────────
// AddIdentity registers the application cookie automatically.
// ConfigureApplicationCookie overrides the defaults to apply maximum security.
//
// __Host- prefix requirements (enforced by the browser, not us):
// - The Secure attribute must be set.
// - The Path attribute must be "/".
// - The Domain attribute must NOT be set.
// Together these prevent the cookie from being set by a subdomain compromise
// and ensure it is never sent over plain HTTP even if a redirect occurs.
builder.Services.ConfigureApplicationCookie(opts =>
{
opts.Cookie.Name = "__Host-sor-web-session";
opts.Cookie.HttpOnly = true; // inaccessible to JavaScript — blocks XSS token theft
opts.Cookie.SecurePolicy = CookieSecurePolicy.Always; // never sent over HTTP
opts.Cookie.SameSite = SameSiteMode.Strict; // never sent on cross-site requests
opts.Cookie.Path = "/"; // required for __Host- prefix
opts.LoginPath = "/auth/login";
opts.LogoutPath = "/auth/logout";
opts.AccessDeniedPath = "/auth/login"; // unauthorized → login, not 403 page
opts.ReturnUrlParameter = "returnUrl"; // param name in /auth/login?returnUrl=...
opts.SlidingExpiration = true;
opts.ExpireTimeSpan = TimeSpan.FromDays(14);
// SecurityStampValidator re-checks the stamp every 30 minutes by default.
// This means password changes and bans take effect within that window
// without a full DB hit on every single request.
});
// ── Anti-forgery ──────────────────────────────────────────────────────────────
// Razor Pages validates anti-forgery tokens on every POST handler by default.
// We apply the same strict cookie security as the session cookie.
// The HeaderName allows JavaScript fetch requests to send the token via header
// rather than form body (needed for AJAX calls with JSON bodies).
builder.Services.AddAntiforgery(opts =>
{
opts.Cookie.Name = "__Host-sor-csrf";
opts.Cookie.HttpOnly = true;
opts.Cookie.SecurePolicy = CookieSecurePolicy.Always;
opts.Cookie.SameSite = SameSiteMode.Strict;
opts.Cookie.Path = "/";
opts.HeaderName = "X-CSRF-TOKEN";
});
// ── Razor Pages ───────────────────────────────────────────────────────────────
// AuthorizeFolder("/Account") applies [Authorize] to every page under /Account.
// No individual page needs the attribute — it is enforced at the routing layer.
// This is the privilege-escalation control: unauthenticated requests to any
// /Account/* page are automatically redirected to /auth/login?returnUrl=...
builder.Services.AddRazorPages(opts =>
{
opts.Conventions.AuthorizeFolder("/Account");
});
// ── Rate limiting ─────────────────────────────────────────────────────────────
// Applied per-IP address to auth endpoints to slow brute-force attacks.
// IP is obtained from the RemoteIpAddress, which reflects the real client IP
// because UseForwardedHeaders() is applied early in the pipeline below.
//
// Policies are applied via [EnableRateLimiting("policy-name")] on page models.
builder.Services.AddRateLimiter(opts =>
{
opts.RejectionStatusCode = StatusCodes.Status429TooManyRequests;
// Login: 10 attempts per IP per 5 minutes
opts.AddPolicy("auth-login", httpCtx =>
RateLimitPartition.GetFixedWindowLimiter(
partitionKey: httpCtx.Connection.RemoteIpAddress?.ToString() ?? "unknown",
factory: _ => new FixedWindowRateLimiterOptions
{
PermitLimit = 10,
Window = TimeSpan.FromMinutes(5),
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
QueueLimit = 0,
}));
// Registration: 5 per IP per hour
opts.AddPolicy("auth-register", httpCtx =>
RateLimitPartition.GetFixedWindowLimiter(
partitionKey: httpCtx.Connection.RemoteIpAddress?.ToString() ?? "unknown",
factory: _ => new FixedWindowRateLimiterOptions
{
PermitLimit = 5,
Window = TimeSpan.FromHours(1),
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
QueueLimit = 0,
}));
// Password reset: 3 per IP per 15 minutes
opts.AddPolicy("auth-reset", httpCtx =>
RateLimitPartition.GetFixedWindowLimiter(
partitionKey: httpCtx.Connection.RemoteIpAddress?.ToString() ?? "unknown",
factory: _ => new FixedWindowRateLimiterOptions
{
PermitLimit = 3,
Window = TimeSpan.FromMinutes(15),
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
QueueLimit = 0,
}));
});
// ── Forwarded headers ─────────────────────────────────────────────────────────
// The pod runs plain HTTP behind a TLS-terminating ingress (nginx/Traefik/etc.).
// Without this, ASP.NET Core sees the ingress IP as the client, breaking rate
// limiting (all clients appear to share one IP) and HSTS redirect logic.
// Clearing KnownNetworks/KnownProxies trusts any upstream proxy — safe because
// the pod is only reachable from within the cluster network.
builder.Services.Configure<ForwardedHeadersOptions>(opts =>
{
opts.ForwardedHeaders =
ForwardedHeaders.XForwardedFor |
ForwardedHeaders.XForwardedProto |
ForwardedHeaders.XForwardedHost;
opts.KnownNetworks.Clear();
opts.KnownProxies.Clear();
});
// ── Health checks ─────────────────────────────────────────────────────────────
builder.Services.AddHealthChecks();
// ── BUILD ─────────────────────────────────────────────────────────────────────
var app = builder.Build();
// ── Middleware pipeline ───────────────────────────────────────────────────────
// Order is critical. Each line's comment explains why it must be at this position.
// 1. Forwarded headers: must be first so all subsequent middleware sees the
// real client IP, scheme, and host from proxy headers.
app.UseForwardedHeaders();
if (!app.Environment.IsDevelopment())
{
// 2a. Exception handler in production: inline so it never redirects to a
// protected route that would trigger an auth challenge loop.
app.UseExceptionHandler(err => err.Run(async ctx =>
{
ctx.Response.StatusCode = 500;
ctx.Response.ContentType = "text/html; charset=utf-8";
await ctx.Response.WriteAsync(
"<!DOCTYPE html><html><body><h1>An error occurred.</h1></body></html>");
}));
// 2b. HSTS: instructs browsers to always use HTTPS for this domain.
// The ingress terminates TLS; the pod itself is plain HTTP.
// UseHttpsRedirection is intentionally omitted — the pod never receives
// HTTPS directly, so redirecting would cause an infinite loop.
app.UseHsts();
}
// 3. Security headers: must come before static files so every response (including
// CSS, JS, images) carries the full security header set.
app.UseMiddleware<SecurityHeadersMiddleware>();
// 4. Static files: serves wwwroot/ content.
// Comes before routing so requests for .css/.js/.png etc. short-circuit here
// without hitting the Razor Pages routing layer.
app.UseStaticFiles();
// 5. Routing: maps URL paths to page handlers.
app.UseRouting();
// 6. Rate limiting: must come after UseRouting (needs endpoint metadata) and
// before UseAuthentication (so we can reject before doing any DB work).
app.UseRateLimiter();
// 7. Authentication: reads the __Host-sor-web-session cookie and populates
// HttpContext.User with the signed-in Account's claims.
app.UseAuthentication();
// 8. Authorization: enforces [Authorize] and AuthorizeFolder conventions.
// Must come after UseAuthentication.
app.UseAuthorization();
// ── Endpoints ─────────────────────────────────────────────────────────────────
app.MapRazorPages();
// Health check: AllowAnonymous so Kubernetes probes work before any session exists.
app.MapHealthChecks("/health").AllowAnonymous();
// ── RUN ───────────────────────────────────────────────────────────────────────
Log.Information("SOR.Website starting");
await app.RunAsync();
+36
View File
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<AssemblyName>SOR.Website</AssemblyName>
<OutputType>Exe</OutputType>
<!-- User secrets for local development (connection strings, etc.) -->
<UserSecretsId>SOR.Website</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<!-- ASP.NET Core Identity: UserManager, SignInManager, password hashing -->
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<!-- Data Protection keys stored in Redis so all pods share the same key ring.
Without this, cookies set by pod A cannot be decrypted by pod B. -->
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" />
<!-- Redis client (for DataProtection key ring) -->
<PackageReference Include="StackExchange.Redis" />
<!-- Structured logging -->
<PackageReference Include="Serilog.AspNetCore" />
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Serilog.Sinks.Seq" />
<!-- EF Core design-time tools: enables 'dotnet ef migrations add' when
targeting this project as the startup project. Dev-only. -->
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<!-- Identity DB context, catalog, shared types -->
<ProjectReference Include="..\SOR.Database\SOR.Database.csproj" />
<ProjectReference Include="..\SOR.Shared\SOR.Shared.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,104 @@
namespace SOR.Website;
/// <summary>
/// Adds a strict suite of HTTP security response headers to every response.
///
/// XSS prevention:
/// Content-Security-Policy: restricts which resources (scripts, styles, images,
/// frames) the browser may load. 'script-src self' means zero inline scripts are
/// executed — any injected &lt;script&gt; tag or javascript: URL is dead on arrival.
/// 'style-src self' blocks injected inline styles. 'object-src none' kills plug-in
/// vectors (Flash etc.). 'base-uri self' prevents &lt;base&gt; tag hijacking.
/// 'form-action self' prevents forms from being redirected to attacker-controlled
/// URLs even if an attacker injects a form into the page.
///
/// Clickjacking prevention:
/// X-Frame-Options and frame-ancestors 'none' together ensure no page on this
/// site can be embedded in an iframe on another origin, defeating UI redress attacks.
///
/// MIME confusion prevention:
/// X-Content-Type-Options: nosniff stops browsers from executing a response as a
/// different MIME type than declared (e.g., serving a .png that is actually JS).
///
/// Information leakage prevention:
/// Referrer-Policy limits what URL is sent to third parties in the Referer header.
/// The header is added on every response so the browser always uses the strictest rule.
/// </summary>
public sealed class SecurityHeadersMiddleware(RequestDelegate next)
{
public Task InvokeAsync(HttpContext context)
{
var h = context.Response.Headers;
// ── Clickjacking ─────────────────────────────────────────────────────────
// Legacy header: understood by all browsers including old IE.
h["X-Frame-Options"] = "DENY";
// ── MIME confusion ───────────────────────────────────────────────────────
h["X-Content-Type-Options"] = "nosniff";
// ── Referrer leakage ─────────────────────────────────────────────────────
// Sends origin only when navigating same-origin, full URL on same-site,
// and origin-only (no path) when crossing to a different origin over HTTPS.
h["Referrer-Policy"] = "strict-origin-when-cross-origin";
// ── Browser feature permissions ──────────────────────────────────────────
// Explicitly deny any feature the site does not need.
// Payment API denial is particularly important to prevent skimming attacks.
h["Permissions-Policy"] = "camera=(), microphone=(), geolocation=(), payment=()";
// ── Content Security Policy ──────────────────────────────────────────────
//
// default-src 'self'
// All resource types not listed below inherit this: same-origin only.
//
// script-src 'self'
// Scripts may only be loaded from this origin. No 'unsafe-inline' means
// zero inline <script> tags or event handlers execute. No 'unsafe-eval'
// means eval/Function constructors are blocked.
//
// style-src 'self'
// Stylesheets from this origin only. No inline <style> or style= attributes.
//
// img-src 'self' data: https://cdn.aeternalisgames.com
// Images from self, data: URIs (used for small inline SVGs/placeholders),
// and the CDN where card art and game assets live.
//
// font-src 'self'
// Web fonts from this origin only.
//
// object-src 'none'
// Disables all browser plug-ins: Flash, Java, Silverlight, etc.
//
// base-uri 'self'
// Prevents an injected <base href="https://attacker.com"> from redirecting
// all relative URLs in the document to an attacker-controlled host.
//
// form-action 'self'
// All <form> submissions must target the same origin. This stops a
// data-exfiltration attack via an injected form even if the attacker
// bypasses CSRF tokens some other way.
//
// frame-ancestors 'none'
// Modern replacement for X-Frame-Options: no page may embed this site
// in an iframe, frame, embed, or object element.
//
// upgrade-insecure-requests
// Tells supporting browsers to automatically upgrade any http:// sub-
// resource URL to https://, closing mixed-content gaps.
//
h["Content-Security-Policy"] =
"default-src 'self'; " +
"script-src 'self'; " +
"style-src 'self'; " +
"img-src 'self' data: https://cdn.aeternalisgames.com; " +
"font-src 'self'; " +
"object-src 'none'; " +
"base-uri 'self'; " +
"form-action 'self'; " +
"frame-ancestors 'none'; " +
"upgrade-insecure-requests";
return next(context);
}
}
+25
View File
@@ -0,0 +1,25 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.Console" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning"
}
},
"WriteTo": [
{ "Name": "Console" }
],
"Enrich": [ "FromLogContext" ]
},
"ConnectionStrings": {
"Default": "Host=localhost;Port=5432;Database=sor;Username=sor;Password=sor",
"Redis": "localhost:6379"
},
"Cdn": {
"PublicBaseUrl": "https://cdn.aeternalisgames.com"
},
"AllowedHosts": "*"
}
+886
View File
@@ -0,0 +1,886 @@
/* ==========================================================================
Aeternalis — site.css
Dark game UI. All styles are here; no inline styles, no inline scripts.
========================================================================== */
/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
:root {
--clr-bg: #08080f;
--clr-bg-2: #0f0f1a;
--clr-bg-3: #14141f;
--clr-bg-card: #1a1a2a;
--clr-surface: #1e1e30;
--clr-border: #2a2a44;
--clr-border-2: #3a3a5a;
--clr-text: #dde0f0;
--clr-text-2: #9090b0;
--clr-text-3: #606080;
--clr-gold: #c4a04a;
--clr-gold-2: #e8c870;
--clr-gold-dim: #7a6030;
--clr-red: #c44040;
--clr-green: #40a060;
--clr-blue: #4070c4;
--clr-primary: var(--clr-gold);
--clr-primary-2: var(--clr-gold-2);
--radius-sm: 4px;
--radius: 8px;
--radius-lg: 12px;
--font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--font-mono: "Courier New", Courier, monospace;
--nav-height: 64px;
--max-width: 1200px;
--col-gap: 24px;
}
html {
font-size: 16px;
scroll-behavior: smooth;
}
body {
background-color: var(--clr-bg);
color: var(--clr-text);
font-family: var(--font-body);
line-height: 1.6;
min-height: 100vh;
display: flex;
flex-direction: column;
}
main { flex: 1; }
a {
color: var(--clr-gold);
text-decoration: none;
}
a:hover { color: var(--clr-gold-2); text-decoration: underline; }
h1, h2, h3, h4, h5, h6 {
line-height: 1.2;
color: var(--clr-text);
}
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); margin-bottom: .5rem; }
h2 { font-size: clamp(1.3rem, 3vw, 1.9rem); margin-bottom: .5rem; }
h3 { font-size: 1.2rem; margin-bottom: .4rem; }
p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }
ul, ol { padding-left: 1.4rem; margin-bottom: 1rem; }
li { margin-bottom: .3rem; }
/* ── Container ──────────────────────────────────────────────────────────── */
.container {
max-width: var(--max-width);
margin: 0 auto;
padding: 0 var(--col-gap);
}
/* ── Navigation ─────────────────────────────────────────────────────────── */
.site-header {
position: sticky;
top: 0;
z-index: 100;
background: rgba(8, 8, 15, 0.95);
backdrop-filter: blur(8px);
border-bottom: 1px solid var(--clr-border);
height: var(--nav-height);
}
.site-nav {
max-width: var(--max-width);
margin: 0 auto;
padding: 0 var(--col-gap);
height: 100%;
display: flex;
align-items: center;
gap: 1.5rem;
}
.nav-brand {
flex-shrink: 0;
text-decoration: none;
}
.brand-name {
font-size: 1.2rem;
font-weight: 700;
letter-spacing: .04em;
color: var(--clr-gold);
text-shadow: 0 0 20px rgba(196, 160, 74, 0.4);
}
.nav-links {
display: flex;
align-items: center;
gap: .25rem;
list-style: none;
flex: 1;
padding: 0;
margin: 0;
}
.nav-link {
color: var(--clr-text-2);
padding: .4rem .75rem;
border-radius: var(--radius-sm);
font-size: .9rem;
transition: color .15s, background .15s;
text-decoration: none;
}
.nav-link:hover { color: var(--clr-text); background: var(--clr-surface); text-decoration: none; }
.nav-play-btn {
display: inline-flex;
align-items: center;
padding: .4rem .9rem;
background: var(--clr-gold);
color: #08080f;
border-radius: var(--radius-sm);
font-weight: 700;
font-size: .9rem;
text-decoration: none;
transition: background .15s;
margin-right: .5rem;
}
.nav-play-btn:hover { background: var(--clr-gold-2); color: #08080f; text-decoration: none; }
.nav-account {
display: flex;
align-items: center;
gap: .5rem;
margin-left: auto;
}
.nav-account-name {
color: var(--clr-text);
font-size: .9rem;
text-decoration: none;
padding: .3rem .6rem;
border-radius: var(--radius-sm);
transition: background .15s;
}
.nav-account-name:hover { background: var(--clr-surface); text-decoration: none; }
.nav-logout-form { display: inline; }
.nav-toggle {
display: none;
flex-direction: column;
gap: 5px;
background: none;
border: none;
cursor: pointer;
padding: .4rem;
}
.nav-toggle span {
display: block;
width: 22px;
height: 2px;
background: var(--clr-text);
border-radius: 2px;
}
/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: .55rem 1.25rem;
border-radius: var(--radius);
font-weight: 600;
font-size: .95rem;
cursor: pointer;
border: none;
text-decoration: none;
transition: background .15s, color .15s, border-color .15s;
line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary {
background: var(--clr-gold);
color: #08080f;
}
.btn-primary:hover { background: var(--clr-gold-2); color: #08080f; }
.btn-ghost {
background: transparent;
color: var(--clr-gold);
border: 1px solid var(--clr-gold-dim);
}
.btn-ghost:hover { border-color: var(--clr-gold); color: var(--clr-gold-2); }
.btn-lg { padding: .75rem 1.75rem; font-size: 1.05rem; }
.btn-block { width: 100%; display: flex; }
/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
position: relative;
min-height: calc(100vh - var(--nav-height));
display: flex;
align-items: center;
justify-content: center;
text-align: center;
padding: 4rem var(--col-gap);
background: radial-gradient(ellipse at 50% 40%, rgba(196,160,74,.08) 0%, transparent 70%),
radial-gradient(ellipse at 20% 80%, rgba(64,70,196,.05) 0%, transparent 60%),
var(--clr-bg);
}
.hero-content { max-width: 640px; }
.hero-title {
font-size: clamp(3rem, 8vw, 5.5rem);
letter-spacing: .06em;
color: var(--clr-gold);
text-shadow: 0 0 40px rgba(196,160,74,.3);
margin-bottom: 1rem;
}
.hero-tagline {
font-size: clamp(1rem, 2.5vw, 1.35rem);
color: var(--clr-text-2);
margin-bottom: 2.5rem;
line-height: 1.5;
}
.hero-actions {
display: flex;
gap: 1rem;
justify-content: center;
flex-wrap: wrap;
}
.hero-scroll-hint {
position: absolute;
bottom: 2rem;
left: 50%;
transform: translateX(-50%);
width: 2px;
height: 48px;
background: linear-gradient(to bottom, var(--clr-gold-dim), transparent);
border-radius: 2px;
}
/* ── Sections ───────────────────────────────────────────────────────────── */
.section { padding: 5rem 0; }
.section-dark { background: var(--clr-bg-2); }
/* ── Story teaser ───────────────────────────────────────────────────────── */
.story-beats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 2rem;
margin-bottom: 2.5rem;
}
.story-beat {
padding: 1.75rem;
border: 1px solid var(--clr-border);
border-radius: var(--radius-lg);
background: var(--clr-bg-card);
}
.beat-number {
font-size: 2rem;
font-weight: 700;
color: var(--clr-gold-dim);
margin-bottom: .75rem;
}
/* ── Match steps ────────────────────────────────────────────────────────── */
.match-steps {
list-style: none;
padding: 0;
display: flex;
flex-direction: column;
gap: 1rem;
margin-bottom: 2.5rem;
}
.match-step {
display: flex;
gap: 1rem;
align-items: flex-start;
padding: 1.25rem 1.5rem;
background: var(--clr-bg-card);
border-radius: var(--radius);
border: 1px solid var(--clr-border);
}
.step-icon {
color: var(--clr-gold);
font-size: 1.1rem;
flex-shrink: 0;
margin-top: .1rem;
}
/* ── CTA section ────────────────────────────────────────────────────────── */
.cta-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 2rem;
}
.cta-block {
padding: 2rem;
border: 1px solid var(--clr-border);
border-radius: var(--radius-lg);
}
.cta-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }
/* ── Page header ────────────────────────────────────────────────────────── */
.page-header {
padding: 3rem 0 2rem;
border-bottom: 1px solid var(--clr-border);
background: var(--clr-bg-2);
margin-bottom: 3rem;
}
.page-subtitle {
color: var(--clr-text-2);
font-size: 1.05rem;
margin-top: .5rem;
margin-bottom: 0;
}
/* ── Auth pages ─────────────────────────────────────────────────────────── */
.auth-page {
display: flex;
justify-content: center;
align-items: flex-start;
padding: 4rem 1rem;
min-height: 60vh;
}
.auth-card {
width: 100%;
max-width: 440px;
background: var(--clr-bg-card);
border: 1px solid var(--clr-border);
border-radius: var(--radius-lg);
padding: 2.5rem 2rem;
}
.auth-title {
font-size: 1.6rem;
margin-bottom: 1.5rem;
text-align: center;
}
.auth-subtitle {
color: var(--clr-text-2);
text-align: center;
margin-bottom: 1.5rem;
}
.auth-links {
text-align: center;
margin-top: 1.5rem;
color: var(--clr-text-2);
font-size: .9rem;
}
.auth-sep { margin: 0 .5rem; }
.webclient-actions { display: flex; flex-direction: column; gap: .75rem; margin: 1.5rem 0; }
/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
display: block;
font-size: .9rem;
font-weight: 600;
color: var(--clr-text-2);
margin-bottom: .4rem;
}
.form-control {
width: 100%;
padding: .6rem .9rem;
background: var(--clr-bg-3);
border: 1px solid var(--clr-border);
border-radius: var(--radius);
color: var(--clr-text);
font-size: .95rem;
transition: border-color .15s;
appearance: auto;
font-family: inherit;
}
.form-control:focus {
outline: none;
border-color: var(--clr-gold-dim);
box-shadow: 0 0 0 2px rgba(196,160,74,.15);
}
.form-check { display: flex; align-items: flex-start; gap: .5rem; }
.form-check-input { margin-top: .2rem; accent-color: var(--clr-gold); flex-shrink: 0; cursor: pointer; }
.form-check-label { font-size: .9rem; color: var(--clr-text-2); cursor: pointer; }
.form-hint { display: block; font-size: .8rem; color: var(--clr-text-3); margin-top: .3rem; }
.form-inline { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.form-inline label { font-size: .9rem; font-weight: 600; color: var(--clr-text-2); }
.field-error { display: block; color: var(--clr-red); font-size: .85rem; margin-top: .25rem; }
/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
padding: .85rem 1rem;
border-radius: var(--radius);
margin-bottom: 1.25rem;
font-size: .9rem;
}
.alert:empty { display: none; }
.alert-error { background: rgba(196,64,64,.12); border: 1px solid rgba(196,64,64,.3); color: #e08080; }
.alert-success { background: rgba(64,160,96,.12); border: 1px solid rgba(64,160,96,.3); color: #80d0a0; }
.alert-info { background: rgba(64,112,196,.12); border: 1px solid rgba(64,112,196,.3); color: #80a0e0; }
.alert-warn { background: rgba(196,160,64,.12); border: 1px solid rgba(196,160,64,.3); color: #d0b860; }
/* ── Account layout ─────────────────────────────────────────────────────── */
.account-layout {
display: grid;
grid-template-columns: 200px 1fr;
gap: 2.5rem;
padding-top: 2rem;
padding-bottom: 4rem;
align-items: start;
}
.account-nav {
display: flex;
flex-direction: column;
gap: .25rem;
position: sticky;
top: calc(var(--nav-height) + 1rem);
}
.account-nav-link {
display: block;
padding: .55rem .9rem;
border-radius: var(--radius);
color: var(--clr-text-2);
font-size: .9rem;
text-decoration: none;
transition: background .15s, color .15s;
}
.account-nav-link:hover { background: var(--clr-surface); color: var(--clr-text); text-decoration: none; }
.account-nav-link.active { background: var(--clr-surface); color: var(--clr-gold); font-weight: 600; }
.account-since { color: var(--clr-text-2); font-size: .9rem; margin-top: .25rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
padding: 1.25rem 1.5rem;
background: var(--clr-bg-card);
border: 1px solid var(--clr-border);
border-radius: var(--radius);
}
.stat-label { font-size: .8rem; color: var(--clr-text-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .4rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--clr-text); word-break: break-all; }
.stat-email { font-size: .95rem; font-family: var(--font-mono); }
.quick-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: var(--radius-sm); font-size: .75rem; font-weight: 600; }
.badge-warn { background: rgba(196,160,64,.2); color: #d0b860; }
/* ── Card catalog ───────────────────────────────────────────────────────── */
.catalog-layout {
display: grid;
grid-template-columns: 240px 1fr;
gap: 2.5rem;
padding-top: 0;
padding-bottom: 4rem;
align-items: start;
}
.catalog-filters {
position: sticky;
top: calc(var(--nav-height) + 1rem);
background: var(--clr-bg-card);
border: 1px solid var(--clr-border);
border-radius: var(--radius-lg);
padding: 1.5rem;
}
.filter-group { margin-bottom: 1rem; }
.filter-group label { display: block; font-size: .8rem; font-weight: 600; color: var(--clr-text-2); margin-bottom: .35rem; }
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
gap: 1rem;
}
.card-grid-compact { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.card-tile {
background: var(--clr-bg-card);
border: 1px solid var(--clr-border);
border-radius: var(--radius);
overflow: hidden;
text-decoration: none;
transition: border-color .15s, transform .1s;
display: block;
}
.card-tile:hover { border-color: var(--clr-gold-dim); transform: translateY(-2px); text-decoration: none; }
.card-tile-art {
height: 120px;
background: var(--clr-surface);
}
.card-tile-info { padding: .75rem; }
.card-tile-name { font-size: .9rem; font-weight: 600; color: var(--clr-text); margin-bottom: .3rem; }
.card-tile-meta { display: flex; gap: .4rem; flex-wrap: wrap; font-size: .75rem; color: var(--clr-text-3); }
.card-cost { display: flex; gap: .4rem; margin-top: .4rem; }
.cost-sp, .cost-st { font-size: .75rem; padding: .1rem .4rem; border-radius: var(--radius-sm); background: var(--clr-surface); color: var(--clr-text-2); }
/* ── Card detail ────────────────────────────────────────────────────────── */
.card-detail-layout {
display: grid;
grid-template-columns: 1fr 1.5fr;
gap: 3rem;
padding: 2rem var(--col-gap) 4rem;
align-items: start;
}
.card-art-full { width: 100%; border-radius: var(--radius-lg); border: 1px solid var(--clr-border); }
.card-art-placeholder { aspect-ratio: 2/3; background: var(--clr-surface); border-radius: var(--radius-lg); border: 1px solid var(--clr-border); }
.card-detail-name { font-size: 2rem; margin-bottom: 1rem; }
.card-detail-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.card-badge { padding: .2rem .6rem; border-radius: var(--radius-sm); font-size: .8rem; font-weight: 600; background: var(--clr-surface); color: var(--clr-text-2); }
.card-costs { display: flex; gap: .5rem; margin-bottom: 1rem; }
.cost-chip { padding: .3rem .75rem; border-radius: var(--radius); font-weight: 700; }
.cost-chip.cost-sp { background: rgba(64,112,196,.15); color: #80a0e0; }
.cost-chip.cost-st { background: rgba(196,64,64,.15); color: #e08080; }
.card-stats { display: flex; gap: 1.5rem; margin-bottom: 1.25rem; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat span { font-size: .75rem; color: var(--clr-text-3); text-transform: uppercase; }
.stat strong { font-size: 1.4rem; font-weight: 700; }
.card-description { margin-bottom: 1rem; color: var(--clr-text-2); }
.card-genus { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.genus-tag { padding: .15rem .5rem; background: var(--clr-surface); border-radius: var(--radius-sm); font-size: .8rem; color: var(--clr-text-3); }
.card-chain { margin-bottom: 1rem; font-size: .9rem; color: var(--clr-text-2); }
.card-chain a { color: var(--clr-gold); }
.card-detail-actions { margin-top: 1.5rem; }
.breadcrumb { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--clr-text-3); margin-bottom: .5rem; }
.breadcrumb a { color: var(--clr-gold); }
.related-cards { margin-top: 3rem; padding-bottom: 4rem; }
.related-cards h2 { margin-bottom: 1.25rem; }
/* ── Leaderboard ────────────────────────────────────────────────────────── */
.leaderboard-table {
width: 100%;
border-collapse: collapse;
margin-bottom: 3rem;
}
.leaderboard-table th {
text-align: left;
padding: .7rem 1rem;
font-size: .8rem;
text-transform: uppercase;
letter-spacing: .05em;
color: var(--clr-text-3);
border-bottom: 1px solid var(--clr-border);
}
.leaderboard-table td {
padding: .75rem 1rem;
border-bottom: 1px solid var(--clr-border-2);
font-size: .95rem;
}
.leaderboard-self td { background: rgba(196,160,74,.06); }
.rank-top-1 td:first-child { color: var(--clr-gold-2); }
.rank-top-2 td:first-child { color: #c0c0d0; }
.rank-top-3 td:first-child { color: #c08040; }
.rank-badge {
display: inline-flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border-radius: 50%;
font-weight: 700;
font-size: .85rem;
}
.rank-badge-1 { background: rgba(196,160,74,.2); color: var(--clr-gold-2); }
.rank-badge-2 { background: rgba(192,192,208,.15); color: #c0c0d0; }
.rank-badge-3 { background: rgba(192,128,64,.15); color: #c08040; }
.self-tag { font-size: .8rem; color: var(--clr-gold-dim); margin-left: .4rem; }
/* ── Prose pages ────────────────────────────────────────────────────────── */
.prose-page { max-width: 760px; padding-bottom: 5rem; }
.prose-section { margin-bottom: 2.5rem; }
.prose-section h2 { margin-bottom: 1rem; }
.prose-section ul, .prose-section ol { margin-bottom: 0; }
.prose-cta { margin-top: 2.5rem; }
.prose-disclaimer { color: var(--clr-text-3); font-size: .85rem; margin-top: 2rem; font-style: italic; }
/* ── Story page ─────────────────────────────────────────────────────────── */
.story-page { padding-bottom: 5rem; }
.story-section { padding: 3rem 0; border-bottom: 1px solid var(--clr-border); }
.story-section:last-child { border-bottom: none; }
.story-section h2 { color: var(--clr-gold); margin-bottom: 2rem; font-size: 1.5rem; text-transform: uppercase; letter-spacing: .08em; }
.story-panel {
padding: 1.75rem;
margin-bottom: 1.25rem;
border-left: 3px solid var(--clr-gold-dim);
background: var(--clr-bg-2);
border-radius: 0 var(--radius) var(--radius) 0;
}
.story-panel h3 { color: var(--clr-gold); margin-bottom: .5rem; }
.story-panel p { color: var(--clr-text-2); margin-bottom: 0; }
.story-panel-threat { border-left-color: var(--clr-red); }
.story-panel-threat h3 { color: #e08080; }
.story-panel-call { border-left-color: var(--clr-gold); background: var(--clr-bg-card); }
.story-quote {
border-left: none;
padding: 1rem 0;
font-size: 1.2rem;
font-style: italic;
color: var(--clr-gold);
text-align: center;
margin: 1rem 0;
}
.story-cta { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1.5rem; }
/* ── How-to page ────────────────────────────────────────────────────────── */
.howto-page {
display: grid;
grid-template-columns: 200px 1fr;
gap: 3rem;
padding-bottom: 5rem;
align-items: start;
}
.howto-nav {
position: sticky;
top: calc(var(--nav-height) + 1.5rem);
display: flex;
flex-direction: column;
gap: .1rem;
font-size: .875rem;
}
.howto-nav a { color: var(--clr-text-2); padding: .35rem .6rem; border-radius: var(--radius-sm); transition: color .15s; }
.howto-nav a:hover { color: var(--clr-gold); text-decoration: none; }
.howto-section { padding: 2rem 0; border-bottom: 1px solid var(--clr-border-2); }
.howto-section:first-of-type { padding-top: 0; }
.howto-section:last-of-type { border-bottom: none; }
.howto-section h2 { color: var(--clr-gold); font-size: 1.3rem; margin-bottom: 1rem; }
.card-type-list, .glossary { display: grid; gap: .75rem; }
.card-type-list dt, .glossary dt { font-weight: 700; color: var(--clr-text); }
.card-type-list dd, .glossary dd { color: var(--clr-text-2); padding-left: 1rem; margin-bottom: .25rem; }
.turn-steps { padding-left: 1.4rem; }
.turn-steps li { margin-bottom: .6rem; }
.howto-cta { display: flex; gap: 1rem; flex-wrap: wrap; padding: 2rem 0 0; }
/* ── AI Asset / Report ──────────────────────────────────────────────────── */
.search-form { margin-bottom: 1.5rem; }
.table-wrapper { overflow-x: auto; margin-bottom: 1.5rem; }
.data-table {
width: 100%;
border-collapse: collapse;
font-size: .9rem;
}
.data-table th {
text-align: left;
padding: .7rem 1rem;
background: var(--clr-bg-2);
border-bottom: 1px solid var(--clr-border);
color: var(--clr-text-2);
font-size: .8rem;
text-transform: uppercase;
letter-spacing: .04em;
}
.data-table td {
padding: .65rem 1rem;
border-bottom: 1px solid var(--clr-border-2);
color: var(--clr-text-2);
}
.mono { font-family: var(--font-mono); font-size: .85rem; }
.report-footer { padding-top: 1.5rem; }
/* ── Pagination ─────────────────────────────────────────────────────────── */
.pagination {
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
padding: 2rem 0;
}
.pagination-btn { color: var(--clr-gold); }
.pagination-info { color: var(--clr-text-2); font-size: .9rem; }
/* ── Empty / Coming soon ────────────────────────────────────────────────── */
.empty-state {
text-align: center;
padding: 5rem 1rem;
color: var(--clr-text-2);
}
.empty-state p { margin-bottom: 1.5rem; }
.coming-soon-block {
padding: 3rem;
border: 1px dashed var(--clr-border);
border-radius: var(--radius-lg);
text-align: center;
color: var(--clr-text-2);
margin-top: 1.5rem;
}
.coming-soon-block p { margin-bottom: 1.25rem; }
/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
background: var(--clr-bg-2);
border-top: 1px solid var(--clr-border);
padding: 2rem 0;
}
.footer-inner {
max-width: var(--max-width);
margin: 0 auto;
padding: 0 var(--col-gap);
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 1rem;
}
.footer-copy { color: var(--clr-text-3); font-size: .875rem; margin: 0; }
.footer-links { display: flex; gap: 1.25rem; font-size: .875rem; }
.footer-links a { color: var(--clr-text-3); }
.footer-links a:hover { color: var(--clr-gold); text-decoration: none; }
/* ── Text helpers ───────────────────────────────────────────────────────── */
.text-muted { color: var(--clr-text-2); font-size: .875rem; margin-top: 1rem; }
/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
.catalog-layout,
.card-detail-layout,
.howto-page,
.account-layout {
grid-template-columns: 1fr;
}
.catalog-filters,
.howto-nav,
.account-nav {
position: static;
}
.account-nav { flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 680px) {
.nav-links {
display: none;
position: absolute;
top: var(--nav-height);
left: 0;
right: 0;
background: var(--clr-bg);
border-bottom: 1px solid var(--clr-border);
flex-direction: column;
padding: .75rem;
gap: .1rem;
}
.nav-links.open { display: flex; }
.nav-toggle { display: flex; }
.nav-account {
margin-left: 0;
gap: .3rem;
}
.auth-card { padding: 2rem 1.25rem; }
.footer-inner { flex-direction: column; text-align: center; }
}
/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: .01ms !important;
transition-duration: .01ms !important;
}
html { scroll-behavior: auto; }
}
+54
View File
@@ -0,0 +1,54 @@
// site.js — minimal vanilla JS for Aeternalis website
// No inline scripts anywhere in the application.
// All JavaScript must be in this file or other files loaded via <script src="...">.
// This is required for the strict Content-Security-Policy (script-src 'self').
(function () {
'use strict';
// ── Mobile nav toggle ────────────────────────────────────────────────────
// Toggles the nav-links list open/closed on mobile viewports.
// Uses aria-expanded to communicate state to assistive technologies.
var toggle = document.querySelector('.nav-toggle');
var navLinks = document.getElementById('nav-links');
if (toggle && navLinks) {
toggle.addEventListener('click', function () {
var isOpen = navLinks.classList.toggle('open');
toggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
});
// Close nav when clicking a link
navLinks.addEventListener('click', function (e) {
if (e.target.tagName === 'A') {
navLinks.classList.remove('open');
toggle.setAttribute('aria-expanded', 'false');
}
});
}
// ── Auto-submit catalog filter form on select change ────────────────────
// Submits the filter form when any <select> inside #filter-form changes.
// This avoids needing an "Apply" button press for single-filter changes.
// Search input uses a debounce to avoid a request on every keypress.
var filterForm = document.getElementById('filter-form');
if (filterForm) {
filterForm.querySelectorAll('select').forEach(function (sel) {
sel.addEventListener('change', function () {
filterForm.submit();
});
});
var searchInput = filterForm.querySelector('input[type="search"]');
if (searchInput) {
var debounceTimer;
searchInput.addEventListener('input', function () {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(function () {
filterForm.submit();
}, 500);
});
}
}
})();