129 instantiations of AuthorizationPolicyBuilder
Aspire.Dashboard (4)
DashboardWebApplication.cs (4)
770policy: new AuthorizationPolicyBuilder(OtlpCompositeAuthenticationDefaults.AuthenticationScheme) 779policy: new AuthorizationPolicyBuilder(FrontendCompositeAuthenticationDefaults.AuthenticationScheme) 786policy: new AuthorizationPolicyBuilder(FrontendCompositeAuthenticationDefaults.AuthenticationScheme) 793policy: new AuthorizationPolicyBuilder(FrontendCompositeAuthenticationDefaults.AuthenticationScheme)
Aspire.Hosting (1)
Dashboard\DashboardServiceHost.cs (1)
99policy: new AuthorizationPolicyBuilder(
CustomPolicyProvider (1)
Authorization\MinimumAgePolicyProvider.cs (1)
44var policy = new AuthorizationPolicyBuilder();
Microsoft.AspNetCore.Authorization (7)
AuthorizationBuilder.cs (2)
113var policyBuilder = new AuthorizationPolicyBuilder(); 140var policyBuilder = new AuthorizationPolicyBuilder();
AuthorizationOptions.cs (2)
32public AuthorizationPolicy DefaultPolicy { get; set; } = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 67var policyBuilder = new AuthorizationPolicyBuilder();
AuthorizationPolicy.cs (3)
81var builder = new AuthorizationPolicyBuilder(); 137policyBuilder = new AuthorizationPolicyBuilder(); 181policyBuilder ??= new();
Microsoft.AspNetCore.Authorization.Policy (2)
AuthorizationEndpointConventionBuilderExtensions.cs (1)
113var policyBuilder = new AuthorizationPolicyBuilder();
AuthorizationMiddleware.cs (1)
125var reqPolicy = new AuthorizationPolicyBuilder();
Microsoft.AspNetCore.Authorization.Test (73)
AuthorizationBuilderTests.cs (4)
16var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 31var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 47var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 78var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
AuthorizationEndpointConventionBuilderExtensionsTests.cs (2)
125var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); 199var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build();
AuthorizationMiddlewareResultHandlerTests.cs (7)
19var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 33var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 47var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 65var policy = new AuthorizationPolicyBuilder() 86var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 104var policy = new AuthorizationPolicyBuilder() 125var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
AuthorizationMiddlewareTests.cs (36)
27var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 46var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 66var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 85var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 106var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 108policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build()); 128var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 150var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 172var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().AddAuthenticationSchemes("schema1", "schema2").Build(); 194var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); 236var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); 278var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); 344return Task.FromResult(new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build()); 356var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); 388var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); 423var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => 430policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); 510policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); 532policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); 547var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewPage").Build(); 566var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 587var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); 608var policy = new AuthorizationPolicyBuilder("Fails").RequireAuthenticatedUser().Build(); 632var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewComment", "CanViewPage").Build(); 652var policy = new AuthorizationPolicyBuilder().RequireAssertion(c => 681var policy = new AuthorizationPolicyBuilder().RequireAssertion(c => 705var policy = new AuthorizationPolicyBuilder().RequireRole("Wut").Build(); 727var policy = new AuthorizationPolicyBuilder().RequireRole("Wut").AddAuthenticationSchemes("Basic", "Bearer").Build(); 748var policy = new AuthorizationPolicyBuilder() 772var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewPage").Build(); 795var policy = new AuthorizationPolicyBuilder().RequireRole("Wut").AddAuthenticationSchemes("NotImplemented").Build(); 818var policy = new AuthorizationPolicyBuilder().RequireRole("Wut").AddAuthenticationSchemes("Basic", "Bearer").Build(); 859var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewPage").Build(); 885var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewPage").Build(); 917var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewPage").AddAuthenticationSchemes("Bearer").Build(); 951var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewPage").Build();
AuthorizationPolicyFacts.cs (3)
14Assert.Throws<InvalidOperationException>(() => new AuthorizationPolicyBuilder().RequireRole()); 55var policies = new[] { new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build() }; 78options.DefaultPolicy = new AuthorizationPolicyBuilder("default").RequireClaim("default").Build();
DefaultAuthorizationServiceTests.cs (13)
348var policy = new AuthorizationPolicyBuilder().RequireRole("Administrator") 371var policy = new AuthorizationPolicyBuilder().RequireClaim(ClaimTypes.Role); 392var policy = new AuthorizationPolicyBuilder("AuthType").RequireClaim(ClaimTypes.Name); 409var policy = new AuthorizationPolicyBuilder("AuthType").RequireRole("Admin"); 426var policy = new AuthorizationPolicyBuilder("AuthType").RequireRole("Admin", "Users"); 442var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewPage"); 725var basePolicy = new AuthorizationPolicyBuilder().RequireClaim("Base", "Value").Build(); 753var basePolicy = new AuthorizationPolicyBuilder().RequireClaim("Base", "Value").Build(); 780var basePolicy = new AuthorizationPolicyBuilder().RequireClaim("Base", "Value").Build(); 999return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); 1009return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); 1038return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); 1048return Task.FromResult(new AuthorizationPolicyBuilder().RequireClaim(policyName).Build());
PolicyEvaluatorTests.cs (8)
21var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); 38var policy = new AuthorizationPolicyBuilder().AddAuthenticationSchemes("A", "B", "C").RequireAssertion(_ => true).Build(); 57var policy = new AuthorizationPolicyBuilder().AddAuthenticationSchemes("A").RequireAssertion(_ => true).Build(); 74var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); 91var policy = new AuthorizationPolicyBuilder().RequireAssertion(c => c.Resource != null).Build(); 109var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => false).Build(); 126var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => false).Build(); 143var policy = new AuthorizationPolicyBuilder()
Microsoft.AspNetCore.Http.Connections.Tests (1)
MapConnectionHandlerTests.cs (1)
37var policy1 = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build();
Microsoft.AspNetCore.Identity.FunctionalTests (1)
Infrastructure\FunctionalTestsServiceCollectionExtensions.cs (1)
47var policy = new AuthorizationPolicyBuilder()
Microsoft.AspNetCore.Mvc.Core (1)
Authorization\AuthorizeFilter.cs (1)
122var builder = new AuthorizationPolicyBuilder(await ComputePolicyAsync());
Microsoft.AspNetCore.Mvc.Core.Test (29)
Authorization\AuthorizeFilterTest.cs (29)
88var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build()); 105policyProvider.Setup(p => p.GetPolicyAsync(It.IsAny<string>())).ReturnsAsync(new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build()) 132var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build()); 146var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewPage").Build()); 160var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); 175var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); 191var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); 205var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder("Fails") 221var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewComment", "CanViewPage").Build()); 234new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); 236new AuthorizationPolicyBuilder().RequireAssertion(_ => false).Build(); 265var secondFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(a => true).Build()); 289var secondFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(a => true).Build()); 315var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(a => false).Build()); 319var secondFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(a => true).Build()); 333var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(a => false).Build()); 337var secondFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(a => false).Build()); 351var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(a => true).Build()); 369public DerivedAuthorizeFilter() : base(new AuthorizationPolicyBuilder().RequireAssertion(a => false).Build()) 377var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(c => c.Resource is AuthorizationFilterContext).Build()); 391var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireRole("Wut").Build()); 406var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder() 423var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder() 439var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder() 473var policy = new AuthorizationPolicyBuilder() 514var policy1 = new AuthorizationPolicyBuilder() 518var policy2 = new AuthorizationPolicyBuilder() 539var policy1 = new AuthorizationPolicyBuilder() 543var policy2 = new AuthorizationPolicyBuilder()
Microsoft.AspNetCore.Mvc.IntegrationTests (4)
AuthorizeFilterIntegrationTest.cs (4)
58var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); 89var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); 105var secondFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(a => true).Build()); 141var secondFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(a => true).Build());
Microsoft.AspNetCore.Routing.FunctionalTests (4)
EndpointRoutingIntegrationTest.cs (4)
111services.AddAuthorization(options => options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build()); 143services.AddAuthorization(options => options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build()); 204services.AddAuthorization(options => options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build()); 235services.AddAuthorization(options => options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build());
Microsoft.AspNetCore.SignalR.Tests (1)
MapSignalRTests.cs (1)
106var policy1 = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build();
41 references to AuthorizationPolicyBuilder
Aspire.Dashboard (2)
Authentication\OpenIdConnect\AuthorizationPolicyBuilderExtensions.cs (2)
22public static AuthorizationPolicyBuilder RequireOpenIdClaims(this AuthorizationPolicyBuilder builder, OpenIdConnectOptions options)
CustomPolicyProvider (1)
Authorization\MinimumAgePolicyProvider.cs (1)
44var policy = new AuthorizationPolicyBuilder();
Microsoft.AspNetCore.Authorization (28)
AuthorizationBuilder.cs (5)
85public virtual AuthorizationBuilder AddPolicy(string name, Action<AuthorizationPolicyBuilder> configurePolicy) 109public virtual AuthorizationBuilder AddDefaultPolicy(string name, Action<AuthorizationPolicyBuilder> configurePolicy) 113var policyBuilder = new AuthorizationPolicyBuilder(); 136public virtual AuthorizationBuilder AddFallbackPolicy(string name, Action<AuthorizationPolicyBuilder> configurePolicy) 140var policyBuilder = new AuthorizationPolicyBuilder();
AuthorizationOptions.cs (2)
62public void AddPolicy(string name, Action<AuthorizationPolicyBuilder> configurePolicy) 67var policyBuilder = new AuthorizationPolicyBuilder();
AuthorizationPolicy.cs (2)
81var builder = new AuthorizationPolicyBuilder(); 130AuthorizationPolicyBuilder? policyBuilder = null;
AuthorizationPolicyBuilder.cs (19)
21/// Creates a new instance of <see cref="AuthorizationPolicyBuilder"/> 30/// Creates a new instance of <see cref="AuthorizationPolicyBuilder"/>. 45/// Gets or sets a list authentication schemes the <see cref="AuthorizationPolicyBuilder.Requirements"/> 55/// <see cref="AuthorizationPolicyBuilder.AuthenticationSchemes"/> for this instance. 59public AuthorizationPolicyBuilder AddAuthenticationSchemes(params string[] schemes) => AddAuthenticationSchemesCore(schemes); 61private AuthorizationPolicyBuilder AddAuthenticationSchemesCore(IEnumerable<string> schemes) 72/// <see cref="AuthorizationPolicyBuilder.Requirements"/> for this instance. 76public AuthorizationPolicyBuilder AddRequirements(params IAuthorizationRequirement[] requirements) => AddRequirementsCore(requirements); 78private AuthorizationPolicyBuilder AddRequirementsCore(IEnumerable<IAuthorizationRequirement> requirements) 92public AuthorizationPolicyBuilder Combine(AuthorizationPolicy policy) 108public AuthorizationPolicyBuilder RequireClaim(string claimType, params string[] allowedValues) 122public AuthorizationPolicyBuilder RequireClaim(string claimType, IEnumerable<string> allowedValues) 136public AuthorizationPolicyBuilder RequireClaim(string claimType) 150public AuthorizationPolicyBuilder RequireRole(params string[] roles) 163public AuthorizationPolicyBuilder RequireRole(IEnumerable<string> roles) 176public AuthorizationPolicyBuilder RequireUserName(string userName) 188public AuthorizationPolicyBuilder RequireAuthenticatedUser() 199public AuthorizationPolicyBuilder RequireAssertion(Func<AuthorizationHandlerContext, bool> handler) 212public AuthorizationPolicyBuilder RequireAssertion(Func<AuthorizationHandlerContext, Task<bool>> handler)
Microsoft.AspNetCore.Authorization.Policy (3)
AuthorizationEndpointConventionBuilderExtensions.cs (2)
103public static TBuilder RequireAuthorization<TBuilder>(this TBuilder builder, Action<AuthorizationPolicyBuilder> configurePolicy) 113var policyBuilder = new AuthorizationPolicyBuilder();
AuthorizationMiddleware.cs (1)
125var reqPolicy = new AuthorizationPolicyBuilder();
Microsoft.AspNetCore.Authorization.Test (6)
DefaultAuthorizationServiceTests.cs (6)
348var policy = new AuthorizationPolicyBuilder().RequireRole("Administrator") 371var policy = new AuthorizationPolicyBuilder().RequireClaim(ClaimTypes.Role); 392var policy = new AuthorizationPolicyBuilder("AuthType").RequireClaim(ClaimTypes.Name); 409var policy = new AuthorizationPolicyBuilder("AuthType").RequireRole("Admin"); 426var policy = new AuthorizationPolicyBuilder("AuthType").RequireRole("Admin", "Users"); 442var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewPage");
Microsoft.AspNetCore.Mvc.Core (1)
Authorization\AuthorizeFilter.cs (1)
122var builder = new AuthorizationPolicyBuilder(await ComputePolicyAsync());