Replace SOR.Admin email/password login with Keycloak OIDC

Admin panel now delegates authentication entirely to Keycloak using the
Authorization Code flow. The local Identity password form and
IdentityRevalidatingAuthenticationStateProvider are removed. Access requires
the "admin" Keycloak realm role, mirroring the game's role-based auth model.

- Program.cs: AddOpenIdConnect("Keycloak") with cookie session; /auth/challenge
  triggers the OIDC flow; /auth/logout signs out of both cookie and Keycloak SSO
- Login.razor: replaced HTML form with an immediate redirect to /auth/challenge
- IdentityRevalidatingAuthenticationStateProvider.cs: deleted (no longer needed)
- appsettings.json: Keycloak:Authority / ClientId / ClientSecret section added
- Directory.Packages.props: pinned Microsoft.AspNetCore.Authentication.OpenIdConnect 8.0.0
- SOR.Admin.csproj: added OpenIdConnect package reference

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-04 08:46:27 -04:00
co-authored by Claude Happy
parent cfb10ae4d0
commit fa695649f6
6 changed files with 116 additions and 165 deletions
@@ -1,45 +1,14 @@
@page "/login"
@attribute [AllowAnonymous]
@* Static SSR — no rendermode, keeps login available without a SignalR connection. *@
@inject NavigationManager Nav
<PageTitle>Sign In – SOR Admin</PageTitle>
<div class="min-vh-100 d-flex align-items-center justify-content-center bg-dark">
<div class="card shadow" style="width: 380px;">
<div class="card-body p-4">
<h1 class="h4 mb-1 fw-bold">
<i class="bi bi-lightning-charge-fill text-warning me-2"></i>SOR Admin
</h1>
<p class="text-muted small mb-4">Sign in to continue</p>
@if (Error == "invalid")
{
<div class="alert alert-danger py-2">Invalid email or password.</div>
}
else if (Error == "locked")
{
<div class="alert alert-warning py-2">Account locked — try again later.</div>
}
<form method="post" action="/auth/login">
<input type="hidden" name="returnUrl" value="@ReturnUrl" />
<div class="mb-3">
<label class="form-label">Email</label>
<input name="email" type="email" class="form-control"
placeholder="admin@example.com" required autofocus />
</div>
<div class="mb-4">
<label class="form-label">Password</label>
<input name="password" type="password" class="form-control" required />
</div>
<button type="submit" class="btn btn-primary w-100">Sign In</button>
</form>
</div>
</div>
</div>
@* Static SSR — no rendermode, stays available without a SignalR connection. *@
@code {
[SupplyParameterFromQuery] public string? ReturnUrl { get; set; }
[SupplyParameterFromQuery] public string? Error { get; set; }
protected override void OnInitialized() =>
Nav.NavigateTo(
$"/auth/challenge?returnUrl={Uri.EscapeDataString(ReturnUrl ?? "/")}",
forceLoad: true);
}