wip: oauth

This commit is contained in:
2024-10-13 22:12:43 +07:00
parent e9f32fc32e
commit b7150c7c43
14 changed files with 234 additions and 65 deletions

View File

@@ -12,9 +12,10 @@ builder.Services.AddSwaggerGen();
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
{
options.LoginPath = "/login";
//options.Events
//options.LoginPath = "/login";
});
// builder.Services.AddAuthorization();
builder.Services.AddAuthorization();
var app = builder.Build();
@@ -27,8 +28,9 @@ if (app.Environment.IsDevelopment())
app.UseHttpsRedirection();
app.UseAuthentication();
// app.UseAuthorization();
app.MapGet("/secured-method", /*[Authorize]*/ (HttpContext ctx) =>
app.UseAuthorization();
app.MapGet("/secured-method", [Authorize] (HttpContext ctx) =>
{
var user = ctx.User?.FindFirst("Name");
if (user == null)