Problem / motivation
The core tracker module is a really useful module that enables tracking of recent content for users.
The main problem is that the most of times we want to enable and allow just admins or content editors to access this interface, but the module is currently using the default _permission: 'access content' for "/activity" url (see tracker.routing.yml). The most of times you might not want to have content types or users names disclosed to the anonymous users.

Steps to reproduce
1) Enable Activity Tracker module
2) As anonymous user, try to access http://yoursitedomain.com/activity
You might see all the information about the users activity, including "Page type", "Page Title", "Author", "Comments" and "Last Updated Date". There is no way to control who can see this information.

Proposed solution
Create a new "access users activity" permission and use it instead of the default "access content". It is possible to have better control of who should see the page by having this new permission type.

Comments

bertonha created an issue. See original summary.

bertonha’s picture

StatusFileSize
new816 bytes

Patch tracker_prevent_anonymous-2978468-2.patch attached

Status: Needs review » Needs work

The last submitted patch, 2: tracker_prevent_anonymous-2978468-2.patch, failed testing. View results

bertonha’s picture

StatusFileSize
new3.72 KB

tracker_prevent_anonymous-2978468-3.patch

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

PeterE’s picture

In case someone else lands here, I had a similar situation whereby I only want the administrator to view user activity.

Add the following to your custom module's mymodule.services.yml (where mymodule is our custom module's name)

services:
  mymodule.route_subscriber:
    class: Drupal\mymodule\Routing\RouteSubscriber
    tags:
      - { name: 'event_subscriber' }

Then create a route in your module's src\Routing\RouteSubscriber.php as follows:

/**
 * change permissions of actvity tracker module to admin only 
 * based on https://www.drupal.org/docs/8/api/routing-system/altering-existing-routes-and-adding-new-routes-based-on-dynamic-ones
 */
namespace Drupal\mymodule\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;



class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {

    // Note that the second parameter of setRequirement() is a string.
    if ($route = $collection->get('tracker.page')) {
      $route->setRequirement('_permission', 'Administer content');
    }
	
	if ($route = $collection->get('tracker.users_recent_content')) {
      $route->setRequirement('_permission', 'Administer content');
    }
	
	if ($route = $collection->get('tracker.user_tab')) {
      $route->setRequirement('_permission', 'Administer content');
    }
  }

}

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

hazit’s picture

It would be useful to simply add Activity Tracker to the permissions list so that access can be set per User Role (i.e. not just anonymous vs authenticated).

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

jasonluttrell’s picture

+1 for adding this feature to Drupal 8/9, implemented as hazit described above. Thanks.

tjtj’s picture

This is a security issue. Anyone can see all activities including admin ones. Must be fixed in core ASAP! Still exists in 9.1.4

bessonweb’s picture

I think also it's a security and SEO issue. That expose all usernames and potentially not published contents. It's not very critical but personnally, I have disabled this module for these reasons.

tjtj’s picture

And people who enable this module do not know that it exposes user names and activities with NO access control permissions. I think it is quite critical. I found this by looking at my logs, and a hacker was accessing this page.

pwolanin’s picture

This seems more that it is a documentation issue and feature request, not a security issue?

There *is* access control via permission - if you have a closed site then anonymous users should not have the access content permission.

larowlan’s picture

If the list includes unpublished node titles then it's access bypass

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

csc4’s picture

+1 for considering this as a security issue in that there is no warning that enabling this module exposes title information with no access checks which is very 'unDrupal' - and undermines module level protections such as Groups

The suggestion from 6 Apr 2010 #762962-45: Add permissions for the tracker pages for three permissions seems

From that issue: Proposed resolution

The patch in #45 adds these three permissions:

access global tracker
access other user's tracker
access own tracker

Seems a really good solution even 11 years on...

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Postponed

This extension is deprecated and scheduled for removal in Drupal 11.

This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

It will be moved to the contributed extension once the Drupal 11 branch is open.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

Project: Drupal core » Activity Tracker
Version: 11.x-dev » 1.0.x-dev
Component: tracker.module » Code
Assigned: bertonha » Unassigned
Status: Postponed » Needs work
Related issues: +#2777445: Restrict access to track user page by default in Tracker module

now in contrib

xmacinfo’s picture

Using the contrib module on D11.

I am surprised to see that anonymous users can see the list of Recent content even if I set the view block permission to:

Role: Administrator

I wonder what is overriding the permission I set in the view.

/admin/structure/views/view/content_recent

Creating a custom module with a custom permissions.yml and routing.yml is one solution. But I would expect the module itself to handle permissions.

If we plan to add missing permissions to this module, let's change the issue to task and change the issue title to:

Add a new “access users activity” permission.

Pseudo code:

    access users activity:
      title: 'Access users activity'
      description: 'Allows users to view the activity tracker page.'
    tracker.activity_page:
      path: '/activity'
      defaults:
        _controller: '\Drupal\tracker\Controller\TrackerController::activityPage'
        _title: 'Activity'
      requirements:
        _permission: 'access users activity'
batigolix’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#1941830: Convert tracker listings to a view

This can be resolved together with the conversion to Views: #1941830: Convert tracker listings to a view

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.