3 instantiations of AuthorizationResult
Microsoft.AspNetCore.Authorization (3)
AuthorizationResult.cs (3)
15
private static readonly AuthorizationResult _succeededResult =
new
() { Succeeded = true };
16
private static readonly AuthorizationResult _failedResult =
new
() { Failure = AuthorizationFailure.ExplicitFail() };
42
public static AuthorizationResult Failed(AuthorizationFailure failure) => new
AuthorizationResult
{ Failure = failure };
117 references to AuthorizationResult
Aspire.Dashboard (1)
Authentication\AspirePolicyEvaluator.cs (1)
114
var
result = await _authorization.AuthorizeAsync(context.User, resource, policy).ConfigureAwait(false);
Microsoft.AspNetCore.Authorization (45)
AuthorizationMetrics.cs (2)
33
public void AuthorizedRequestCompleted(ClaimsPrincipal user, string? policyName,
AuthorizationResult
? result, Exception? exception)
42
private void AuthorizedRequestCompletedCore(ClaimsPrincipal user, string? policyName,
AuthorizationResult
? result, Exception? exception)
AuthorizationResult.cs (7)
15
private static readonly
AuthorizationResult
_succeededResult = new() { Succeeded = true };
16
private static readonly
AuthorizationResult
_failedResult = new() { Failure = AuthorizationFailure.ExplicitFail() };
35
public static
AuthorizationResult
Success() => _succeededResult;
41
/// <returns>The <see cref="
AuthorizationResult
"/>.</returns>
42
public static
AuthorizationResult
Failed(AuthorizationFailure failure) => new AuthorizationResult { Failure = failure };
47
/// <returns>The <see cref="
AuthorizationResult
"/>.</returns>
48
public static
AuthorizationResult
Failed() => _failedResult;
AuthorizationServiceExtensions.cs (12)
24
/// A <see cref="Task{TResult}"/> that contains an <see cref="
AuthorizationResult
"/> indicating whether requirement evaluation has succeeded or failed.
25
/// The result's <see cref="
AuthorizationResult
.Succeeded"/> property is <c>true</c> when the user fulfills the policy; otherwise <c>false</c>.
27
public static Task<
AuthorizationResult
> AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object? resource, IAuthorizationRequirement requirement)
43
/// A <see cref="Task{TResult}"/> that contains an <see cref="
AuthorizationResult
"/> indicating whether policy evaluation has succeeded or failed.
44
/// The result's <see cref="
AuthorizationResult
.Succeeded"/> property is <c>true</c> when the user fulfills the policy; otherwise <c>false</c>.
46
public static Task<
AuthorizationResult
> AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object? resource, AuthorizationPolicy policy)
61
/// A <see cref="Task{TResult}"/> that contains an <see cref="
AuthorizationResult
"/> indicating whether policy evaluation has succeeded or failed.
62
/// The result's <see cref="
AuthorizationResult
.Succeeded"/> property is <c>true</c> when the user fulfills the policy; otherwise <c>false</c>.
64
public static Task<
AuthorizationResult
> AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, AuthorizationPolicy policy)
79
/// A <see cref="Task{TResult}"/> that contains an <see cref="
AuthorizationResult
"/> indicating whether policy evaluation has succeeded or failed.
80
/// The result's <see cref="
AuthorizationResult
.Succeeded"/> property is <c>true</c> when the user fulfills the policy; otherwise <c>false</c>.
82
public static Task<
AuthorizationResult
> AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, string policyName)
DefaultAuthorizationEvaluator.cs (4)
15
/// <returns>The <see cref="
AuthorizationResult
"/>.</returns>
16
public
AuthorizationResult
Evaluate(AuthorizationHandlerContext context)
18
?
AuthorizationResult
.Success()
19
:
AuthorizationResult
.Failed(context.HasFailed
DefaultAuthorizationService.cs (7)
59
/// A <see cref="Task{TResult}"/> that contains an <see cref="
AuthorizationResult
"/> indicating whether authorization has succeeded.
60
/// The result's <see cref="
AuthorizationResult
.Succeeded"/> property is <c>true</c> when the user fulfills the policy; otherwise <c>false</c>.
62
public virtual async Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object? resource, IEnumerable<IAuthorizationRequirement> requirements)
77
var
result = _evaluator.Evaluate(authContext);
96
/// A <see cref="Task{TResult}"/> that contains an <see cref="
AuthorizationResult
"/> indicating whether authorization has succeeded.
97
/// The result's <see cref="
AuthorizationResult
.Succeeded"/> property is <c>true</c> when the user fulfills the policy; otherwise <c>false</c>.
99
public virtual async Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object? resource, string policyName)
DefaultAuthorizationServiceImpl.cs (4)
24
public override async Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object? resource, IEnumerable<IAuthorizationRequirement> requirements)
26
AuthorizationResult
result;
41
public override async Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object? resource, string policyName)
43
AuthorizationResult
result;
DenyAnonymousAuthorizationRequirement.cs (1)
12
/// it never calls <see cref="AuthorizationHandlerContext.Fail()"/>. The <see cref="DefaultAuthorizationEvaluator"/> produces a failed <see cref="
AuthorizationResult
" />
IAuthorizationEvaluator.cs (2)
15
/// <returns>The <see cref="
AuthorizationResult
"/>.</returns>
16
AuthorizationResult
Evaluate(AuthorizationHandlerContext context);
IAuthorizationService.cs (6)
25
/// A <see cref="Task{TResult}"/> that contains an <see cref="
AuthorizationResult
"/> indicating whether authorization has succeeded.
26
/// The result's <see cref="
AuthorizationResult
.Succeeded"/> property is <c>true</c> when the user fulfills the policy; otherwise <c>false</c>.
32
Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object? resource, IEnumerable<IAuthorizationRequirement> requirements);
44
/// A <see cref="Task{TResult}"/> that contains an <see cref="
AuthorizationResult
"/> indicating whether authorization has succeeded.
45
/// The result's <see cref="
AuthorizationResult
.Succeeded"/> property is <c>true</c> when the policy has been fulfilled; otherwise <c>false</c>.
51
Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object? resource, string policyName);
Microsoft.AspNetCore.Authorization.Policy (1)
PolicyEvaluator.cs (1)
98
var
result = await _authorization.AuthorizeAsync(context.User, resource, policy);
Microsoft.AspNetCore.Authorization.Test (49)
DefaultAuthorizationServiceTests.cs (40)
44
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
65
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
87
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
107
var
allowed = await authorizationService.AuthorizeAsync(new ClaimsPrincipal(), "Custom");
134
var
allowed = await authorizationService.AuthorizeAsync(new ClaimsPrincipal(), "Custom");
185
var
allowed = await authorizationService.AuthorizeAsync(new ClaimsPrincipal(), "Custom");
214
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
236
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
257
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
276
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
290
var
allowed = await authorizationService.AuthorizeAsync(null, null, "Basic");
305
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
326
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
361
var
allowed = await authorizationService.AuthorizeAsync(user, policy.Build());
382
var
allowed = await authorizationService.AuthorizeAsync(user, policy.Build());
399
var
allowed = await authorizationService.AuthorizeAsync(user, policy.Build());
416
var
allowed = await authorizationService.AuthorizeAsync(user, null, policy.Build());
432
var
allowed = await authorizationService.AuthorizeAsync(user, policy.Build());
453
var
allowed = await authorizationService.AuthorizeAsync(user, policy.Build());
473
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
501
var
allowed = await authorizationService.AuthorizeAsync(user, "Hao");
527
var
allowed = await authorizationService.AuthorizeAsync(user, "Hao");
549
var
allowed = await authorizationService.AuthorizeAsync(user, "Hao");
571
var
allowed = await authorizationService.AuthorizeAsync(user, "Hao");
596
var
allowed = await authorizationService.AuthorizeAsync(user, null, "Any");
616
var
allowed = await authorizationService.AuthorizeAsync(user, null, "Any");
649
var
allowed = await authorizationService.AuthorizeAsync(user, null, "Custom");
670
var
allowed = await authorizationService.AuthorizeAsync(user, null, "Custom");
711
var
allowed = await authorizationService.AuthorizeAsync(user, null, "Passthrough");
739
var
allowed = await authorizationService.AuthorizeAsync(user, null, "Combined");
766
var
allowed = await authorizationService.AuthorizeAsync(user, null, "Combined");
793
var
allowed = await authorizationService.AuthorizeAsync(user, null, "Combined");
970
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
989
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
1028
var
allowed = await authorizationService.AuthorizeAsync(user, "Basic");
1076
public
AuthorizationResult
Evaluate(AuthorizationHandlerContext context) =>
AuthorizationResult
.Success();
1087
var
result = await authorizationService.AuthorizeAsync(null, "Fail");
1211
var
result = await authorizationService.AuthorizeAsync(user, "Log");
1245
var
result = await authorizationService.AuthorizeAsync(user, "Log");
PassThroughAuthorizationHandlerTests.cs (1)
41
var
allowed = await authorizationService.AuthorizeAsync(new ClaimsPrincipal(), "Self");
PolicyEvaluatorTests.cs (8)
171
public Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable<IAuthorizationRequirement> requirements)
172
=> Task.FromResult(
AuthorizationResult
.Success());
174
public Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName)
175
=> Task.FromResult(
AuthorizationResult
.Success());
180
public Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable<IAuthorizationRequirement> requirements)
181
=> Task.FromResult(
AuthorizationResult
.Failed());
183
public Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName)
184
=> Task.FromResult(
AuthorizationResult
.Failed());
Microsoft.AspNetCore.Components.Authorization (1)
AuthorizeViewCore.cs (1)
112
var
result = await AuthorizationService.AuthorizeAsync(user, Resource, policy!);
Microsoft.AspNetCore.Components.Authorization.Tests (19)
AuthorizeRouteViewTest.cs (5)
51
_testAuthorizationService.NextResult =
AuthorizationResult
.Success();
87
_testAuthorizationService.NextResult =
AuthorizationResult
.Success();
126
_testAuthorizationService.NextResult =
AuthorizationResult
.Failed();
155
_testAuthorizationService.NextResult =
AuthorizationResult
.Failed();
178
_testAuthorizationService.NextResult =
AuthorizationResult
.Failed();
AuthorizeViewTest.cs (6)
90
authorizationService.NextResult =
AuthorizationResult
.Success();
118
authorizationService.NextResult =
AuthorizationResult
.Success();
154
authorizationService.NextResult =
AuthorizationResult
.Success();
190
authorizationService.NextResult =
AuthorizationResult
.Success();
296
authorizationService.NextResult =
AuthorizationResult
.Success();
355
authorizationService.NextResult =
AuthorizationResult
.Success();
TestAsyncAuthorizationService.cs (4)
11
public
AuthorizationResult
NextResult { get; set; }
12
=
AuthorizationResult
.Failed();
17
public async Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable<IAuthorizationRequirement> requirements)
31
public Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName)
TestAuthorizationService.cs (4)
11
public
AuthorizationResult
NextResult { get; set; }
12
=
AuthorizationResult
.Failed();
17
public Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable<IAuthorizationRequirement> requirements)
28
public Task<
AuthorizationResult
> AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName)
Microsoft.AspNetCore.SignalR.Core (1)
Internal\DefaultHubDispatcher.cs (1)
685
var
authorizationResult = await authService.AuthorizeAsync(principal, resource, authorizePolicy);