Add cookie/JWT-based authentication and user context headers
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.
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
using DbFirst.Application.Abstractions;
|
||||
|
||||
namespace DbFirst.API.Services
|
||||
namespace DbFirst.API.Services;
|
||||
|
||||
public class CurrentUserService(IHttpContextAccessor httpContextAccessor) : ICurrentUserService
|
||||
{
|
||||
public class CurrentUserService(IHttpContextAccessor httpContextAccessor) : ICurrentUserService
|
||||
{
|
||||
public string UserName =>
|
||||
httpContextAccessor.HttpContext?.User.Identity?.Name ?? "unknown";
|
||||
}
|
||||
public string UserName =>
|
||||
httpContextAccessor.HttpContext?.User.Identity?.Name ?? "unknown";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user