Create a view
enable ajax
expose the filter
It doesn't matter if the block is detached or not.
When I click apply I get the following errors in the logs:
https://mysite.com|1517955969|access denied|127.0.0.1|https://mysite.com/views/ajax?_wrapper_format=drupal_ajax|https://mysite.com/group/1/events|1||/views/ajax?_wrapper_format=drupal_ajax
Feb 6 14:26:09 server pound: 52.119.115.169 POST /views/ajax?_wrapper_format=drupal_ajax HTTP/1.1 - HTTP/1.1 403 Forbidden
I am using letsencrypt for https. Pound/Varnish.
I disabled ssl and I still get the forbidden error. I am not sure why
Edit: the following is not the case.
It looks like the request is coming over http but when the url is converted to https the path is forbidden
| Comment | File | Size | Author |
|---|---|---|---|
| #43 | 2942657-shows-request-params-filtered.png | 49.56 KB | scott_earnest |
| #38 | group_route_ajax_route-2942657-38.patch | 935 bytes | mcortes19 |
| #33 | group_route_ajax_route-2942657-33.patch | 891 bytes | hitchshock |
| #31 | 2942657-31.patch | 1.08 KB | david.muffley |
| #27 | group_route_ajax_route-2942657-27.patch | 1.1 KB | chi |
Issue fork group-2942657
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
socialnicheguru commentedComment #3
socialnicheguru commentedI initially thought this was a problem with views in Drupal Core.
However I went to a site that I am working on and found that the ajax error only occurs when I have a view in a group.
It does not show up at other times.
Comment #4
sriharsha.uppuluri commentedFacing the similar issue
Comment #5
Keith Caulkins commentedSeeing this as well after upgrading from 8.3.9 to 8.5.3. Were you able to fix it?
Comment #6
socialnicheguru commentedNo it is still an issue.
views enabled with ajax not in a group work fine.
views enabled with ajax in a group give an error.
The view has a group:content relationship
I had to uncheck ajax for group views. Once I did that the error went away
Comment #7
just_like_good_vibeshello,
i had the same issue, and after some debug i found the ajax call returns an access denied 403 because the access was not granted to the view (access to the views display i checked during the execution of the ajax call). digging deeper, i realize the permission to access my view were "group permission" -> "access node overview". There was a little notice bellow this special permission with a warning saying the permission only works if a "group" argument is inside the route.
because the ajax call has not such a "group" argument, the permission cannot not work properly (by construction, such a permisson do not support AJAX calls).
i do not know if you are in the same case, i post this explanation just in case , hope that helps.
Mikael
Comment #8
socialnicheguru commentedWhat needs to be done here? Is there a workaround?
Comment #9
sumithb commentedWe too are experiencing this same issue.
Comment #10
danielen commentedRun into this issue too.
Workaround for me:
Removing Permission/Access for the View solved the problem.
But access check is required for me (to build a context). Currently I've no idea how to resolve this.
Comment #11
veronicaseveryn commentedI ran into the same issue when using Views Infinite Scroll for a pager on a View based on Groups (with Contextual filter for a group from URL and AJAX enabled). The view has specific Group permission check (based on the group you're browsing). This check fails in AJAX calls.
I have created a patch that solves the issue for me (Drupal 8.5.5).
To make it work 100%, you'll also need to use this fix: https://www.drupal.org/project/drupal/issues/2866386 (specifically, https://www.drupal.org/project/drupal/issues/2866386#comment-12525337) or wait until it gets committed in Core :))
Otherwise, it will only work on the first pagination step (like it did in my case).
Please, test for other use cases.
Comment #13
farnoosh commentedAny update on this issue?
Comment #14
farnoosh commentedI was receiving the same error on a "views" with Access Group permission that I didn't want to touch, using ajax resulting the pager not working with access denied warning.
If you are having this issue on Drupal 8.6.4:
Here is my workaround to get the views pager to work.
1- apply https://www.drupal.org/project/drupal/issues/3021827#comment-12901850
2- Then apply the attached patch. I updated this patch based on #11
Comment #15
socialnicheguru commentedis there an interdiff with 11?
Comment #16
farnoosh commentedPatch #12 works on core 8.6.4
Comment #17
subhojit777The patch in #11 does not applies on 8.x Here is the updated version. I have also made some improvements.
1. Instead of using unsafe
$_POSTI am using Symfony request component for retrieving the data.Comment #19
varshith commentedThe above patch doesn't work for me. I see 2 issues
- The value $_POST['view_path'] can only be obtained directly from $_POST and its null if obtained using 'Symfony request component'.
- The value $_POST['view_path'] is inclusive of site 'base_path' and so fails route matching if base path is not '/'.
I am attaching a patch against latest dev release of the module and it works fine for views infinite scroll using group permission.
EDIT:
I also had to use this core patch as 'load more' didn't work for me from second time
https://www.drupal.org/project/drupal/issues/2866386#comment-13158418
Comment #20
emb03 commentedPatch #18 did not work for me (group_route_ajax_route-2942657-18.patch)
Comment #21
tomsaw commentedPatch #19 worked for me :).
Worked with plain pager and views_infinite_scroll.
Thanks!
Comment #22
tomsaw commentedAjax broken again with 'group RC1'
Comment #23
jukka792 commentedHi
Patch #19 worked for me with Group 8.x-1.3
Thanks community!
Comment #24
joelrotelli commentedPatch #19 works like a charm ! Thanks
Comment #25
it-cruPatch #19 worked for me with Group 8.x-1.4
Raised to major because Group related views which using AJAX are not working.
Comment #26
it-cruComment #27
chi commentedThat calls AccessAwareRouter which checks access to the route. I don't think it is needed because we just want to get the group parameter.
Also it conflicts with #2815971: More contexts needed when Group permission plugin is used. Access control and Group route context call each other which creates infinite loop.
The attached patch relies on
router.no_access_checksrouter instead.Comment #28
david.muffley commentedChanged to 2.x-dev since 1.x is security fix only. This still applies as-is to 2.x, and it's still necessary to fix the issue.
Comment #29
jdleonardBug still exists in Group 3.2.0. #27 and #19 apply cleanly, but do not resolve the problem. Removing the group permission from the view's access control setting does, but of course that access restriction is there for a reason!
Comment #30
jan-e commentedPatch in #19 still has to be applied in Group 8.x-1.6.
Comment #31
david.muffley commented#27 doesn't work with Drupal ^10.1 when a view's ajax is a GET. Here's an update to handle older core versions with POST and newer ones with GET. Manually tested with both Drupal 9.5 and Drupal 10.1, both with and without a base path, and with and without valid access. This is just begging for automated tests.
Comment #32
jan-e commented@david.muffley in #31: can't you use
$_REQUESTin stead of the switch between$_GETand$_POST?Comment #33
hitchshockRefactored the last patch to make it Drupal 10 compatible.
Comment #34
maskedjellybeanThanks all and thanks @HitchShock. #33 works for me in Drupal 10.2.3 and Group 1.6.0.
Adding some pieces of the error that is thrown by this issue so hopefully folks find this easier:
access denied Warning Path: /views/ajax?_wrapper_format=drupal_ajaxSymfony\Component\HttpKernel\Exception\AccessDeniedHttpException: in Drupal\views\Controller\ViewAjaxController->ajaxView() (line 220 of /docroot/core/modules/views/src/Controller/ViewAjaxController.php)Comment #35
iamsruthi.s commented@HitchShock applied patch #33 in Drupal 10.2.4 but not working for me, just scrolls to the top of the page.
Comment #36
iamsruthi.s commentedComment #37
blacksnipeI had a similar issue with exposed filters (without Views Infinite Scroll) in D10.
Patch #33 by @HitchShock solves my issue. Not sure about VIS though.
Comment #38
mcortes19 commentedAdded validation when Group view is attached to a node or any other page
Comment #41
jurgenhaasI've turned this into an MR with the idea to replace the call to
\Drupal::service()and to$_REQUESTwith proper function calls. While that works for the router, it doesn't for the request parameter. I wasn't able to figure out why and commented that out in line 124. Maybe somebody knows why this isn't working?Comment #43
scott_earnest commented@jurgenhaas - i found that the 'view_path', along with other parameters used by ajax, have been stripped by the time you can get them via dependency injection of the symfony request stack.
See: core/modules/views/src/Controller/ViewAjaxController.php
in method "ajaxView"
(one of the FILTERED_QUERY_PARAMETERS is of course "view_path")
I adjusted your MR to remove the request property on the class, and the commented code.
This works for us, test steps to follow.
Comment #44
scott_earnest commentedTesting Steps
Create a view with a group relationship
Format the view as a table
Click "sortable" on one or more of the field in the settings
Update the "Access" to be "Group Permission", then set that permission
Use ajax
Verify when logged in as a member of a group with the correct permissions that the click sorting works with ajax enabled