Compare commits
1 Commits
master
..
8e4298404d
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e4298404d |
@@ -8,15 +8,7 @@
|
|||||||
"Bash(awk '{print $NF}')",
|
"Bash(awk '{print $NF}')",
|
||||||
"Bash(dotnet test *)",
|
"Bash(dotnet test *)",
|
||||||
"Bash(dotnet user-secrets *)",
|
"Bash(dotnet user-secrets *)",
|
||||||
"Bash(env)",
|
"Bash(env)"
|
||||||
"Bash(grep -E \"\\\\.\\(cs|json|razor\\)$\")",
|
|
||||||
"Bash(dotnet package *)",
|
|
||||||
"Bash(dotnet restore *)",
|
|
||||||
"Bash(powershell -Command '[Reflection.Assembly]::LoadFrom\\('\\\\''C:\\\\Users\\\\jonmc\\\\.nuget\\\\packages\\\\microsoft.playwright\\\\1.60.0\\\\lib\\\\netstandard2.0\\\\Microsoft.Playwright.dll'\\\\''\\) | Out-Null; [Microsoft.Playwright.IBrowserContext].GetMethods\\(\\) | Where-Object { $_.Name -match '\\\\''Virtual|Authenticator|CDP|Request'\\\\'' } | Select-Object Name')",
|
|
||||||
"Bash(powershell -Command 'Add-Type -Path '\\\\''C:\\\\Users\\\\jonmc\\\\.nuget\\\\packages\\\\microsoft.playwright\\\\1.60.0\\\\lib\\\\netstandard2.0\\\\Microsoft.Playwright.dll'\\\\''; [AppDomain]::CurrentDomain.GetAssemblies\\(\\) | Where-Object { $_.GetName\\(\\).Name -eq '\\\\''Microsoft.Playwright'\\\\'' } | ForEach-Object { $_.GetExportedTypes\\(\\) | Where-Object { $_.Name -match '\\\\''Virtual|Authenticator|IBrowserContext'\\\\'' } | Select-Object FullName }')",
|
|
||||||
"Bash(python3 -c \"import json; d=json.load\\(open\\('/c/Users/jonmc/.nuget/packages/microsoft.playwright/1.60.0/.playwright/package/api.json'\\)\\); keys=[k for k in str\\(d\\) if 'Virtual' in k or 'Authenticator' in k]; print\\(keys[:5]\\)\")",
|
|
||||||
"Bash(python3 -c ' *)",
|
|
||||||
"Bash(powershell -Command ' *)"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Model;
|
using Chrono.Model;
|
||||||
|
|
||||||
var repoRoot = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", ".."));
|
var repoRoot = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", ".."));
|
||||||
var docsDir = Path.Combine(repoRoot, "chrono.docs");
|
var docsDir = Path.Combine(repoRoot, "chrono.docs");
|
||||||
var webWwwRoot = Path.Combine(repoRoot, "Chrono", "Standalone", "wwwroot");
|
var webWwwRoot = Path.Combine(repoRoot, "Chrono", "Web", "wwwroot");
|
||||||
var generatedFile = Path.Combine(repoRoot, "Chrono", "Shared", "Generated", "Cards.g.cs");
|
var generatedFile = Path.Combine(repoRoot, "Chrono", "Shared", "Generated", "Cards.g.cs");
|
||||||
|
|
||||||
Console.WriteLine($"Repo root: {repoRoot}");
|
Console.WriteLine($"Repo root: {repoRoot}");
|
||||||
@@ -49,7 +49,7 @@ foreach (var file in mdFiles)
|
|||||||
Attack = ParseInt(yaml, "attack"),
|
Attack = ParseInt(yaml, "attack"),
|
||||||
Health = ParseInt(yaml, "health"),
|
Health = ParseInt(yaml, "health"),
|
||||||
Description = StripWikiLinks(yaml.GetValueOrDefault("description")),
|
Description = StripWikiLinks(yaml.GetValueOrDefault("description")),
|
||||||
Syndicate = StripWikiLink(yaml.GetValueOrDefault("faction")),
|
Faction = StripWikiLink(yaml.GetValueOrDefault("faction")),
|
||||||
Set = StripWikiLink(yaml.GetValueOrDefault("set")),
|
Set = StripWikiLink(yaml.GetValueOrDefault("set")),
|
||||||
Speed = StripWikiLink(yaml.GetValueOrDefault("speed")),
|
Speed = StripWikiLink(yaml.GetValueOrDefault("speed")),
|
||||||
Archetypes = ParseList(yaml, "archetypes").Select(s => StripWikiLink(s) ?? "").Where(s => s != "").ToList(),
|
Archetypes = ParseList(yaml, "archetypes").Select(s => StripWikiLink(s) ?? "").Where(s => s != "").ToList(),
|
||||||
@@ -66,13 +66,32 @@ foreach (var file in mdFiles)
|
|||||||
cards.Add(card);
|
cards.Add(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy PNGs to wwwroot/cards
|
||||||
|
var cardsDir = Path.Combine(webWwwRoot, "cards");
|
||||||
|
Directory.CreateDirectory(cardsDir);
|
||||||
|
|
||||||
|
var pngFiles = Directory.GetFiles(docsDir, "*.png", SearchOption.AllDirectories);
|
||||||
|
var pngMap = pngFiles
|
||||||
|
.GroupBy(Path.GetFileName)
|
||||||
|
.ToDictionary(g => g.Key!, g => g.First(), StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
foreach (var card in cards)
|
||||||
|
{
|
||||||
|
if (card.ImageFile == null) continue;
|
||||||
|
if (pngMap.TryGetValue(card.ImageFile, out var src))
|
||||||
|
{
|
||||||
|
var dst = Path.Combine(cardsDir, card.ImageFile);
|
||||||
|
File.Copy(src, dst, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generate C# source file
|
// Generate C# source file
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(generatedFile)!);
|
Directory.CreateDirectory(Path.GetDirectoryName(generatedFile)!);
|
||||||
using var writer = new StreamWriter(generatedFile, false, Encoding.UTF8);
|
using var writer = new StreamWriter(generatedFile, false, Encoding.UTF8);
|
||||||
writer.WriteLine("// <auto-generated/>");
|
writer.WriteLine("// <auto-generated/>");
|
||||||
writer.WriteLine("#nullable enable");
|
writer.WriteLine("#nullable enable");
|
||||||
writer.WriteLine();
|
writer.WriteLine();
|
||||||
writer.WriteLine("namespace Model;");
|
writer.WriteLine("namespace Chrono.Model;");
|
||||||
writer.WriteLine();
|
writer.WriteLine();
|
||||||
writer.WriteLine("public static class CardDatabase");
|
writer.WriteLine("public static class CardDatabase");
|
||||||
writer.WriteLine("{");
|
writer.WriteLine("{");
|
||||||
@@ -90,7 +109,7 @@ for (var i = 0; i < cards.Count; i++)
|
|||||||
WriteNullProp(writer, "Attack", c.Attack, 3);
|
WriteNullProp(writer, "Attack", c.Attack, 3);
|
||||||
WriteNullProp(writer, "Health", c.Health, 3);
|
WriteNullProp(writer, "Health", c.Health, 3);
|
||||||
WriteStrProp(writer, "Description", c.Description, 3);
|
WriteStrProp(writer, "Description", c.Description, 3);
|
||||||
WriteStrProp(writer, "Syndicate", c.Syndicate, 3);
|
WriteStrProp(writer, "Faction", c.Faction, 3);
|
||||||
WriteStrProp(writer, "Set", c.Set, 3);
|
WriteStrProp(writer, "Set", c.Set, 3);
|
||||||
WriteStrProp(writer, "Speed", c.Speed, 3);
|
WriteStrProp(writer, "Speed", c.Speed, 3);
|
||||||
WriteListProp(writer, "Archetypes", c.Archetypes, 3);
|
WriteListProp(writer, "Archetypes", c.Archetypes, 3);
|
||||||
@@ -138,7 +157,7 @@ foreach (var file in deckFiles)
|
|||||||
Divers = ParseList(yaml, "divers").Select(s => StripWikiLink(s) ?? "").Where(s => s != "").ToList(),
|
Divers = ParseList(yaml, "divers").Select(s => StripWikiLink(s) ?? "").Where(s => s != "").ToList(),
|
||||||
Description = StripWikiLinks(NullIfNa(yaml.GetValueOrDefault("description")))?.Replace("\r\n", "\n")
|
Description = StripWikiLinks(NullIfNa(yaml.GetValueOrDefault("description")))?.Replace("\r\n", "\n")
|
||||||
.Replace("\r", "\n").Replace("\n\n", "\n").Replace("\n\n", "\n"),
|
.Replace("\r", "\n").Replace("\n\n", "\n").Replace("\n\n", "\n"),
|
||||||
Syndicates = ParseList(yaml, "factions").Select(s => StripWikiLink(s) ?? "").Where(s => s != "").ToList(),
|
Factions = ParseList(yaml, "factions").Select(s => StripWikiLink(s) ?? "").Where(s => s != "").ToList(),
|
||||||
IsVisible = isVisible,
|
IsVisible = isVisible,
|
||||||
DeckCode = deckCode,
|
DeckCode = deckCode,
|
||||||
DeckType = yaml.GetValueOrDefault("deckType")
|
DeckType = yaml.GetValueOrDefault("deckType")
|
||||||
@@ -156,7 +175,7 @@ using var deckWriter = new StreamWriter(deckGeneratedFile, false, Encoding.UTF8)
|
|||||||
deckWriter.WriteLine("// <auto-generated/>");
|
deckWriter.WriteLine("// <auto-generated/>");
|
||||||
deckWriter.WriteLine("#nullable enable");
|
deckWriter.WriteLine("#nullable enable");
|
||||||
deckWriter.WriteLine();
|
deckWriter.WriteLine();
|
||||||
deckWriter.WriteLine("namespace Model;");
|
deckWriter.WriteLine("namespace Chrono.Model;");
|
||||||
deckWriter.WriteLine();
|
deckWriter.WriteLine();
|
||||||
deckWriter.WriteLine("public static class DeckDatabase");
|
deckWriter.WriteLine("public static class DeckDatabase");
|
||||||
deckWriter.WriteLine("{");
|
deckWriter.WriteLine("{");
|
||||||
@@ -173,7 +192,7 @@ for (var i = 0; i < decks.Count; i++)
|
|||||||
WriteListProp(deckWriter, "Keycards", d.Keycards, 3);
|
WriteListProp(deckWriter, "Keycards", d.Keycards, 3);
|
||||||
WriteListProp(deckWriter, "Divers", d.Divers, 3);
|
WriteListProp(deckWriter, "Divers", d.Divers, 3);
|
||||||
WriteStrProp(deckWriter, "Description", d.Description, 3);
|
WriteStrProp(deckWriter, "Description", d.Description, 3);
|
||||||
WriteListProp(deckWriter, "Syndicates", d.Syndicates, 3);
|
WriteListProp(deckWriter, "Factions", d.Factions, 3);
|
||||||
deckWriter.WriteLine($" IsVisible = {(d.IsVisible ? "true" : "false")},");
|
deckWriter.WriteLine($" IsVisible = {(d.IsVisible ? "true" : "false")},");
|
||||||
WriteStrProp(deckWriter, "DeckCode", d.DeckCode, 3);
|
WriteStrProp(deckWriter, "DeckCode", d.DeckCode, 3);
|
||||||
WriteStrProp(deckWriter, "DeckType", d.DeckType, 3);
|
WriteStrProp(deckWriter, "DeckType", d.DeckType, 3);
|
||||||
@@ -210,38 +229,19 @@ foreach (var file in mdFiles)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var category = yaml.GetValueOrDefault("category");
|
var category = yaml.GetValueOrDefault("category") ?? Path.GetFileName(Path.GetDirectoryName(file)) ?? "";
|
||||||
if (category == null)
|
|
||||||
{
|
|
||||||
var parentDir = Path.GetFileName(Path.GetDirectoryName(file)) ?? "";
|
|
||||||
category = parentDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (excludedCategories.Contains(category)) continue;
|
if (excludedCategories.Contains(category)) continue;
|
||||||
|
|
||||||
// Also exclude files that look like base templates
|
// Also exclude files that look like base templates
|
||||||
var fileName = Path.GetFileName(file);
|
var fileName = Path.GetFileName(file);
|
||||||
if (fileName.StartsWith("_")) continue;
|
if (fileName.StartsWith("_")) continue;
|
||||||
|
|
||||||
// Special handling for Syndicates and Syndicate Pairings
|
|
||||||
List<string>? syndicatesProp = null;
|
|
||||||
if (category == "Syndicate Pairings")
|
|
||||||
{
|
|
||||||
syndicatesProp = ParseList(yaml, "syndicates");
|
|
||||||
}
|
|
||||||
else if (category == "Syndicate" || category == "Faction")
|
|
||||||
{
|
|
||||||
syndicatesProp = [Path.GetFileNameWithoutExtension(file)];
|
|
||||||
category = "Syndicate"; // Normalize Faction to Syndicate
|
|
||||||
}
|
|
||||||
|
|
||||||
docs.Add(new DocData
|
docs.Add(new DocData
|
||||||
{
|
{
|
||||||
Title = Path.GetFileNameWithoutExtension(file),
|
Title = Path.GetFileNameWithoutExtension(file),
|
||||||
Category = category,
|
Category = category,
|
||||||
Content = body,
|
Content = body,
|
||||||
Frontmatter = yaml,
|
Frontmatter = yaml
|
||||||
Syndicates = syndicatesProp
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ using var docWriter = new StreamWriter(docGeneratedFile, false, Encoding.UTF8);
|
|||||||
docWriter.WriteLine("// <auto-generated/>");
|
docWriter.WriteLine("// <auto-generated/>");
|
||||||
docWriter.WriteLine("#nullable enable");
|
docWriter.WriteLine("#nullable enable");
|
||||||
docWriter.WriteLine();
|
docWriter.WriteLine();
|
||||||
docWriter.WriteLine("namespace Model;");
|
docWriter.WriteLine("namespace Chrono.Model;");
|
||||||
docWriter.WriteLine();
|
docWriter.WriteLine();
|
||||||
docWriter.WriteLine("public static class DocDatabase");
|
docWriter.WriteLine("public static class DocDatabase");
|
||||||
docWriter.WriteLine("{");
|
docWriter.WriteLine("{");
|
||||||
@@ -267,7 +267,6 @@ for (var i = 0; i < docs.Count; i++)
|
|||||||
WriteProp(docWriter, "Category", d.Category, 3);
|
WriteProp(docWriter, "Category", d.Category, 3);
|
||||||
WriteStrProp(docWriter, "Content", d.Content, 3);
|
WriteStrProp(docWriter, "Content", d.Content, 3);
|
||||||
WriteDictProp(docWriter, "Frontmatter", d.Frontmatter, 3);
|
WriteDictProp(docWriter, "Frontmatter", d.Frontmatter, 3);
|
||||||
WriteListProp(docWriter, "Syndicates", d.Syndicates, 3);
|
|
||||||
var comma = i < docs.Count - 1 ? "," : "";
|
var comma = i < docs.Count - 1 ? "," : "";
|
||||||
docWriter.WriteLine($" }}{comma}");
|
docWriter.WriteLine($" }}{comma}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
"""
|
||||||
|
One-time script: Download card images from playchrono.com and add imageLink frontmatter.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python process_cards.py
|
||||||
|
|
||||||
|
Requires a saved HTML copy of https://www.playchrono.com/collections/cards
|
||||||
|
with the embedded JSON.parse('...') card data.
|
||||||
|
"""
|
||||||
|
import re
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import urllib.request
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Adjust these paths for your environment
|
||||||
|
html_file = r"../playchrono_cards_page.html"
|
||||||
|
docs_dir = r"../../chrono.docs"
|
||||||
|
|
||||||
|
if not os.path.exists(html_file):
|
||||||
|
# Fallback: search for saved tool output
|
||||||
|
possible = [f for f in os.listdir(r"C:\Users\jonmc\.local\share\opencode\tool-output")
|
||||||
|
if f.startswith("tool_") and os.path.isfile(os.path.join(r"C:\Users\jonmc\.local\share\opencode\tool-output", f))]
|
||||||
|
if possible:
|
||||||
|
html_file = os.path.join(r"C:\Users\jonmc\.local\share\opencode\tool-output", possible[-1])
|
||||||
|
|
||||||
|
with open(html_file, 'r', encoding='utf-8') as f:
|
||||||
|
html = f.read()
|
||||||
|
|
||||||
|
start_marker = "JSON.parse('"
|
||||||
|
idx = html.find(start_marker)
|
||||||
|
if idx < 0:
|
||||||
|
print("ERROR: Could not find JSON.parse in HTML")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
start = idx + len(start_marker)
|
||||||
|
quote_end = html.find("')", start)
|
||||||
|
if quote_end < 0:
|
||||||
|
print("ERROR: Could not find closing '")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
raw_json_str = html[start:quote_end]
|
||||||
|
|
||||||
|
json_str = raw_json_str.encode('utf-8').decode('unicode_escape')
|
||||||
|
json_str = json_str.replace('\\/', '/')
|
||||||
|
|
||||||
|
try:
|
||||||
|
cards = json.loads(json_str)
|
||||||
|
except json.JSONDecodeError as e:
|
||||||
|
print(f"ERROR parsing JSON: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
print(f"Found {len(cards)} cards")
|
||||||
|
|
||||||
|
name_to_image = {}
|
||||||
|
for card in cards:
|
||||||
|
name = card.get('name', '')
|
||||||
|
image_url = card.get('image_url', '')
|
||||||
|
if name and image_url:
|
||||||
|
name_to_image[name.lower()] = image_url
|
||||||
|
counterpart = card.get('counterpart')
|
||||||
|
if counterpart and isinstance(counterpart, dict):
|
||||||
|
cname = counterpart.get('name', '')
|
||||||
|
cimage = counterpart.get('image_url', '')
|
||||||
|
if cname and cimage:
|
||||||
|
name_to_image[cname.lower()] = cimage
|
||||||
|
|
||||||
|
print(f"Built mapping for {len(name_to_image)} card names")
|
||||||
|
|
||||||
|
md_files = [f for f in os.listdir(docs_dir) if f.endswith('.md')]
|
||||||
|
print(f"Found {len(md_files)} markdown files")
|
||||||
|
|
||||||
|
processed = 0
|
||||||
|
downloaded = 0
|
||||||
|
matched = 0
|
||||||
|
for md_file in sorted(md_files):
|
||||||
|
filepath = os.path.join(docs_dir, md_file)
|
||||||
|
|
||||||
|
card_name = md_file[:-3]
|
||||||
|
card_name_lower = card_name.lower()
|
||||||
|
|
||||||
|
if card_name_lower not in name_to_image:
|
||||||
|
continue
|
||||||
|
|
||||||
|
matched += 1
|
||||||
|
image_url = name_to_image[card_name_lower]
|
||||||
|
|
||||||
|
png_filename = f"{card_name}.png"
|
||||||
|
png_filepath = os.path.join(docs_dir, png_filename)
|
||||||
|
|
||||||
|
if not os.path.exists(png_filepath):
|
||||||
|
try:
|
||||||
|
print(f" DL: {png_filename}")
|
||||||
|
req = urllib.request.Request(image_url, headers={
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'
|
||||||
|
})
|
||||||
|
with urllib.request.urlopen(req) as response:
|
||||||
|
with open(png_filepath, 'wb') as out:
|
||||||
|
out.write(response.read())
|
||||||
|
downloaded += 1
|
||||||
|
except Exception as e:
|
||||||
|
print(f" ERR: {png_filename} - {e}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
with open(filepath, 'r', encoding='utf-8') as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
has_image_link = 'imageLink:' in content
|
||||||
|
img_ref = f"![[{png_filename}]]"
|
||||||
|
has_img_ref = img_ref in content
|
||||||
|
|
||||||
|
if has_image_link and has_img_ref:
|
||||||
|
continue
|
||||||
|
|
||||||
|
modified = content
|
||||||
|
|
||||||
|
if not has_image_link:
|
||||||
|
modified = modified.rstrip()
|
||||||
|
if modified.endswith('---'):
|
||||||
|
modified = modified[:-3] + f'imageLink: "[[{png_filename}]]"\n---'
|
||||||
|
else:
|
||||||
|
modified = modified + f'\nimageLink: "[[{png_filename}]]"\n'
|
||||||
|
|
||||||
|
if not has_img_ref:
|
||||||
|
modified = modified.rstrip() + f'\n\n\n{img_ref}\n'
|
||||||
|
|
||||||
|
with open(filepath, 'w', encoding='utf-8') as f:
|
||||||
|
f.write(modified)
|
||||||
|
|
||||||
|
processed += 1
|
||||||
|
|
||||||
|
print(f"\nDone! Matched: {matched}, Downloaded: {downloaded}, Updated markdown: {processed}")
|
||||||
|
print(f"Skipped (no card match): {len(md_files) - matched}")
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Standalone", "Standalone\Standalone.csproj", "{18981096-443A-44BF-AE56-6499C2B03AEF}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web", "Web\Web.csproj", "{18981096-443A-44BF-AE56-6499C2B03AEF}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "Build\Build.csproj", "{36E3775C-0E28-4EAE-AE92-4FB493E3787F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "Build\Build.csproj", "{36E3775C-0E28-4EAE-AE92-4FB493E3787F}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -10,16 +10,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deploy", "Deploy\Deploy.csp
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{90F32056-6983-4224-8A8C-E797C71633F3}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{90F32056-6983-4224-8A8C-E797C71633F3}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cloud", "Cloud\Cloud.csproj", "{BFB7B73F-EFDD-4DE8-89F2-E1CBE1B55C27}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{BFB7B73F-EFDD-4DE8-89F2-E1CBE1B55C27}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{30D8468D-01E1-4D8A-99AF-EE4A75A5E956}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{30D8468D-01E1-4D8A-99AF-EE4A75A5E956}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Markdown", "Markdown\Markdown.csproj", "{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "md", "md", "{A4C572E4-E709-4553-B42F-709BFFFE0A7E}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shared", "shared", "{92ED656F-1D94-4348-97AD-B76094B14A8E}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -114,28 +108,8 @@ Global
|
|||||||
{30D8468D-01E1-4D8A-99AF-EE4A75A5E956}.Release|x64.Build.0 = Release|Any CPU
|
{30D8468D-01E1-4D8A-99AF-EE4A75A5E956}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{30D8468D-01E1-4D8A-99AF-EE4A75A5E956}.Release|x86.ActiveCfg = Release|Any CPU
|
{30D8468D-01E1-4D8A-99AF-EE4A75A5E956}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{30D8468D-01E1-4D8A-99AF-EE4A75A5E956}.Release|x86.Build.0 = Release|Any CPU
|
{30D8468D-01E1-4D8A-99AF-EE4A75A5E956}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Debug|x86.Build.0 = Debug|Any CPU
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Release|x86.ActiveCfg = Release|Any CPU
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C}.Release|x86.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
|
||||||
{BA7A908C-FEF7-4AC7-ABCE-437259A6C34C} = {A4C572E4-E709-4553-B42F-709BFFFE0A7E}
|
|
||||||
{36E3775C-0E28-4EAE-AE92-4FB493E3787F} = {92ED656F-1D94-4348-97AD-B76094B14A8E}
|
|
||||||
{90F32056-6983-4224-8A8C-E797C71633F3} = {92ED656F-1D94-4348-97AD-B76094B14A8E}
|
|
||||||
{30D8468D-01E1-4D8A-99AF-EE4A75A5E956} = {92ED656F-1D94-4348-97AD-B76094B14A8E}
|
|
||||||
{3358AF7A-603B-4BAC-A7F5-07978FB87843} = {92ED656F-1D94-4348-97AD-B76094B14A8E}
|
|
||||||
{E5E9A799-76C8-43B3-B9C2-3CAEC2B5E1DD} = {92ED656F-1D94-4348-97AD-B76094B14A8E}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
@inherits LayoutComponentBase
|
|
||||||
@inject Shared.Services.CardPreviewService PreviewService
|
|
||||||
<div class="page">
|
|
||||||
<div class="sidebar">
|
|
||||||
<NavMenu/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<main>
|
|
||||||
<NavigationTracker/>
|
|
||||||
<article class="content px-4">
|
|
||||||
<TelerikRootComponent>
|
|
||||||
@Body
|
|
||||||
<Shared.Components.CardPreview />
|
|
||||||
<Shared.Components.DocDetailModal Doc="@PreviewService.SelectedDoc"
|
|
||||||
OnClose="@(() => PreviewService.SelectDoc(null))" />
|
|
||||||
</TelerikRootComponent>
|
|
||||||
</article>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
@page "/login"
|
|
||||||
@rendermode InteractiveServer
|
|
||||||
@attribute [AllowAnonymous]
|
|
||||||
@inject IJSRuntime JS
|
|
||||||
@inject NavigationManager Nav
|
|
||||||
@inject AuthenticationStateProvider AuthStateProvider
|
|
||||||
|
|
||||||
<PageTitle>Sign In — Chrono CCG</PageTitle>
|
|
||||||
|
|
||||||
<div class="login-container">
|
|
||||||
<div class="login-card">
|
|
||||||
<h1 class="login-title">Chrono CCG</h1>
|
|
||||||
|
|
||||||
@if (_error is not null)
|
|
||||||
{
|
|
||||||
<div class="alert alert-danger">@_error</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (_enrolled)
|
|
||||||
{
|
|
||||||
<p class="login-hint">Use your registered passkey to sign in.</p>
|
|
||||||
<button class="btn btn-primary btn-lg w-100" @onclick="SignIn" disabled="@_busy">
|
|
||||||
@if (_busy)
|
|
||||||
{
|
|
||||||
<span class="spinner-border spinner-border-sm me-2" role="status"></span>
|
|
||||||
}
|
|
||||||
Sign in with Passkey
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<p class="login-hint">No passkey enrolled yet. Register your device to get started.</p>
|
|
||||||
<button class="btn btn-success btn-lg w-100" @onclick="Enroll" disabled="@_busy">
|
|
||||||
@if (_busy)
|
|
||||||
{
|
|
||||||
<span class="spinner-border spinner-border-sm me-2" role="status"></span>
|
|
||||||
}
|
|
||||||
Enroll Passkey
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private bool _enrolled;
|
|
||||||
private bool _busy;
|
|
||||||
private string? _error;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
|
|
||||||
if (authState.User.Identity?.IsAuthenticated == true)
|
|
||||||
{
|
|
||||||
Nav.NavigateTo("/", replace: true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var http = new HttpClient { BaseAddress = new Uri(Nav.BaseUri) };
|
|
||||||
var status = await http.GetFromJsonAsync<StatusResponse>("/api/auth/status");
|
|
||||||
_enrolled = status?.Enrolled ?? false;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
_enrolled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SignIn()
|
|
||||||
{
|
|
||||||
_busy = true;
|
|
||||||
_error = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await JS.InvokeVoidAsync("passkeyLogin");
|
|
||||||
Nav.NavigateTo("/", true);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_error = ex.Message;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_busy = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Enroll()
|
|
||||||
{
|
|
||||||
_busy = true;
|
|
||||||
_error = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await JS.InvokeVoidAsync("passkeyEnroll");
|
|
||||||
Nav.NavigateTo("/", true);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_error = ex.Message;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_busy = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private record StatusResponse(bool Enrolled, bool Authenticated);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
.login-container {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
min-height: 100vh;
|
|
||||||
background: var(--bs-body-bg, #f8f9fa);
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-card {
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 12px;
|
|
||||||
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
|
|
||||||
padding: 2.5rem 2rem;
|
|
||||||
width: 100%;
|
|
||||||
max-width: 380px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-title {
|
|
||||||
font-size: 1.75rem;
|
|
||||||
font-weight: 700;
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-hint {
|
|
||||||
color: #6c757d;
|
|
||||||
margin-bottom: 1.25rem;
|
|
||||||
font-size: 0.95rem;
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
@inject NavigationManager Nav
|
|
||||||
|
|
||||||
@code {
|
|
||||||
|
|
||||||
protected override void OnInitialized()
|
|
||||||
{
|
|
||||||
Nav.NavigateTo("/login", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<Router AppAssembly="@typeof(Program).Assembly"
|
|
||||||
AdditionalAssemblies="new[] { typeof(Home).Assembly, typeof(Syndicates).Assembly, typeof(Agents).Assembly }">
|
|
||||||
<Found Context="routeData">
|
|
||||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
|
|
||||||
<NotAuthorized>
|
|
||||||
<RedirectToLogin/>
|
|
||||||
</NotAuthorized>
|
|
||||||
</AuthorizeRouteView>
|
|
||||||
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
|
|
||||||
</Found>
|
|
||||||
</Router>
|
|
||||||
@@ -1,220 +0,0 @@
|
|||||||
using System.Security.Claims;
|
|
||||||
using Cloud.Models;
|
|
||||||
using Fido2NetLib;
|
|
||||||
using Fido2NetLib.Objects;
|
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Cloud.Controllers;
|
|
||||||
|
|
||||||
[AllowAnonymous]
|
|
||||||
[ApiController]
|
|
||||||
[Route("api/auth")]
|
|
||||||
public class AuthController : ControllerBase
|
|
||||||
{
|
|
||||||
private const string RegOptionsKey = "fido2.reg.options";
|
|
||||||
private const string AssertOptionsKey = "fido2.assert.options";
|
|
||||||
private readonly AppDbContext _db;
|
|
||||||
|
|
||||||
private readonly IFido2 _fido2;
|
|
||||||
|
|
||||||
public AuthController(IFido2 fido2, AppDbContext db)
|
|
||||||
{
|
|
||||||
_fido2 = fido2;
|
|
||||||
_db = db;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Registration ──────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
[HttpPost("register/options")]
|
|
||||||
public async Task<IActionResult> RegisterOptions()
|
|
||||||
{
|
|
||||||
// Only allow registration when unenrolled or already authenticated
|
|
||||||
var hasCredentials = await _db.PasskeyCredentials.AnyAsync();
|
|
||||||
if (hasCredentials && !User.Identity!.IsAuthenticated)
|
|
||||||
return Forbid();
|
|
||||||
|
|
||||||
var user = new Fido2User
|
|
||||||
{
|
|
||||||
Id = Guid.NewGuid().ToByteArray(),
|
|
||||||
Name = "owner",
|
|
||||||
DisplayName = "Owner"
|
|
||||||
};
|
|
||||||
|
|
||||||
var existingKeys = await _db.PasskeyCredentials
|
|
||||||
.Select(c => new PublicKeyCredentialDescriptor(c.CredentialId))
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
var options = _fido2.RequestNewCredential(new RequestNewCredentialParams
|
|
||||||
{
|
|
||||||
User = user,
|
|
||||||
ExcludeCredentials = existingKeys,
|
|
||||||
AuthenticatorSelection = new AuthenticatorSelection
|
|
||||||
{
|
|
||||||
ResidentKey = ResidentKeyRequirement.Required,
|
|
||||||
UserVerification = UserVerificationRequirement.Required
|
|
||||||
},
|
|
||||||
AttestationPreference = AttestationConveyancePreference.None
|
|
||||||
});
|
|
||||||
|
|
||||||
HttpContext.Session.SetString(RegOptionsKey, options.ToJson());
|
|
||||||
return Ok(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("register/complete")]
|
|
||||||
public async Task<IActionResult> RegisterComplete(
|
|
||||||
[FromBody] AuthenticatorAttestationRawResponse attestationResponse)
|
|
||||||
{
|
|
||||||
var json = HttpContext.Session.GetString(RegOptionsKey);
|
|
||||||
if (json is null) return BadRequest("Session expired. Please retry enrollment.");
|
|
||||||
|
|
||||||
var options = CredentialCreateOptions.FromJson(json);
|
|
||||||
HttpContext.Session.Remove(RegOptionsKey);
|
|
||||||
|
|
||||||
var hasCredentials = await _db.PasskeyCredentials.AnyAsync();
|
|
||||||
if (hasCredentials && !User.Identity!.IsAuthenticated)
|
|
||||||
return Forbid();
|
|
||||||
|
|
||||||
IsCredentialIdUniqueToUserAsyncDelegate isUnique = async (args, _) =>
|
|
||||||
!await _db.PasskeyCredentials.AnyAsync(c => c.CredentialId == args.CredentialId);
|
|
||||||
|
|
||||||
var result = await _fido2.MakeNewCredentialAsync(new MakeNewCredentialParams
|
|
||||||
{
|
|
||||||
AttestationResponse = attestationResponse,
|
|
||||||
OriginalOptions = options,
|
|
||||||
IsCredentialIdUniqueToUserCallback = isUnique
|
|
||||||
});
|
|
||||||
|
|
||||||
var credential = new PasskeyCredential
|
|
||||||
{
|
|
||||||
CredentialId = result.Id,
|
|
||||||
PublicKey = result.PublicKey,
|
|
||||||
SignCount = result.SignCount,
|
|
||||||
UserHandle = result.User.Id,
|
|
||||||
AaGuid = result.AaGuid.ToString()
|
|
||||||
};
|
|
||||||
_db.PasskeyCredentials.Add(credential);
|
|
||||||
await _db.SaveChangesAsync();
|
|
||||||
|
|
||||||
var claims = new[] { new Claim(ClaimTypes.Name, "owner") };
|
|
||||||
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
|
|
||||||
await HttpContext.SignInAsync(
|
|
||||||
CookieAuthenticationDefaults.AuthenticationScheme,
|
|
||||||
new ClaimsPrincipal(identity),
|
|
||||||
new AuthenticationProperties { IsPersistent = true });
|
|
||||||
|
|
||||||
return Ok(new { message = "Passkey enrolled and authenticated." });
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Authentication ────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
[HttpPost("login/options")]
|
|
||||||
public async Task<IActionResult> LoginOptions()
|
|
||||||
{
|
|
||||||
var existingKeys = await _db.PasskeyCredentials
|
|
||||||
.Select(c => new PublicKeyCredentialDescriptor(c.CredentialId))
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
var options = _fido2.GetAssertionOptions(new GetAssertionOptionsParams
|
|
||||||
{
|
|
||||||
AllowedCredentials = existingKeys,
|
|
||||||
UserVerification = UserVerificationRequirement.Required
|
|
||||||
});
|
|
||||||
|
|
||||||
HttpContext.Session.SetString(AssertOptionsKey, options.ToJson());
|
|
||||||
return Ok(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("login/complete")]
|
|
||||||
public async Task<IActionResult> LoginComplete([FromBody] AuthenticatorAssertionRawResponse assertionResponse)
|
|
||||||
{
|
|
||||||
var json = HttpContext.Session.GetString(AssertOptionsKey);
|
|
||||||
if (json is null) return BadRequest("Session expired. Please retry sign-in.");
|
|
||||||
|
|
||||||
var options = AssertionOptions.FromJson(json);
|
|
||||||
HttpContext.Session.Remove(AssertOptionsKey);
|
|
||||||
|
|
||||||
// assertionResponse.RawId contains the credential ID as raw bytes
|
|
||||||
var credentialId = assertionResponse.RawId;
|
|
||||||
var allCredentials = await _db.PasskeyCredentials.ToListAsync();
|
|
||||||
var stored = allCredentials.FirstOrDefault(c => c.CredentialId.SequenceEqual(credentialId));
|
|
||||||
|
|
||||||
if (stored is null) return Unauthorized("Credential not recognized.");
|
|
||||||
|
|
||||||
IsUserHandleOwnerOfCredentialIdAsync isOwner = (args, _) =>
|
|
||||||
Task.FromResult(args.UserHandle.SequenceEqual(stored.UserHandle));
|
|
||||||
|
|
||||||
var result = await _fido2.MakeAssertionAsync(new MakeAssertionParams
|
|
||||||
{
|
|
||||||
AssertionResponse = assertionResponse,
|
|
||||||
OriginalOptions = options,
|
|
||||||
StoredPublicKey = stored.PublicKey,
|
|
||||||
StoredSignatureCounter = (uint)stored.SignCount,
|
|
||||||
IsUserHandleOwnerOfCredentialIdCallback = isOwner
|
|
||||||
});
|
|
||||||
|
|
||||||
stored.SignCount = result.SignCount;
|
|
||||||
await _db.SaveChangesAsync();
|
|
||||||
|
|
||||||
var claims = new[] { new Claim(ClaimTypes.Name, "owner") };
|
|
||||||
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
|
|
||||||
await HttpContext.SignInAsync(
|
|
||||||
CookieAuthenticationDefaults.AuthenticationScheme,
|
|
||||||
new ClaimsPrincipal(identity),
|
|
||||||
new AuthenticationProperties { IsPersistent = true });
|
|
||||||
|
|
||||||
return Ok(new { message = "Authenticated." });
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Logout ────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
[HttpPost("logout")]
|
|
||||||
public async Task<IActionResult> Logout()
|
|
||||||
{
|
|
||||||
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Status ────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
[HttpGet("status")]
|
|
||||||
public async Task<IActionResult> Status()
|
|
||||||
{
|
|
||||||
var hasCredentials = await _db.PasskeyCredentials.AnyAsync();
|
|
||||||
return Ok(new
|
|
||||||
{
|
|
||||||
enrolled = hasCredentials,
|
|
||||||
authenticated = User.Identity?.IsAuthenticated ?? false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Dev-only test helpers (Development environment only) ──────────────────
|
|
||||||
|
|
||||||
[HttpPost("dev-login")]
|
|
||||||
public async Task<IActionResult> DevLogin([FromServices] IWebHostEnvironment env)
|
|
||||||
{
|
|
||||||
if (!env.IsDevelopment()) return NotFound();
|
|
||||||
|
|
||||||
var claims = new[] { new Claim(ClaimTypes.Name, "owner") };
|
|
||||||
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
|
|
||||||
await HttpContext.SignInAsync(
|
|
||||||
CookieAuthenticationDefaults.AuthenticationScheme,
|
|
||||||
new ClaimsPrincipal(identity),
|
|
||||||
new AuthenticationProperties { IsPersistent = false });
|
|
||||||
|
|
||||||
return Ok(new { message = "Dev login successful." });
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpDelete("credentials")]
|
|
||||||
public async Task<IActionResult> DeleteAllCredentials([FromServices] IWebHostEnvironment env)
|
|
||||||
{
|
|
||||||
if (!env.IsDevelopment()) return NotFound();
|
|
||||||
|
|
||||||
_db.PasskeyCredentials.RemoveRange(_db.PasskeyCredentials);
|
|
||||||
await _db.SaveChangesAsync();
|
|
||||||
return Ok(new { message = "All credentials deleted." });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using Cloud;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Cloud.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(AppDbContext))]
|
|
||||||
[Migration("20260703120000_AddPasskeyCredentials")]
|
|
||||||
partial class AddPasskeyCredentials
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "10.0.9")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("Chrono.Model.CardNote", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("CardName")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Note")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("CardName");
|
|
||||||
|
|
||||||
b.ToTable("CardNotes");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Cloud.Models.PasskeyCredential", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("AaGuid")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<byte[]>("CredentialId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("bytea");
|
|
||||||
|
|
||||||
b.Property<byte[]>("PublicKey")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("bytea");
|
|
||||||
|
|
||||||
b.Property<long>("SignCount")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<byte[]>("UserHandle")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("bytea");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("PasskeyCredentials");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Cloud.Models.UserDeck", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.PrimitiveCollection<string>("Cards")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.PrimitiveCollection<string>("Divers")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Notes")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Season")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime>("UpdatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("UserDecks");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Cloud.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class AddPasskeyCredentials : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "PasskeyCredentials",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
CredentialId = table.Column<byte[]>(type: "bytea", nullable: false),
|
|
||||||
PublicKey = table.Column<byte[]>(type: "bytea", nullable: false),
|
|
||||||
SignCount = table.Column<long>(type: "bigint", nullable: false),
|
|
||||||
UserHandle = table.Column<byte[]>(type: "bytea", nullable: false),
|
|
||||||
AaGuid = table.Column<string>(type: "text", nullable: false),
|
|
||||||
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_PasskeyCredentials", x => x.Id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "PasskeyCredentials");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
namespace Cloud.Models;
|
|
||||||
|
|
||||||
public class PasskeyCredential
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public required byte[] CredentialId { get; set; }
|
|
||||||
public required byte[] PublicKey { get; set; }
|
|
||||||
public long SignCount { get; set; }
|
|
||||||
public required byte[] UserHandle { get; set; }
|
|
||||||
public string AaGuid { get; set; } = string.Empty;
|
|
||||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*",
|
|
||||||
"Fido2": {
|
|
||||||
"ServerDomain": "localhost",
|
|
||||||
"ServerName": "Chrono CCG",
|
|
||||||
"Origins": [
|
|
||||||
"https://localhost:7001",
|
|
||||||
"http://localhost:5000"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 434 KiB |
|
Before Width: | Height: | Size: 560 KiB |
|
Before Width: | Height: | Size: 656 KiB |
|
Before Width: | Height: | Size: 568 KiB |
|
Before Width: | Height: | Size: 243 KiB |
|
Before Width: | Height: | Size: 808 KiB |
|
Before Width: | Height: | Size: 386 KiB |
|
Before Width: | Height: | Size: 573 KiB |
|
Before Width: | Height: | Size: 532 KiB |
|
Before Width: | Height: | Size: 514 KiB |
|
Before Width: | Height: | Size: 843 KiB |
|
Before Width: | Height: | Size: 12 MiB |
|
Before Width: | Height: | Size: 603 KiB |
|
Before Width: | Height: | Size: 571 KiB |
|
Before Width: | Height: | Size: 380 KiB |
|
Before Width: | Height: | Size: 360 KiB |
|
Before Width: | Height: | Size: 449 KiB |
|
Before Width: | Height: | Size: 275 KiB |
|
Before Width: | Height: | Size: 621 KiB |
|
Before Width: | Height: | Size: 398 KiB |
|
Before Width: | Height: | Size: 397 KiB |
|
Before Width: | Height: | Size: 548 KiB |
|
Before Width: | Height: | Size: 582 KiB |
|
Before Width: | Height: | Size: 425 KiB |
|
Before Width: | Height: | Size: 524 KiB |
|
Before Width: | Height: | Size: 584 KiB |
|
Before Width: | Height: | Size: 691 KiB |
|
Before Width: | Height: | Size: 446 KiB |
|
Before Width: | Height: | Size: 570 KiB |
|
Before Width: | Height: | Size: 493 KiB |
|
Before Width: | Height: | Size: 531 KiB |
|
Before Width: | Height: | Size: 515 KiB |
|
Before Width: | Height: | Size: 410 KiB |
|
Before Width: | Height: | Size: 583 KiB |
|
Before Width: | Height: | Size: 432 KiB |
|
Before Width: | Height: | Size: 551 KiB |
|
Before Width: | Height: | Size: 536 KiB |
|
Before Width: | Height: | Size: 418 KiB |
|
Before Width: | Height: | Size: 512 KiB |
|
Before Width: | Height: | Size: 611 KiB |
|
Before Width: | Height: | Size: 577 KiB |
|
Before Width: | Height: | Size: 466 KiB |
|
Before Width: | Height: | Size: 586 KiB |
|
Before Width: | Height: | Size: 630 KiB |
|
Before Width: | Height: | Size: 515 KiB |
|
Before Width: | Height: | Size: 517 KiB |
|
Before Width: | Height: | Size: 511 KiB |
|
Before Width: | Height: | Size: 588 KiB |
|
Before Width: | Height: | Size: 564 KiB |
|
Before Width: | Height: | Size: 706 KiB |
|
Before Width: | Height: | Size: 571 KiB |
|
Before Width: | Height: | Size: 549 KiB |
|
Before Width: | Height: | Size: 562 KiB |
|
Before Width: | Height: | Size: 509 KiB |
|
Before Width: | Height: | Size: 551 KiB |
|
Before Width: | Height: | Size: 544 KiB |
|
Before Width: | Height: | Size: 654 KiB |
|
Before Width: | Height: | Size: 689 KiB |
|
Before Width: | Height: | Size: 567 KiB |
|
Before Width: | Height: | Size: 428 KiB |
|
Before Width: | Height: | Size: 477 KiB |
|
Before Width: | Height: | Size: 480 KiB |
|
Before Width: | Height: | Size: 484 KiB |
|
Before Width: | Height: | Size: 542 KiB |
|
Before Width: | Height: | Size: 443 KiB |
|
Before Width: | Height: | Size: 398 KiB |
|
Before Width: | Height: | Size: 479 KiB |
|
Before Width: | Height: | Size: 799 KiB |
|
Before Width: | Height: | Size: 376 KiB |
|
Before Width: | Height: | Size: 538 KiB |
|
Before Width: | Height: | Size: 797 KiB |
|
Before Width: | Height: | Size: 415 KiB |
|
Before Width: | Height: | Size: 525 KiB |
|
Before Width: | Height: | Size: 493 KiB |
|
Before Width: | Height: | Size: 466 KiB |
|
Before Width: | Height: | Size: 649 KiB |
|
Before Width: | Height: | Size: 401 KiB |
|
Before Width: | Height: | Size: 446 KiB |
|
Before Width: | Height: | Size: 592 KiB |
|
Before Width: | Height: | Size: 450 KiB |
|
Before Width: | Height: | Size: 404 KiB |
|
Before Width: | Height: | Size: 856 KiB |
|
Before Width: | Height: | Size: 623 KiB |
|
Before Width: | Height: | Size: 444 KiB |
|
Before Width: | Height: | Size: 557 KiB |
|
Before Width: | Height: | Size: 414 KiB |