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

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