React to Authenticate(schemes) being removed

This commit is contained in:
Hao Kung 2015-03-16 16:57:16 -07:00
parent e16d263cd5
commit f05520602f
1 changed files with 6 additions and 6 deletions

View File

@ -35,16 +35,16 @@ namespace Microsoft.AspNet.Mvc
// Build a ClaimsPrincipal with the Policy's required authentication types // Build a ClaimsPrincipal with the Policy's required authentication types
if (Policy.ActiveAuthenticationSchemes != null && Policy.ActiveAuthenticationSchemes.Any()) if (Policy.ActiveAuthenticationSchemes != null && Policy.ActiveAuthenticationSchemes.Any())
{ {
var results = await context.HttpContext.AuthenticateAsync(Policy.ActiveAuthenticationSchemes); var newPrincipal = new ClaimsPrincipal();
if (results != null) foreach (var scheme in Policy.ActiveAuthenticationSchemes)
{ {
var newPrincipal = new ClaimsPrincipal(); var result = (await context.HttpContext.AuthenticateAsync(scheme))?.Principal;
foreach (var principal in results.Where(r => r.Principal != null).Select(r => r.Principal)) if (result != null)
{ {
newPrincipal.AddIdentities(principal.Identities); newPrincipal.AddIdentities(result.Identities);
} }
context.HttpContext.User = newPrincipal;
} }
context.HttpContext.User = newPrincipal;
} }
// Allow Anonymous skips all authorization // Allow Anonymous skips all authorization