using Emberend.Database; using Emberend.Endpoints; using Microsoft.EntityFrameworkCore; using System; using System.Net; var builder = WebApplication.CreateBuilder(args); builder.WebHost.ConfigureKestrel(options => { options.AddServerHeader = false; options.Listen(IPAddress.Any, 8085); //options.Listen(IPAddress.Any, 4431, listenOptions => //{ // listenOptions.UseHttps("/etc/letsencrypt/live/x/letsencrypt.pfx", ""); //}); }); builder.Services.AddMemoryCache(); builder.Logging.ClearProviders(); builder.Services.AddDbContextPool(opt => { opt.UseMySql( builder.Configuration.GetConnectionString("Default"), ServerVersion.AutoDetect( builder.Configuration.GetConnectionString("Default") ) ); }); builder.Services.AddAuthentication("auth") .AddCookie("auth", o => { o.Cookie.Name = "auth"; o.Cookie.HttpOnly = true; o.Cookie.SameSite = SameSiteMode.Strict; o.Events.OnRedirectToLogin = ctx => { ctx.Response.StatusCode = 401; return Task.CompletedTask; }; }); builder.Services.AddAuthorization(); var app = builder.Build(); app.UseAuthentication(); app.UseAuthorization(); app.MapUserAccessEndpoints(); //app.UseHttpsRedirection(); app.MapGet("/", async (HttpContext context) => { await context.Response.WriteAsync("Hello, alex-api.onlystefan.com"); }); app.MapGet("/test", async (HttpContext context) => { await context.Response.WriteAsync("test"); }); app.Run(); public sealed record RegisterDto(string Email, string Password); public sealed record LoginDto(string Email, string Password);