Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

AuthorizeFilter sets null Identity #2534

Closed
leastprivilege opened this issue May 9, 2015 · 5 comments
Closed

AuthorizeFilter sets null Identity #2534

leastprivilege opened this issue May 9, 2015 · 5 comments
Assignees
Milestone

Comments

@leastprivilege
Copy link

I think you have a bug here:

// Build a ClaimsPrincipal with the Policy's required authentication types
if (Policy.ActiveAuthenticationSchemes != null && Policy.ActiveAuthenticationSchemes.Any())
{
var newPrincipal = new ClaimsPrincipal();
foreach (var scheme in Policy.ActiveAuthenticationSchemes)
{
var result = (await context.HttpContext.Authentication.AuthenticateAsync(scheme))?.Principal;
if (result != null)
{
newPrincipal.AddIdentities(result.Identities);
}
}
context.HttpContext.User = newPrincipal;

This will result in a null ClaimsPrincipal.Identity when the user is not authenticated.

You rather want to create an Identity that is not authenticated.

@danroth27
Copy link
Member

@blowdart Can you take a look at this?

@danroth27 danroth27 removed this from the 6.0.0-beta5 milestone May 11, 2015
@blowdart
Copy link
Member

I already pinged @HaoK.

@HaoK
Copy link
Member

HaoK commented May 13, 2015

1ea1cc4

@HaoK HaoK closed this as completed May 13, 2015
@vcsjones
Copy link

Is the milestone for this still beta5?

@danroth27 danroth27 added this to the 6.0.0-beta5 milestone May 26, 2015
@danroth27
Copy link
Member

Yup, the fix is in beta5.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants