fix: change cookie name
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

This commit is contained in:
Polianin Nikita 2024-10-31 04:23:43 +03:00
parent a0ff624481
commit eb272baa38

View File

@ -1,15 +1,15 @@
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 const string JwtAuthorizationName = "_ajwt";
public async Task InvokeAsync(HttpContext context)
{
if (context.Request.Cookies.ContainsKey(JwtAuthorizationName))
context.Request.Headers.Authorization = "Bearer " + context.Request.Cookies[JwtAuthorizationName];
if (context.Request.Cookies.ContainsKey(CookieNames.AccessToken))
context.Request.Headers.Authorization = "Bearer " + context.Request.Cookies[CookieNames.AccessToken];
await next(context);
}