AuthorizationPolicyBuilder constructs ASP.NET Core authorization policies from requirements. Configure it inside AddPolicy in Program.cs, then apply the named policy with [Authorize]. section 24.3
Require a boarding-pass claim
builder.Services.AddAuthorizationBuilder() .AddPolicy("CanEnterSecurity", policyBuilder => policyBuilder.RequireClaim("BoardingPassNumber")); [Authorize("CanEnterSecurity")] public class AirportSecurityModel : PageModel { } The policy succeeds when the user has the BoardingPassNumber claim. RequireClaim can also require a specific value, such as "A1234". section 24.3
Use simple methods for direct claims or identity checks. For rules such as “at least 18, and either Gold frequent-flyer status or an employee number, but never banned,” add lightweight IAuthorizationRequirement objects and let authorization handlers evaluate them. Handlers can succeed, do nothing, or explicitly fail with context.Fail(). section 24.4 section 24.4.2
