WIP separation Web et API

This commit is contained in:
Paul Schneider
2025-02-12 20:41:14 +00:00
parent 6cd5f1d041
commit c2ae054719
55 changed files with 71 additions and 98 deletions

View File

@ -44,7 +44,7 @@ internal class Program
.AllowAnyMethod();
});
})
.AddControllers();
.AddControllersWithViews();
// accepts any access token issued by identity server
var authenticationBuilder = services.AddAuthentication()
@ -64,14 +64,22 @@ internal class Program
app
.UseRouting()
.UseAuthentication()
.UseAuthorization()
.UseCors("default");
.UseAuthorization().UseCors("default")
.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute()
.RequireAuthorization();
});
app.MapGet("/identity", (HttpContext context) =>
new JsonResult(context?.User?.Claims.Select(c => new { c.Type, c.Value }))
).RequireAuthorization("ApiScope");
await app.RunAsync();
}
};
}
}