Skip to content

Fixed 500 error in admin when logged in and calling JSON view#10888

Merged
roland-d merged 1 commit intojoomla:stagingfrom
mahagr:login403json
Jun 25, 2016
Merged

Fixed 500 error in admin when logged in and calling JSON view#10888
roland-d merged 1 commit intojoomla:stagingfrom
mahagr:login403json

Conversation

@mahagr
Copy link
Copy Markdown

@mahagr mahagr commented Jun 21, 2016

Pull Request for Issue #10212.

Summary of Changes

By default if user hasn't logged in or the session has timed out, Joomla Administrator attempts to call login view.

Because of the login view only exists for HTML, JSON calls fail with 500 View not found [name, type, prefix]: login, json, loginView error. This is bad as it prevents JavaScript from detecting the missing permissions and reacting properly to the AJAX response.

The best solution in ideal world would be not to call com_login and let the component to handle the error by itself, but because of the changed behaviour would likely cause a huge amount of vulnerabilities in 3rd party components, the second best solution is to emulate components default behaviour when user has no access to it.

My proposal is to throw 403 You are not authorised to view this resource. error instead of 500. This is the default error message when you are logged in but your user doesn't have the proper admin permissions for the given component. This error message is shown in admin regardless of if the view/task exists or not.

In addition to JSON, this change changes behaviour from all non-HTML responses.

More discussion about this issue can be found from Issue #10212.

Testing Instructions

Log out and enter to administrator/index.php?option=com_xxx&format=json (GET or POST). Note that the contents of the URL doesn't matter as com_login intercepts the call.

In unpatched version you will get this error:

500 View not found [name, type, prefix]: login, json, loginView

In patched version the error changes into:

403 You are not authorised to view this resource.

Both errors are handled by default error page and they are in HTML.

Note: Component and view doesn't need to exist as the request gets intercepted by Joomla.

@crommie
Copy link
Copy Markdown

crommie commented Jun 25, 2016

I have tested this item ✅ successfully on f2ebd73

404 without patch applied, 403 with patch applied


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

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Jun 25, 2016

I have tested this item ✅ successfully on f2ebd73


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

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Jun 25, 2016

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jun 25, 2016
@roland-d roland-d added this to the Joomla 3.6.0 milestone Jun 25, 2016
@roland-d roland-d merged commit a65b686 into joomla:staging Jun 25, 2016
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jun 25, 2016
@roland-d
Copy link
Copy Markdown
Contributor

Thanks everybody

@mahagr
Copy link
Copy Markdown
Author

mahagr commented Jun 26, 2016

Thanks! Motivates me to look into contributing other fixes as well. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants