-
Notifications
You must be signed in to change notification settings - Fork 597
Failed authorization for an authenticated user redirects to login page instead of access denied page #246
Comments
Yes, that API is very easy to read :) |
OK - but I am returning a 403 for an authenticated user - and this code path does not seem to get hit.. |
You'd think that 403 would be the appropriate thing to return, but what they eventually settled on is returning a 401 and having the auth middleware that produced the user identity (cookies) change it to a 403 OR redirect to AccessDeniedPath. |
Yep, need to convince @lodejard if you want to change this behavior... |
Related ticket: #134 |
OK - fair enough. But still it does not work. I authenticate using cookie MW and hit a Authorize attribute with a role check - role check fails and I get redirected to login page. I have an access denied page set on the cookie MW. Am I doing something wrong? |
@HaoK ? |
So, according to @lodejard, they should already be acting like this: https://twitter.com/loudej/status/601074953836834816 In my tests with 1.0.0-beta5-12413 versions of AuthN/AuthZ packages, this isn't working -- an authenticated, but not authorized, user is still getting a 302 redirect to the login page. |
Looks like the issue is 401->403 not working for automatic authentication, which is always the case for the Authorize(Roles = "Foo"). Things seem to work via an explicit policy where ActiveAuthenticationScheme includes the Cookie... Still investigating |
Yup, confirmed this workaround should work @leastprivilege @bojanrajkovic can you try this and see fixes the issue?
And then an addition |
@HaoK Confirmed, that works! I added that configuration snippet and added |
Awesome thanks, just wanted to make sure this is the same root issue, I'll work on the fix shortly... |
This should be in builds now, right? We don't need that workaround from earlier? |
A failed role check with the Authorize attribute redirects an authenticated user back to the login page. I haven't checked the internals, but that seems to indicate you are emitting a 401.
My assumption was that in that situation a 403 should be emitted and the cookie middleware will use the AccessDeniedPath instead.
The text was updated successfully, but these errors were encountered: