-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Route hijacking with restricted public access - protected page request is not handled by custom login page controller #10730
Comments
Thanks for the report @mattmawford - I'll see if we can find someone to say something clever about this! The holiday season has kicked in though, so it might take a little longer, apologies in advance! 😅 |
Hi @mattmawford I have done some initial investigation and will need some help from a fellow colleague who is on summer holiday as Seb mentions. |
Investigation NotesHere are some notes of my digging and debugging I have done for anyone else who comes along to this issue on return from holiday.
Comparing this with a direct request to the login page it will not call PublicAccessMiddleware but it will still call into UmbracoRoutesFactory and will carry on the logic to find a HijackedController and set it on the UmbracoRouteValues in the HttpContext.Features. So I am now very perplexed, hopefully with these notes and a fresh pair of eyes on this can spot what the problem is. |
Have perhaps made a bit of progress. The issue seems to be that the In this case though, whilst it runs for the originally requested page, it doesn't run again after the That's as far as I've got though... we don't explicitly call this method, rather the framework does, so I haven't managed to figure out any further. |
Thanks for the notes @AndyButland I have done some hacking & poking around with not much luck, with our With you mentioning the values in RouteValueDictionary being incorrect my hack or thought was that perhaps I could modify the values & re-assign it back on the // Values in 'RouteValueDictionary' are wrong - update them
var routeValues = httpContext.Request.RouteValues;
// Modify values & re-assign
routeValues[Constants.Web.Routing.ControllerToken] = updatedRouteValues.ControllerName;
routeValues[Constants.Web.Routing.ActionToken] = updatedRouteValues.ActionName;
httpContext.Request.RouteValues = routeValues; There is also this method but I am unsure how it is supposed to be used and wonder if this would help ensuring we route to the custom controller/hijacked route logic. Seems some further source code diving of the ASPNet repro may needed to be done to figure this out and needs some smarter people such as @bergmania to investigate |
Afraid have made little more progress with further investigation, but just to document what I've tried. Similar to Warren above - before I'd realised he'd tried! - I found looking to reset the route values didn't have any effect. Slightly different syntax, so worth noting I guess, but I suspect it's doing the same thing under the hood:
There's not much documentation on
... which is perhaps worth doing to make sure we are in alignment with this notice, but it doesn't help with the current issue. I had one last thought - which is perhaps cheating - but I wondered why we don't simply issue a redirect from the |
@AndyButland - personally I feel it would be a shame to loose the existing behaviour. I find it's useful not to have been redirected to login, this way we have access to the original request and URL - essential when we want to know where the user is trying to go. |
Yes, agreed, even if there were a change like this we'd want to pass on that information - so redirect e.g. to |
Will this get addressed for v9 launch or use workaround for now? |
Fixed in #11155, ready for review |
I've tried this in v9-rc004, however if I have "Restrict Public Access" set on a page trying to access any pages underneath the LoginPageController gets hit all the time for any pages underneath the restricted page even when logged in and I can't navigate to any of the pages below. I'd except these controllers to be hit:
|
Which exact Umbraco version are you using? For example: 8.13.1 - don't just write v8
9.0.0-rc001
Bug summary
In v8, when a custom controller is in place for route hijacking on a member login page, a request to a protected page is handled by the custom member login page controller, and returns the login page template.
In v9, a similar request, whilst still returning the login page template, is handled by the default render controller. In other words, the custom login page controller only works of you navigate direct to the login page - it does not work if the login template is presented due to access being restricted to the requested page.
Specifics
My login page document type is MemberLoginPage
In v8, my route hijacking controller is like:
In v9, it's
Steps to reproduce
Create 3 document types for HomePage, TextPage and MemberLoginPage. Create content, with Restrict Public Access on the Restricted Access TextPage node like this:
In Visual Studio, create a custom controller called MemberLoginPageController (as above in Specifics), and place a breakpoint on the return line in the Index() method. Debug the solution, and browse to /login/ and /restricted-access/ in turn.
Expected result / actual result
I'd expect the breakpoint to be hit when browsing to both /login/ and /restricted-access/, but the breakpoint is only hit when browsing to /login/.
The text was updated successfully, but these errors were encountered: