debug: detailed logging for auth state and /api/auth/me response
WBS-9.3 - NULL Policy CI Gate / NULL Policy Validation (push) Failing after 9s
Quant Engine CI/CD Pipeline / validate-core (push) Failing after 17s
Quant Engine CI/CD Pipeline / validate-ui-and-storage (push) Has been skipped
Deploy to Production / Build & Deploy to Production (push) Failing after 2m52s
WBS-9.3 - NULL Policy CI Gate / NULL Policy Validation (push) Failing after 9s
Quant Engine CI/CD Pipeline / validate-core (push) Failing after 17s
Quant Engine CI/CD Pipeline / validate-ui-and-storage (push) Has been skipped
Deploy to Production / Build & Deploy to Production (push) Failing after 2m52s
Changes: - Dashboard.razor: Disable auth check temporarily for testing (VERIFY dashboard loads) - CustomAuthenticationStateProvider: Add detailed JSON logging * Log /api/auth/me URL * Log response status and JSON content * Log parsed values (authenticated, username, role) * Better exception tracking Result: Dashboard now loads when auth check disabled This confirms: Problem is in CustomAuthenticationStateProvider parsing/validation Next step: - Check console logs to see where /api/auth/me fails - Fix JSON parsing or response handling Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
+13
-1
@@ -36,19 +36,26 @@ namespace QuantEngine.Web.Client.Infrastructure
|
||||
Console.WriteLine("[Auth] Attempting validation via /api/auth/me (cookie or Bearer)...");
|
||||
var baseUrl = _http.BaseAddress?.AbsoluteUri ?? "http://localhost:5265";
|
||||
var meUrl = new Uri(new Uri(baseUrl), "api/auth/me").ToString();
|
||||
Console.WriteLine($"[Auth] /api/auth/me URL: {meUrl}");
|
||||
|
||||
var meResponse = await _http.GetAsync(meUrl);
|
||||
Console.WriteLine($"[Auth] /api/auth/me status: {meResponse.StatusCode}");
|
||||
|
||||
if (meResponse.IsSuccessStatusCode)
|
||||
{
|
||||
var json = await meResponse.Content.ReadAsStringAsync();
|
||||
Console.WriteLine($"[Auth] Response JSON: {json}");
|
||||
|
||||
var meData = System.Text.Json.JsonDocument.Parse(json).RootElement;
|
||||
var authenticated = meData.TryGetProperty("authenticated", out var authProp) && authProp.GetBoolean();
|
||||
var username = meData.TryGetProperty("username", out var userProp) ? userProp.GetString() : null;
|
||||
var role = meData.TryGetProperty("role", out var roleProp) ? roleProp.GetString() : "Admin";
|
||||
|
||||
Console.WriteLine($"[Auth] Parsed: authenticated={authenticated}, username={username}, role={role}");
|
||||
|
||||
if (authenticated && !string.IsNullOrWhiteSpace(username))
|
||||
{
|
||||
Console.WriteLine($"[Auth] ✅ Authenticated via /api/auth/me: {username}");
|
||||
Console.WriteLine($"[Auth] ✅ SUCCESS: Authenticated as {username}");
|
||||
var identity = new ClaimsIdentity(new[]
|
||||
{
|
||||
new Claim(ClaimTypes.Name, username),
|
||||
@@ -57,6 +64,10 @@ namespace QuantEngine.Web.Client.Infrastructure
|
||||
|
||||
return new AuthenticationState(new ClaimsPrincipal(identity));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"[Auth] Parsing failed: authenticated={authenticated}, username={username}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -66,6 +77,7 @@ namespace QuantEngine.Web.Client.Infrastructure
|
||||
catch (Exception meEx)
|
||||
{
|
||||
Console.WriteLine($"[Auth] /api/auth/me failed: {meEx.Message}");
|
||||
Console.WriteLine($"[Auth] Exception: {meEx}");
|
||||
}
|
||||
|
||||
// Fallback: Try to read from localStorage
|
||||
|
||||
Reference in New Issue
Block a user