wip: oauth
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user