This repository was archived by the owner on Dec 14, 2018. It is now read-only.
File tree 3 files changed +10
-10
lines changed
src/Microsoft.AspNet.Mvc.Core/Filters
test/WebSites/FiltersWebSite 3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -44,10 +44,10 @@ public virtual async Task OnAuthorizationAsync(Filters.AuthorizationContext cont
44
44
}
45
45
46
46
// Build a ClaimsPrincipal with the Policy's required authentication types
47
- if ( Policy . ActiveAuthenticationSchemes != null && Policy . ActiveAuthenticationSchemes . Any ( ) )
47
+ if ( Policy . AuthenticationSchemes != null && Policy . AuthenticationSchemes . Any ( ) )
48
48
{
49
49
ClaimsPrincipal newPrincipal = null ;
50
- foreach ( var scheme in Policy . ActiveAuthenticationSchemes )
50
+ foreach ( var scheme in Policy . AuthenticationSchemes )
51
51
{
52
52
var result = await context . HttpContext . Authentication . AuthenticateAsync ( scheme ) ;
53
53
if ( result != null )
@@ -77,7 +77,7 @@ public virtual async Task OnAuthorizationAsync(Filters.AuthorizationContext cont
77
77
! httpContext . User . Identities . Any ( i => i . IsAuthenticated ) ||
78
78
! await authService . AuthorizeAsync ( httpContext . User , context , Policy ) )
79
79
{
80
- context . Result = new ChallengeResult ( Policy . ActiveAuthenticationSchemes . ToArray ( ) ) ;
80
+ context . Result = new ChallengeResult ( Policy . AuthenticationSchemes . ToArray ( ) ) ;
81
81
}
82
82
}
83
83
}
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ namespace FiltersWebSite
13
13
{
14
14
public class BasicAuthenticationHandler : AuthenticationHandler < BasicOptions >
15
15
{
16
- protected override Task < AuthenticationTicket > HandleAuthenticateAsync ( )
16
+ protected override Task < AuthenticateResult > HandleAuthenticateAsync ( )
17
17
{
18
18
var principal = new ClaimsPrincipal ( ) ;
19
19
principal . AddIdentity ( new ClaimsIdentity (
@@ -24,8 +24,8 @@ protected override Task<AuthenticationTicket> HandleAuthenticateAsync()
24
24
new Claim ( ClaimTypes . NameIdentifier , "John" )
25
25
} ,
26
26
Options . AuthenticationScheme ) ) ;
27
- return Task . FromResult ( new AuthenticationTicket ( principal ,
28
- new AuthenticationProperties ( ) , Options . AuthenticationScheme ) ) ;
27
+ return Task . FromResult ( AuthenticateResult . Success ( new AuthenticationTicket ( principal ,
28
+ new AuthenticationProperties ( ) , Options . AuthenticationScheme ) ) ) ;
29
29
}
30
30
}
31
31
}
Original file line number Diff line number Diff line change @@ -20,22 +20,22 @@ public void ConfigureServices(IServiceCollection services)
20
20
// This policy cannot succeed since the claim is never added
21
21
options . AddPolicy ( "Impossible" , policy =>
22
22
{
23
- policy . ActiveAuthenticationSchemes . Add ( "Interactive" ) ;
23
+ policy . AuthenticationSchemes . Add ( "Interactive" ) ;
24
24
policy . RequireClaim ( "Never" ) ;
25
25
} ) ;
26
26
options . AddPolicy ( "Api" , policy =>
27
27
{
28
- policy . ActiveAuthenticationSchemes . Add ( "Api" ) ;
28
+ policy . AuthenticationSchemes . Add ( "Api" ) ;
29
29
policy . RequireClaim ( ClaimTypes . NameIdentifier ) ;
30
30
} ) ;
31
31
options . AddPolicy ( "Api-Manager" , policy =>
32
32
{
33
- policy . ActiveAuthenticationSchemes . Add ( "Api" ) ;
33
+ policy . AuthenticationSchemes . Add ( "Api" ) ;
34
34
policy . Requirements . Add ( Operations . Edit ) ;
35
35
} ) ;
36
36
options . AddPolicy ( "Interactive" , policy =>
37
37
{
38
- policy . ActiveAuthenticationSchemes . Add ( "Interactive" ) ;
38
+ policy . AuthenticationSchemes . Add ( "Interactive" ) ;
39
39
policy . RequireClaim ( ClaimTypes . NameIdentifier )
40
40
. RequireClaim ( "Permission" , "CanViewPage" ) ;
41
41
} ) ;
You can’t perform that action at this time.
0 commit comments