feature: RBAC + Clinical Audit Logging

This commit is contained in:
voltsrage
2026-06-21 15:46:55 +08:00
parent a43db52813
commit 5af6ab490e
83 changed files with 4281 additions and 70 deletions
@@ -0,0 +1,29 @@
using System.Security.Claims;
public class CurrentUserService : ICurrentUserService
{
private readonly IHttpContextAccessor _http;
public CurrentUserService(IHttpContextAccessor http) => _http = http;
public Guid? UserId =>
Guid.TryParse(_http.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier), out var id)
? id : null;
public string? Username => _http.HttpContext?.User.FindFirstValue(ClaimTypes.Name);
public string? DisplayName => _http.HttpContext?.User.FindFirstValue("display_name");
public ClinicalRole? Role
{
get
{
var role = _http.HttpContext?.User.FindFirstValue("clinical_role");
return role is null ? null : ClinicalRoleExtensions.FromDbString(role);
}
}
public bool IsAuthenticated => _http.HttpContext?.User.Identity?.IsAuthenticated == true;
public string? IpAddress => _http.HttpContext?.Connection.RemoteIpAddress?.ToString();
}