4 instantiations of PolicyAuthorizationResult
Microsoft.AspNetCore.Authorization.Policy (4)
PolicyAuthorizationResult.cs (4)
11
private static readonly PolicyAuthorizationResult _challengedResult =
new
() { Challenged = true };
12
private static readonly PolicyAuthorizationResult _forbiddenResult =
new
() { Forbidden = true };
13
private static readonly PolicyAuthorizationResult _succeededResult =
new
() { Succeeded = true };
57
: new
PolicyAuthorizationResult
{ Forbidden = true, AuthorizationFailure = authorizationFailure };
56 references to PolicyAuthorizationResult
Aspire.Dashboard (8)
Authentication\AspirePolicyEvaluator.cs (8)
102
/// <returns>Returns <see cref="
PolicyAuthorizationResult
.Success"/> if authorization succeeds.
103
/// Otherwise returns <see cref="
PolicyAuthorizationResult
.Forbid(AuthorizationFailure)"/> if <see cref="AuthenticateResult.Succeeded"/>, otherwise
104
/// returns <see cref="
PolicyAuthorizationResult
.Challenge"/></returns>
105
public virtual async Task<
PolicyAuthorizationResult
> AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context, object? resource)
111
return
PolicyAuthorizationResult
.Forbid();
117
return
PolicyAuthorizationResult
.Success();
122
?
PolicyAuthorizationResult
.Forbid(result.Failure)
123
:
PolicyAuthorizationResult
.Challenge();
CustomAuthorizationFailureResponse (1)
Authorization\SampleAuthorizationMiddlewareResultHandler.cs (1)
29
PolicyAuthorizationResult
policyAuthorizationResult)
Microsoft.AspNetCore.Authorization.Policy (25)
AuthorizationMiddleware.cs (1)
193
var
authorizeResult = await policyEvaluator.AuthorizeAsync(policy, authenticateResult!, context, resource);
AuthorizationMiddlewareResultHandler.cs (1)
15
public Task HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy,
PolicyAuthorizationResult
authorizeResult)
IAuthorizationMiddlewareResultHandler.cs (1)
23
Task HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy,
PolicyAuthorizationResult
authorizeResult);
IPolicyEvaluator.cs (4)
34
/// <returns>Returns <see cref="
PolicyAuthorizationResult
.Success"/> if authorization succeeds.
35
/// Otherwise returns <see cref="
PolicyAuthorizationResult
.Forbid(AuthorizationFailure)"/> if <see cref="AuthenticateResult.Succeeded"/>, otherwise
36
/// returns <see cref="
PolicyAuthorizationResult
.Challenge"/></returns>
37
Task<
PolicyAuthorizationResult
> AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context, object? resource);
PolicyAuthorizationResult.cs (11)
11
private static readonly
PolicyAuthorizationResult
_challengedResult = new() { Challenged = true };
12
private static readonly
PolicyAuthorizationResult
_forbiddenResult = new() { Forbidden = true };
13
private static readonly
PolicyAuthorizationResult
_succeededResult = new() { Succeeded = true };
40
/// <returns>The <see cref="
PolicyAuthorizationResult
"/>.</returns>
41
public static
PolicyAuthorizationResult
Challenge() => _challengedResult;
46
/// <returns>The <see cref="
PolicyAuthorizationResult
"/>.</returns>
47
public static
PolicyAuthorizationResult
Forbid() => _forbiddenResult;
53
/// <returns>The <see cref="
PolicyAuthorizationResult
"/>.</returns>
54
public static
PolicyAuthorizationResult
Forbid(AuthorizationFailure? authorizationFailure)
62
/// <returns>The <see cref="
PolicyAuthorizationResult
"/>.</returns>
63
public static
PolicyAuthorizationResult
Success() => _succeededResult;
PolicyEvaluator.cs (7)
91
/// <returns>Returns <see cref="
PolicyAuthorizationResult
.Success"/> if authorization succeeds.
92
/// Otherwise returns <see cref="
PolicyAuthorizationResult
.Forbid(AuthorizationFailure)"/> if <see cref="AuthenticateResult.Succeeded"/>, otherwise
93
/// returns <see cref="
PolicyAuthorizationResult
.Challenge"/></returns>
94
public virtual async Task<
PolicyAuthorizationResult
> AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context, object? resource)
101
return
PolicyAuthorizationResult
.Success();
106
?
PolicyAuthorizationResult
.Forbid(result.Failure)
107
:
PolicyAuthorizationResult
.Challenge();
Microsoft.AspNetCore.Authorization.Test (20)
AuthorizationMiddlewareResultHandlerTests.cs (14)
20
var
policyAuthorizationResult =
PolicyAuthorizationResult
.Success();
34
var
policyAuthorizationResult =
PolicyAuthorizationResult
.Challenge();
48
var
policyAuthorizationResult =
PolicyAuthorizationResult
.Forbid();
69
var
policyAuthorizationResult =
PolicyAuthorizationResult
.Challenge();
87
var
policyAuthorizationResult =
PolicyAuthorizationResult
.Challenge();
108
var
policyAuthorizationResult =
PolicyAuthorizationResult
.Forbid();
126
var
policyAuthorizationResult =
PolicyAuthorizationResult
.Forbid();
PolicyEvaluatorTests.cs (6)
77
var
result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context, resource: null);
95
var
result = await evaluator.AuthorizeAsync(policy, success, context, resource: null);
96
var
result2 = await evaluator.AuthorizeAsync(policy, success, context, resource: new object());
112
var
result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context, resource: null);
129
var
result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), "scheme")), context, resource: null);
149
var
result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), "scheme")), context, resource: null);
Microsoft.AspNetCore.Mvc.Core (1)
Authorization\AuthorizeFilter.cs (1)
185
var
authorizeResult = await policyEvaluator.AuthorizeAsync(effectivePolicy, authenticateResult, context.HttpContext, context);
SecurityWebSite (1)
CountingPolicyEvaluator.cs (1)
16
public override Task<
PolicyAuthorizationResult
> AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context, object resource)