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)
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5209",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
@@ -22,8 +20,6 @@
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7089;http://localhost:5209",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
|
||||
Reference in New Issue
Block a user