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

Latest authZ iteration #151

Closed
wants to merge 1 commit into from
Closed

Latest authZ iteration #151

wants to merge 1 commit into from

Conversation

HaoK
Copy link
Member

@HaoK HaoK commented Feb 10, 2015

  • Core Auth API now takes list of IAuthorizationRequirements, or policy name.
  • Overload that takes AuthorizationPolicy instance moved to extension method.
  • Remove HttpContext from API and replace with ClaimsPrincipal instead
  • Add Operation requirement
  • Base AuthenticationHandler now automatically converts 401 to 403 if authenticate was called
  • Add Sync overloads
  • Add ClaimsTransformationOptions (TBD where to use this)

Fixes #132
Fixes #116
Fixes #11
Fixes #117
Fixes #134

cc @lodejard @blowdart @yishaigalatzer @Tratcher


// If authenticate was called and the the status is still 401, authZ failed so set 403 and stop
// REVIEW: Does this need to ensure that there's the 401 is challenge for this auth type?
if (Response.StatusCode == 401 && _authenticateCalled)
Copy link
Member

Choose a reason for hiding this comment

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

This approach easily breaks down with any of the auth middleware that change challenges to redirects (Google, FB, MS, Tw, OIDC, WsFed, etc). Consider:

  • The auth middleware produces the identity, but then it does a client side redirect and preserves the identity via a cookie.
  • On the next request it is the cookie auth middleware that will set _authenticateCalled.
  • If authorization fails and issues another challenge then a few different things could happen:
    • If the challenge is a general 401 without specifying an auth type and any of the redirecting middleware are Active, then the first Active middleware will redirect the request and you're stuck in an infinite auth loop just like before.
    • If the challenge is a specific to an auth type then the middleware doesn't even have to be active, it will always redirect the request and you're stuck in an infinite auth loop just like before.
  • So for this to work you have to avoid both of the above by either:
    • Issue a general challenge and have all the auth middleware set to Passive
    • Issue a specific challenge for cookie auth

Copy link
Member

Choose a reason for hiding this comment

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

One related note: It's quite strange for cookie auth to issue 403s if it's set up to handle 401s by redirecting to a login page. Wouldn't it make more sense for it to redirect to an Access Denied page instead?

@HaoK
Copy link
Member Author

HaoK commented Feb 16, 2015

Removing 401/403 changes and handling that in a different PR

@HaoK
Copy link
Member Author

HaoK commented Feb 16, 2015

Merged 5094b85

@HaoK HaoK closed this Feb 16, 2015
@HaoK HaoK deleted the auth2-9 branch April 20, 2015 23:19
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.

2 participants