2 types derived from AuthorizeAttribute
CustomPolicyProvider (1)
Authorization\MinimumAgeAuthorizeAttribute.cs (1)
16
internal class MinimumAgeAuthorizeAttribute :
AuthorizeAttribute
Microsoft.AspNetCore.Authorization.Test (1)
AuthorizationMiddlewareTests.cs (1)
450
public class ReqAuthorizeAttribute :
AuthorizeAttribute
, IAuthorizationRequirementData
137 instantiations of AuthorizeAttribute
Aspire.Dashboard (3)
Otlp\Grpc\OtlpGrpcLogsService.cs (1)
12
[
Authorize
(Policy = OtlpAuthorization.PolicyName)]
Otlp\Grpc\OtlpGrpcMetricsService.cs (1)
12
[
Authorize
(Policy = OtlpAuthorization.PolicyName)]
Otlp\Grpc\OtlpGrpcTraceService.cs (1)
12
[
Authorize
(Policy = OtlpAuthorization.PolicyName)]
Aspire.Hosting (1)
Dashboard\DashboardService.cs (1)
20
[
Authorize
(Policy = ResourceServiceApiKeyAuthorization.PolicyName)]
BasicWebSite (5)
Controllers\AuthorizeUserController.cs (4)
9
[
Authorize
("Api")]
12
[
Authorize
("Api-Manager")]
18
[
Authorize
(Roles = "Administrator")]
24
[
Authorize
("Impossible")]
Controllers\TestingController.cs (1)
61
[
Authorize
("Api")]
ClaimsTransformation (1)
Controllers\HomeController.cs (1)
18
[
Authorize
]
Cookies (1)
Controllers\HomeController.cs (1)
18
[
Authorize
]
CustomAuthorizationFailureResponse (3)
Controllers\SampleController.cs (3)
15
[
Authorize
(Policy = SamplePolicyNames.CustomPolicyWithCustomForbiddenMessage)]
22
[
Authorize
(Policy = SamplePolicyNames.CustomPolicy)]
29
[
Authorize
(Policy = SamplePolicyNames.FailureReasonPolicy)]
IdentitySample.Mvc (2)
Controllers\AccountController.cs (1)
15
[
Authorize
]
Controllers\ManageController.cs (1)
13
[
Authorize
]
JwtSample (1)
Broadcaster.cs (1)
10
[
Authorize
(JwtBearerDefaults.AuthenticationScheme)]
Microsoft.AspNetCore.Authorization.Policy (4)
AuthorizationEndpointConventionBuilderExtensions.cs (4)
28
return builder.RequireAuthorization(new
AuthorizeAttribute
());
46
return builder.RequireAuthorization(policyNames.Select(n => new
AuthorizeAttribute
(n)).ToArray());
69
authorizeData = new IAuthorizeData[] { new
AuthorizeAttribute
(), };
142
endpointBuilder.Metadata.Add(new
AuthorizeAttribute
());
Microsoft.AspNetCore.Authorization.Test (47)
AuthorizationAppBuilderExtensionsTests.cs (1)
29
new EndpointMetadataCollection(new
AuthorizeAttribute
()),
AuthorizationEndpointConventionBuilderExtensionsTests.cs (3)
17
var metadata = new
AuthorizeAttribute
();
173
var authorize = new
AuthorizeAttribute
();
200
var authorize = new
AuthorizeAttribute
();
AuthorizationMiddlewareTests.cs (28)
115
var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new
AuthorizeAttribute
()), authenticationService: authenticationService);
136
var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new
AuthorizeAttribute
()), authenticationService: authenticationService);
158
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
() { AuthenticationSchemes = "whatever" }), authenticationService: authenticationService);
180
var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new
AuthorizeAttribute
()), authenticationService: authenticationService);
205
var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new
AuthorizeAttribute
("whatever")));
250
var endpoint = CreateEndpoint(new
AuthorizeAttribute
("whatever"), new ReqAttribute(req));
290
var endpoint = CreateEndpoint(new
AuthorizeAttribute
("whatever"), new ReqAttribute(req));
359
var endpoint = CreateEndpoint(new
AuthorizeAttribute
("whatever"));
399
var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new
AuthorizeAttribute
("whatever")));
433
var context = GetHttpContext(anonymous: false, endpoint: CreateEndpoint(new
AuthorizeAttribute
(), policy));
513
var context = GetHttpContext(anonymous: false, endpoint: CreateEndpoint(new
AuthorizeAttribute
(), new ReqAttribute(req)));
553
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()));
573
var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new
AuthorizeAttribute
(), new AllowAnonymousAttribute()), authenticationService: authenticationService);
594
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()), authenticationService: authenticationService);
616
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()), authenticationService: authenticationService);
638
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()));
662
var endpoint = CreateEndpoint(new
AuthorizeAttribute
());
691
var endpoint = CreateEndpoint(new
AuthorizeAttribute
());
712
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()), authenticationService: authenticationService);
734
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()), authenticationService: authenticationService);
757
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()), authenticationService: authenticationService);
778
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()));
802
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
(), new AllowAnonymousAttribute()), authenticationService: authenticationService);
842
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()), authenticationService: authenticationService.Object);
865
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()));
891
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()));
930
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()), authenticationService: authenticationService.Object);
956
var context = GetHttpContext(endpoint: CreateEndpoint(new
AuthorizeAttribute
()));
AuthorizationPolicyFacts.cs (12)
22
new
AuthorizeAttribute
(),
23
new
AuthorizeAttribute
("1") { AuthenticationSchemes = "dupe" },
24
new
AuthorizeAttribute
("2") { AuthenticationSchemes = "dupe" },
25
new
AuthorizeAttribute
{ Roles = "r1,r2", AuthenticationSchemes = "roles" },
51
new
AuthorizeAttribute
(),
52
new
AuthorizeAttribute
(),
74
new
AuthorizeAttribute
(),
75
new
AuthorizeAttribute
("2") { AuthenticationSchemes = "dupe" }
100
new
AuthorizeAttribute
() { Roles = "r1 , r2" }
121
new
AuthorizeAttribute
() { AuthenticationSchemes = "a1 , a2" }
141
new
AuthorizeAttribute
() { AuthenticationSchemes = "a1 , , ,,, a2" }
161
new
AuthorizeAttribute
() { Roles = "r1 , ,, , r2" }
DefaultAuthorizationServiceTests.cs (1)
31
new
AuthorizeAttribute
{ Policy = "Wut" }
MetadataTest.cs (2)
14
var metadata = new
AuthorizeAttribute
();
27
var metadata = new
AuthorizeAttribute
("Name");
Microsoft.AspNetCore.Components.Authorization.Tests (2)
AuthorizeRouteViewTest.cs (1)
379
[
Authorize
]
AuthorizeViewTest.cs (1)
575
=> new[] { new
AuthorizeAttribute
{ AuthenticationSchemes = "test scheme" } };
Microsoft.AspNetCore.Components.Endpoints.Tests (4)
RazorComponentEndpointFactoryTest.cs (4)
29
new object[] { new
AuthorizeAttribute
() }),
60
builder => builder.Metadata.Add(new
AuthorizeAttribute
())
89
builder => builder.Metadata.Add(new
AuthorizeAttribute
())
144
builder => builder.Metadata.Add(new
AuthorizeAttribute
())
Microsoft.AspNetCore.Http.Connections.Tests (7)
HttpConnectionDispatcherTests.cs (2)
3962
[
Authorize
]
3989
[
Authorize
(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
MapConnectionHandlerTests.cs (5)
163
options.AuthorizationData.Add(new
AuthorizeAttribute
());
222
options.AuthorizationData.Add(new
AuthorizeAttribute
());
252
.RequireAuthorization(new
AuthorizeAttribute
("Foo"));
466
[
Authorize
]
471
[
Authorize
]
Microsoft.AspNetCore.Mvc.Core (2)
Authorization\AuthorizeFilter.cs (2)
31
: this(authorizeData: new[] { new
AuthorizeAttribute
() })
75
: this(new[] { new
AuthorizeAttribute
(policy) })
Microsoft.AspNetCore.Mvc.Core.Test (17)
ApiConventionTypeAttributeTest.cs (2)
60
var attributes = new Attribute[] { new ProducesAttribute(typeof(object)), new ServiceFilterAttribute(typeof(object)), new
AuthorizeAttribute
() };
75
[
Authorize
]
ApplicationModels\AuthorizationApplicationModelProviderTest.cs (3)
219
[
Authorize
(Policy = "Base")]
227
[
Authorize
(Policy = "Derived")]
233
[
Authorize
]
ApplicationModels\ControllerActionDescriptorProviderTests.cs (2)
1747
[
Authorize
("ControllerPolicy")]
1753
[
Authorize
("ActionPolicy")]
Authorization\AuthorizeFilterTest.cs (10)
56
var authorizeFilter = new AuthorizeFilter(new[] { new
AuthorizeAttribute
() });
72
var authorizeFilter = new AuthorizeFilter(new[] { new
AuthorizeAttribute
() });
107
var authorizeFilter = new AuthorizeFilter(policyProvider.Object, new AuthorizeAttribute[] { new
AuthorizeAttribute
("whatever") });
259
new
AuthorizeAttribute
{ Policy = "true"},
260
new
AuthorizeAttribute
{ Policy = "false"}
283
new
AuthorizeAttribute
{ Policy = "true"},
284
new
AuthorizeAttribute
{ Policy = "false"}
291
var thirdFilter = new AuthorizeFilter(testProvider2, new IAuthorizeData[] { new
AuthorizeAttribute
(policy: "something") });
457
new AuthorizeFilter(new[] { new
AuthorizeAttribute
()}),
558
new EndpointMetadataCollection(new
AuthorizeAttribute
("policy2")),
Microsoft.AspNetCore.Mvc.IntegrationTests (1)
AuthorizeFilterIntegrationTest.cs (1)
215
[
Authorize
(Policy = "Base")]
Microsoft.AspNetCore.Mvc.RazorPages (4)
DependencyInjection\PageConventionCollectionExtensions.cs (4)
203
model.EndpointMetadata.Add(new
AuthorizeAttribute
(policy));
266
model.EndpointMetadata.Add(new
AuthorizeAttribute
(policy));
292
model.EndpointMetadata.Add(new
AuthorizeAttribute
(policy));
355
model.EndpointMetadata.Add(new
AuthorizeAttribute
(policy));
Microsoft.AspNetCore.Mvc.RazorPages.Test (5)
ApplicationModels\AuthorizationPageApplicationModelProviderTest.cs (4)
47
[
Authorize
]
98
[
Authorize
]
141
[
Authorize
(Policy = "Base")]
146
[
Authorize
(Policy = "Derived")]
ApplicationModels\ResponseCacheFilterApplicationModelProviderTest.cs (1)
44
[
Authorize
]
Microsoft.AspNetCore.Routing.Tests (1)
TestObjects\TestMatcherFactory.cs (1)
70
metadataList.Add(new
AuthorizeAttribute
());
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (3)
Hubs.cs (1)
316
[
Authorize
(JwtBearerDefaults.AuthenticationScheme)]
Startup.cs (2)
101
.RequireAuthorization(new
AuthorizeAttribute
(JwtBearerDefaults.AuthenticationScheme));
103
.RequireAuthorization(new
AuthorizeAttribute
(NegotiateDefaults.AuthenticationScheme));
Microsoft.AspNetCore.SignalR.Tests (9)
AuthConnectionHandler.cs (1)
11
[
Authorize
]
AuthHub.cs (1)
8
[
Authorize
]
HubConnectionHandlerTestUtils\Hubs.cs (3)
152
[
Authorize
("test")]
157
[
Authorize
("test")]
241
[
Authorize
("test")]
MapSignalRTests.cs (4)
240
options.AuthorizationData.Add(new
AuthorizeAttribute
());
271
.RequireAuthorization(new
AuthorizeAttribute
("Foo"));
377
[
Authorize
]
386
[
Authorize
]
Negotiate.Server (2)
Controllers\AuthController.cs (2)
26
[
Authorize
]
39
[
Authorize
]
PathSchemeSelection (1)
Controllers\HomeController.cs (1)
18
[
Authorize
]
RazorPagesWebSite (2)
Controllers\AuthorizedActionController.cs (1)
10
[
Authorize
]
Pages\ModelWithAuthFilter.cs (1)
10
[
Authorize
]
SecurityWebSite (7)
Controllers\AdministrationController.cs (1)
22
[
Authorize
(AuthenticationSchemes = "Cookie2")]
Controllers\AuthorizedActionsController.cs (1)
16
[
Authorize
("RequireClaimB")]
Controllers\AuthorizedController.cs (2)
9
[
Authorize
] // requires any authenticated user (aka the application cookie typically)
12
[
Authorize
(AuthenticationSchemes = "Bearer")]
Controllers\HomeController.cs (2)
17
[
Authorize
]
24
[
Authorize
]
Pages\AuthorizePageViaModel.cshtml.cs (1)
10
[
Authorize
("RequireClaimB")]
SignalR.Client.FunctionalTestApp (1)
AuthorizedHub.cs (1)
10
[
Authorize
(JwtBearerDefaults.AuthenticationScheme)]
StaticFilesAuth (1)
Startup.cs (1)
129
new
AuthorizeAttribute
(policy)
74 references to AuthorizeAttribute
Microsoft.AspNetCore.Authorization (2)
AuthorizeAttribute.cs (2)
18
/// Initializes a new instance of the <see cref="
AuthorizeAttribute
"/> class.
23
/// Initializes a new instance of the <see cref="
AuthorizeAttribute
"/> class with the specified policy.
Microsoft.AspNetCore.Authorization.Test (13)
AuthorizationEndpointConventionBuilderExtensionsTests.cs (3)
17
var
metadata = new AuthorizeAttribute();
173
var
authorize = new AuthorizeAttribute();
200
var
authorize = new AuthorizeAttribute();
AuthorizationPolicyFacts.cs (7)
21
var attributes = new
AuthorizeAttribute
[] {
50
var attributes = new
AuthorizeAttribute
[] {
73
var attributes = new
AuthorizeAttribute
[] {
99
var attributes = new
AuthorizeAttribute
[] {
120
var attributes = new
AuthorizeAttribute
[] {
140
var attributes = new
AuthorizeAttribute
[] {
160
var attributes = new
AuthorizeAttribute
[] {
DefaultAuthorizationServiceTests.cs (1)
30
await Assert.ThrowsAsync<InvalidOperationException>(() => AuthorizationPolicy.CombineAsync(provider, new
AuthorizeAttribute
[] {
MetadataTest.cs (2)
14
var
metadata = new AuthorizeAttribute();
27
var
metadata = new AuthorizeAttribute("Name");
Microsoft.AspNetCore.Components.Endpoints.Tests (5)
RazorComponentEndpointFactoryTest.cs (5)
42
Assert.Contains(endpoint.Metadata, m => m is
AuthorizeAttribute
);
77
Assert.Contains(endpoint.Metadata, m => m is
AuthorizeAttribute
);
105
Assert.Contains(endpoint.Metadata, m => m is
AuthorizeAttribute
);
149
builder => builder.Metadata.Remove(builder.Metadata.OfType<
AuthorizeAttribute
>().Single())
165
Assert.DoesNotContain(endpoint.Metadata, m => m is
AuthorizeAttribute
);
Microsoft.AspNetCore.Mvc.Core (1)
Authorization\AuthorizeFilter.cs (1)
18
/// <see cref="AuthorizationPolicy"/>. MVC recognizes the <see cref="
AuthorizeAttribute
"/> and adds an instance of
Microsoft.AspNetCore.Mvc.Core.Test (4)
ApplicationModels\ControllerActionDescriptorProviderTests.cs (3)
266
metadata => Assert.IsType<
AuthorizeAttribute
>(metadata),
274
metadata => Assert.Equal("ControllerPolicy", Assert.IsType<
AuthorizeAttribute
>(metadata).Policy),
275
metadata => Assert.Equal("ActionPolicy", Assert.IsType<
AuthorizeAttribute
>(metadata).Policy));
Authorization\AuthorizeFilterTest.cs (1)
107
var authorizeFilter = new AuthorizeFilter(policyProvider.Object, new
AuthorizeAttribute
[] { new AuthorizeAttribute("whatever") });
Microsoft.AspNetCore.Mvc.IntegrationTests (4)
AuthorizeFilterIntegrationTest.cs (4)
37
var authorizeData = action.Attributes.OfType<
AuthorizeAttribute
>();
65
var authorizeData = action.Attributes.OfType<
AuthorizeAttribute
>();
96
var authorizeData = action.Attributes.OfType<
AuthorizeAttribute
>();
132
var authorizeData = action.Attributes.OfType<
AuthorizeAttribute
>();
Microsoft.AspNetCore.Mvc.RazorPages.Test (44)
DependencyInjection\PageConventionCollectionExtensionsTest.cs (44)
66
Assert.IsType<
AuthorizeAttribute
>(Assert.Single(model.EndpointMetadata));
72
Assert.IsType<
AuthorizeAttribute
>(model.EndpointMetadata[0]);
187
metadata => Assert.IsType<
AuthorizeAttribute
>(metadata));
194
metadata => Assert.IsType<
AuthorizeAttribute
>(metadata),
201
metadata => Assert.IsType<
AuthorizeAttribute
>(metadata),
272
metadata => Assert.IsType<
AuthorizeAttribute
>(metadata));
279
metadata => Assert.IsType<
AuthorizeAttribute
>(metadata),
287
metadata => Assert.IsType<
AuthorizeAttribute
>(metadata),
427
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(model.EndpointMetadata));
456
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(authorizeFilter.AuthorizeData));
484
var
authorizeAttribute = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(model.EndpointMetadata));
538
var
authorizeAttribute = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(model.EndpointMetadata));
593
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(model.EndpointMetadata));
622
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(authorizeFilter.AuthorizeData));
653
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(model.EndpointMetadata));
660
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(model.EndpointMetadata));
690
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(authorizeFilter.AuthorizeData));
697
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(authorizeFilter.AuthorizeData));
728
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(model.EndpointMetadata));
735
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(model.EndpointMetadata));
767
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(authorizeFilter.AuthorizeData));
774
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(authorizeFilter.AuthorizeData));
806
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(model.EndpointMetadata));
813
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(model.EndpointMetadata));
845
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(authorizeFilter.AuthorizeData));
852
var
authorizeData = Assert.IsType<
AuthorizeAttribute
>(Assert.Single(authorizeFilter.AuthorizeData));
Microsoft.AspNetCore.SignalR.Core (1)
Internal\DefaultHubDispatcher.cs (1)
800
var authorizeAttributes = methodInfo.GetCustomAttributes<
AuthorizeAttribute
>(inherit: true);