? ? Pending

User tests: Successful: Unsuccessful:

avatar LivioCavallo
LivioCavallo
27 Aug 2017

Summary of Changes

Joomla! has a good permissions system that allows fine-grained settings in components, categories till to the article level.
In the major part of cases all these settings are correctly checked and respected but in some circumstancies 'com_content' only checks permissions at component level: article, articles and featured models.

The article model:

  • populateState function authorises at component level and eventually filters published and archived articles.
    A 'TODO' in comments seems to clearly suggest that a different authorisation was intended.
    This PR authorises at article level.

  • getItem function authorises at component level and eventually filters not-expired and not-future articles.
    It seems to me that article level authorisation was simply forgotten.
    This PR authorises at article level.

Testing Instructions

Create an unpublished (or expired or pending) TEST article in "Uncategorised" category.
Set permissions in "Uncategorised" category to allow Registered user group to 'edit' and 'edit.state'.
Create e menuitem/single article -> TEST article.
Login in frontend as registered user and navigate to menuitem.

Expected result

Page is displayed.

Actual result

Page is NOT displayed. User has not permissions to view article, error 404, article not found.

Notes

  • This PR is related to #17725.
avatar joomla-cms-bot joomla-cms-bot - change - 27 Aug 2017
Category Front End com_content
avatar LivioCavallo LivioCavallo - open - 27 Aug 2017
avatar LivioCavallo LivioCavallo - change - 27 Aug 2017
Status New Pending
avatar LivioCavallo
LivioCavallo - comment - 27 Aug 2017

Should we check for $pk==0 ? I think not, as article model is not used for new article creation (form model is used in that case)

avatar LivioCavallo
LivioCavallo - comment - 27 Aug 2017

Why is AppVeyor failing with php7.1?

avatar laoneo
laoneo - comment - 28 Aug 2017

What wonders me if the $pk variable is always set. Because when not set , then this checks will always return false for none super admin users as there is no asset com_content..

avatar ggppdk
ggppdk - comment - 28 Aug 2017
avatar ggppdk
ggppdk - comment - 28 Aug 2017

It is wrong to check 'com_content.article.' . $pk for new records, but possibly harmless because the record (the article) does not exist yet in the DB

[EDIT]
i meant by looking where filter_published state setting is being used , and it is being used inside getItem

avatar LivioCavallo LivioCavallo - change - 28 Aug 2017
Labels Added: ?
avatar LivioCavallo
LivioCavallo - comment - 28 Aug 2017

Yes, $pk can be unset, but this is not related to the present problem with authorisation.

In fact you can always browse a malformed url, lacking id in query, and you'll get an error page: index.php?option=com_content&view=article&Itemid=101 won't work.

But this can be the chance to improve this too: I think that the component should work anyway, also when input from user is not correct, if there is a univocal intended behaviour.
In this case, the explicit article id in the url seems redundant: if the user passes a url with a correct Itemid but without the article id, it is quite sure he wants the article contained in the menuitem query string. So we can retrieve the article id from the menuitem.

I added this input check and improvement to present PR.

avatar laoneo
laoneo - comment - 28 Aug 2017

I think this was a step into the wrong direction. I would rather do like:

$asset = 'com_content';
if ($pk)
{
    $asset = 'com_content.article.' . $pk;
}
if ((!$user->authorise('core.edit.state', $asset))
avatar LivioCavallo
LivioCavallo - comment - 28 Aug 2017

Why is that direction wrong?
It makes the component more robust, resilent to erroneous user input.

avatar laoneo
laoneo - comment - 28 Aug 2017

Because the model should not be aware about any menu. Imagine you use the model in a plugin which gets triggered when displaying a contact, then you will have a menu with a totally wrong id.

avatar LivioCavallo
LivioCavallo - comment - 28 Aug 2017

@laoneo: You are right. Thanks. Reverted.

avatar laoneo
laoneo - comment - 28 Aug 2017

The second checks needs the same logic, or not?

avatar LivioCavallo
LivioCavallo - comment - 28 Aug 2017

I think not, as $pk is already 'sanitized' in getItem at row 79, calling getState('article.id') that default-returns null and is converted to (int) 0.

avatar joomlabeat
joomlabeat - comment - 23 Sep 2017

I ended up here tonight, searching the issues regarding filtering the article model when there is no authorised user. I am working on a plugin and I need to get info for all the articles, disregarding if the user has access to it. Currently it's impossible to get an unpublished or trashed article, as it will result to a 404.

Does this PR fixes that?

avatar LivioCavallo
LivioCavallo - comment - 24 Sep 2017

I'm not sure I understand your question.
With this PR the model will return all and just the articles the user has permissions to edit.
So if the user has permissions on a specifit article to edit it or to edit its state then the model will return that article if it is published, archived, suspended, expired or pending.

avatar joomlabeat
joomlabeat - comment - 24 Sep 2017

@LivioCavallo

In my system plugin, I am looping over an array of articles id's - trying to gather their data (e.g. catid) by using the model. But if I request an article that is unpublished from the model with getItem($id) - then the model will throw a 404error. So it's impossible to get such information through the model for unpublished or trashed items.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 31 Oct 2017

@LivioCavallo is this PR on for Test?

avatar LivioCavallo
LivioCavallo - comment - 1 Nov 2017

Yes, this PR is ready for Test!
And it solves the problem.

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 5 Nov 2017 - Tested successfully
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Nov 2017

I have tested this item successfully on 31a121a

Works as expected, test on unpublished, expired and pending.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17735.

avatar twister65
twister65 - comment - 23 Sep 2018

I have tested this item successfully on 31a121a


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17735.

avatar twister65 twister65 - test_item - 23 Sep 2018 - Tested successfully
avatar franz-wohlkoenig franz-wohlkoenig - change - 23 Sep 2018
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 23 Sep 2018

Ready to Commit after two successful tests.

avatar LivioCavallo LivioCavallo - change - 26 Sep 2018
Labels Added: ?
avatar mbabker mbabker - change - 2 Oct 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-10-02 16:17:13
Closed_By mbabker
avatar mbabker mbabker - close - 2 Oct 2018
avatar mbabker mbabker - merge - 2 Oct 2018

Add a Comment

Login with GitHub to post a comment