22 lines
No EOL
659 B
C#
22 lines
No EOL
659 B
C#
using Femto.Api.Auth;
|
|
using Femto.Modules.Auth.Application.Dto;
|
|
|
|
namespace Femto.Api.Sessions;
|
|
|
|
internal static class HttpContextSessionExtensions
|
|
{
|
|
public static void SetSession(this HttpContext httpContext, Session session, CookieSettings cookieSettings)
|
|
{
|
|
httpContext.Response.Cookies.Append(
|
|
"session",
|
|
session.SessionId,
|
|
new CookieOptions
|
|
{
|
|
HttpOnly = true,
|
|
Secure = cookieSettings.Secure,
|
|
SameSite = cookieSettings.SameSite? SameSiteMode.Strict : SameSiteMode.None,
|
|
Expires = session.Expires,
|
|
}
|
|
);
|
|
}
|
|
} |