? Pending

User tests: Successful: Unsuccessful:

avatar carlitorweb
carlitorweb
25 Jan 2023

Pull Request for Issue #39706

Joomla\CMS\Dispatcher\ComponentDispatcherFactory::createDispatcher search for the component dispatcher, in this case the com_config dispatcher. As there is not a dispatcher class inside the component, is used Joomla\CMS\Dispatcher\ComponentDispatcher::checkAccess(). This function check only if the user have core.manage permission, something com_config do not need kown from a NoSuperUser.

One solution is change Joomla\CMS\Dispatcher\ComponentDispatcher::checkAccess() for check in case:

$this->option === "com_config"

then check for the right permission:

!$this->app->getIdentity()->authorise('core.options', $this->option)

But I liked better the approch of override the function in the component.

Testing Instructions

Check the issue description

Actual result BEFORE applying this Pull Request

Check the issue description

Expected result AFTER applying this Pull Request

Clicking on the Options button will display the options for the component.

Link to documentations

Please select:

  • No documentation changes for docs.joomla.org needed

  • No documentation changes for manual.joomla.org needed

avatar joomla-cms-bot joomla-cms-bot - change - 25 Jan 2023
Category Administration com_config
avatar carlitorweb carlitorweb - open - 25 Jan 2023
avatar carlitorweb carlitorweb - change - 25 Jan 2023
Status New Pending
avatar carlitorweb
carlitorweb - comment - 25 Jan 2023

For maintainers, please notice checkAccess() can be empty. I added that check there for be sure we cover all possible scenarios. Let me kown if keep the function empty is good enough.

avatar carlitorweb carlitorweb - change - 25 Jan 2023
The description was changed
avatar carlitorweb carlitorweb - edited - 25 Jan 2023
avatar carlitorweb carlitorweb - change - 25 Jan 2023
The description was changed
avatar carlitorweb carlitorweb - edited - 25 Jan 2023
avatar carlitorweb carlitorweb - change - 25 Jan 2023
The description was changed
avatar carlitorweb carlitorweb - edited - 25 Jan 2023
avatar carlitorweb carlitorweb - change - 25 Jan 2023
Title
Display the options for a component for a no SuperUser account
Display the component options to a NoSuperUser account
avatar carlitorweb carlitorweb - edited - 25 Jan 2023
avatar carlitorweb carlitorweb - change - 25 Jan 2023
The description was changed
avatar carlitorweb carlitorweb - edited - 25 Jan 2023
avatar carlitorweb carlitorweb - change - 25 Jan 2023
The description was changed
avatar carlitorweb carlitorweb - edited - 25 Jan 2023
avatar wilsonge
wilsonge - comment - 7 Feb 2023
avatar joomdonation
joomdonation - comment - 7 Feb 2023

I looked at com_config and saw that the code provided in this PR does not cover all the cases yet. I suggest use the code like below:

protected function checkAccess()
{
	$task = $this->input->getCmd('task');

	// sendtestmail expects json response, so we leave the method to handle the permission and send response itself
	if ($task === 'application.sendtestmail') {
		return;
	}

	$option = $this->input->getCmd('component');
	$user   = $this->app->getIdentity();

	if ($option && !in_array(strtolower($option), ['com_joomlaupdate', 'com_privacy'], true)) {
		$canAccess = $user->authorise('core.admin', $option) || $user->authorise('core.options', $option);
	} else {
		$canAccess = $user->authorise('core.admin');
	}

	if (!$canAccess) {
		throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
	}
}

Explanation:

  • The checkAccess method should throw NotAllowed exception if user does not have permission to perform the action like we do for all other extensions (not perform redirection like in proposed code)
  • When component is provided in the request, we check for core.admin or core.options permissions for all components except com_privacy, com_joomlaupdate . For the two components, we need to have global core.admin permission.
  • For all other actions in com_config, users need to have global core.admin permission.
  • We need special case for sendtestmail here because the ajax request expect json response, so if we throws Exception, I think the javascript code which handle response would have some error.
avatar carlitorweb
carlitorweb - comment - 7 Feb 2023

The checkAccess method should throw NotAllowed exception if user does not have permission to perform the action like we do for all other extensions (not perform redirection like in proposed code)

Throw a error page it should not be the result for a user. Redirect with a message of why cant access I think is how should work in this case.

avatar joomdonation
joomdonation - comment - 7 Feb 2023

Throw a error page it should not be the result for a user. Redirect with a message of why cant access I think is how should work in this case.

Users should not be presented with the link if they do not have permission. If they type the URL directly, they get error is expected behavior. Anyway, that's how it works for all component dispatchers which we implemented.

avatar carlitorweb carlitorweb - change - 7 Feb 2023
Labels Added: ?
avatar carlitorweb
carlitorweb - comment - 7 Feb 2023

Btw, good catch about "sendtestmail"

avatar carlitorweb
carlitorweb - comment - 7 Feb 2023

@joomdonation is done

avatar carlitorweb
carlitorweb - comment - 15 Feb 2023

@joomdonation After checked all references to the function, I removed the function param $authCheck because is not used. Also, is not relate with the way we check now the permissions.

avatar joomdonation
joomdonation - comment - 16 Feb 2023

@carlitorweb Unfortunately, your last commits messed up the code. The general rule is you are not allowed to change the behavior of a public method (which could be used by other extensions - potential cause backward incompatible change).

Thinking more about the issue, I realized we need to check it more carefully to avoid user bypass permission check by passing the component input in the request. I come up with this code which should be more secure and a bit more clean than the current code https://github.com/joomla/joomla-cms/compare/4.2-dev...joomdonation:joomla-cms:com_config_dispatcher?expand=1

Please take a look at the code and feel free to ask it to your PR.

avatar carlitorweb
carlitorweb - comment - 16 Feb 2023

You are correct about b/c.

@joomdonation I will close this PR, please up yours.

avatar joomdonation
joomdonation - comment - 16 Feb 2023

@carlitorweb OK. If you don't want to continue, you can close the PR and I will open a new PR to replace this one. Thanks for trying !

avatar carlitorweb carlitorweb - change - 16 Feb 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-02-16 11:37:52
Closed_By carlitorweb
avatar carlitorweb carlitorweb - close - 16 Feb 2023

Add a Comment

Login with GitHub to post a comment