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

16 lines
514 B
C#
Raw Normal View History

using Microsoft.AspNetCore.Http;
2024-10-31 04:23:43 +03:00
using Mirea.Api.Security.Common;
using System.Threading.Tasks;
namespace Mirea.Api.Endpoint.Configuration.Core.Middleware;
public class CookieAuthorizationMiddleware(RequestDelegate next)
{
2024-10-09 03:02:35 +03:00
public async Task InvokeAsync(HttpContext context)
{
2024-10-31 04:23:43 +03:00
if (context.Request.Cookies.ContainsKey(CookieNames.AccessToken))
context.Request.Headers.Authorization = "Bearer " + context.Request.Cookies[CookieNames.AccessToken];
await next(context);
}
}