2024-10-09 03:00:26 +03:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2024-10-31 04:23:43 +03:00
|
|
|
|
using Mirea.Api.Security.Common;
|
2024-10-09 03:00:26 +03:00
|
|
|
|
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-09 03:00:26 +03:00
|
|
|
|
{
|
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];
|
2024-10-09 03:00:26 +03:00
|
|
|
|
|
|
|
|
|
await next(context);
|
|
|
|
|
}
|
|
|
|
|
}
|