AspNetCore.Docs.Samples/security/authorization/AuthRequirementsData/Program.cs

15 lines
407 B
C#
Raw Normal View History

2023-05-27 11:05:48 +08:00
using AuthRequirementsData.Authorization;
using Microsoft.AspNetCore.Authorization;
var builder = WebApplication.CreateBuilder();
builder.Services.AddAuthentication().AddJwtBearer();
builder.Services.AddAuthorization();
builder.Services.AddControllers();
builder.Services.AddSingleton<IAuthorizationHandler, MinimumAgeAuthorizationHandler>();
var app = builder.Build();
app.MapControllers();
app.Run();