Introduce a new authentication mechanism using JWT tokens stored in cookies, with a custom CookieAuthHandler for API request authentication. Add AuthServiceSettings for configuration and UserHeaderHandler to propagate user context in outgoing HTTP requests. Update service registrations and configuration files to support the new authentication flow. Refactor CurrentUserService for simplicity. This enables stateless, cookie-based authentication and consistent user context across API calls.
10 lines
282 B
C#
10 lines
282 B
C#
using DbFirst.Application.Abstractions;
|
|
|
|
namespace DbFirst.API.Services;
|
|
|
|
public class CurrentUserService(IHttpContextAccessor httpContextAccessor) : ICurrentUserService
|
|
{
|
|
public string UserName =>
|
|
httpContextAccessor.HttpContext?.User.Identity?.Name ?? "unknown";
|
|
}
|