WIP separation Web et API
This commit is contained in:
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user