MireaBackend/Endpoint/Configuration/Core/Middleware/CookieAuthorizationMiddleware.cs
Polianin Nikita eb272baa38
All checks were successful
Build and Deploy Docker Container / build-and-deploy (push) Successful in 2m12s
.NET Test Pipeline / build-and-test (push) Successful in 2m44s
fix: change cookie name
2024-10-31 04:23:43 +03:00

16 lines
514 B
C#

using Microsoft.AspNetCore.Http;
using Mirea.Api.Security.Common;
using System.Threading.Tasks;
namespace Mirea.Api.Endpoint.Configuration.Core.Middleware;
public class CookieAuthorizationMiddleware(RequestDelegate next)
{
public async Task InvokeAsync(HttpContext context)
{
if (context.Request.Cookies.ContainsKey(CookieNames.AccessToken))
context.Request.Headers.Authorization = "Bearer " + context.Request.Cookies[CookieNames.AccessToken];
await next(context);
}
}