2024-10-09 03:00:26 +03:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Mirea.Api.Endpoint.Configuration.Core.Middleware;
|
|
|
|
|
|
|
|
|
|
public class CookieAuthorizationMiddleware(RequestDelegate next)
|
|
|
|
|
{
|
|
|
|
|
public const string JwtAuthorizationName = "_ajwt";
|
2024-10-09 03:02:35 +03:00
|
|
|
|
public async Task InvokeAsync(HttpContext context)
|
2024-10-09 03:00:26 +03:00
|
|
|
|
{
|
|
|
|
|
if (context.Request.Cookies.ContainsKey(JwtAuthorizationName))
|
|
|
|
|
context.Request.Headers.Authorization = "Bearer " + context.Request.Cookies[JwtAuthorizationName];
|
|
|
|
|
|
|
|
|
|
await next(context);
|
|
|
|
|
}
|
|
|
|
|
}
|