1.
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(options =>
{
options.Authority = "https://localhost:44354";
options.ApiName = "app.api.weather";
});
services.AddControllers();
}
To use IdentityServerAuthenticaltionDefaults, you need to install nuget package Microsoft.AspNet.Identity.Core
2.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//..removed for brevity
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
//..removed for brevity
}
3.
[ApiController]
[Authorize]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
//...removed for brevity
}
No comments:
Post a Comment