MireaBackend/Endpoint/Configuration/Core/Middleware/CookieAuthorizationMiddleware.cs

16 lines
531 B
C#
Raw Normal View History

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)
{
if (context.Request.Cookies.ContainsKey(JwtAuthorizationName))
context.Request.Headers.Authorization = "Bearer " + context.Request.Cookies[JwtAuthorizationName];
await next(context);
}
}