4879c4e01e
Bootstrap served locally with absolute paths and <base href="/">. LDAP auth uses search-then-bind with service account for GLAuth compatibility. CookieAuthenticationStateProvider reads HttpContext.User instead of parsing JWT. Login/logout forms opt out of Blazor enhanced nav (data-enhance="false"). Nav links use absolute paths; seed data includes Design/Deployment group mappings. DataConnections page loads all connections (not just site-assigned). Site appsettings configured for Test Plant A; Site registers with Central on startup. DeploymentService resolves string site identifier for Akka routing. Instances page gains Create Instance form.
30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
using System.Security.Claims;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Components.Server;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace ScadaLink.CentralUI.Auth;
|
|
|
|
/// <summary>
|
|
/// Bridges ASP.NET Core cookie authentication with Blazor Server's auth state.
|
|
/// The cookie middleware has already validated and decrypted the cookie by the time
|
|
/// the Blazor circuit is established, so we just read HttpContext.User.
|
|
/// </summary>
|
|
public class CookieAuthenticationStateProvider : ServerAuthenticationStateProvider
|
|
{
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
public CookieAuthenticationStateProvider(IHttpContextAccessor httpContextAccessor)
|
|
{
|
|
_httpContextAccessor = httpContextAccessor;
|
|
}
|
|
|
|
public override Task<AuthenticationState> GetAuthenticationStateAsync()
|
|
{
|
|
var user = _httpContextAccessor.HttpContext?.User
|
|
?? new ClaimsPrincipal(new ClaimsIdentity());
|
|
|
|
return Task.FromResult(new AuthenticationState(user));
|
|
}
|
|
}
|