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

16 lines
408 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();
2023-05-31 07:27:13 +08:00
builder.Services.AddControllers();
2023-06-02 10:49:22 +08:00
builder.Services.AddSingleton<IAuthorizationHandler, MinimumAgeAuthorizationHandler>();
2023-05-27 11:05:48 +08:00
var app = builder.Build();
app.MapControllers();
2023-05-31 07:27:13 +08:00
app.Run();