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

Filter should call through to AuthorizationService #4385

Closed
wants to merge 2 commits into from
Closed

Conversation

HaoK
Copy link
Member

@HaoK HaoK commented Mar 30, 2016

@@ -75,7 +75,6 @@ public AuthorizeFilter(AuthorizationPolicy policy)

// Note: Default Anonymous User is new ClaimsPrincipal(new ClaimsIdentity())
if (httpContext.User == null ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure @Tratcher told me once that this property couldn't be null, but maybe things have changed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still can't, at least not with our DefaultHttpContext, but who knows what implementation is under this HttpContext... :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe yeah, people do unexpected things sometimes 😄

FWIW, I'd personally remove this null check and treat null principals like empty ones, specially since the authorization service is fine with null values.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could flow null into the auth service as well.

@HaoK
Copy link
Member Author

HaoK commented May 23, 2016

@Eilon who should sign off on this change?

@Eilon
Copy link
Member

Eilon commented May 24, 2016

Assigned to @kichalla to review.

// Arrange
var authorizeFilter = new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build());
var authorizationContext = GetAuthorizationContext(services => services.AddAuthorization(), anonymous: true);
authorizationContext.HttpContext.User = new ClaimsPrincipal();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a variation for null user?

@kichalla
Copy link
Member

:shipit: after responding to the minor comment

@HaoK
Copy link
Member Author

HaoK commented May 24, 2016

f54a964

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

Successfully merging this pull request may close these issues.

6 participants