-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Browseable API does not check view permissions when rendering permission denied response ? #5127
Comments
Seems a valid issue, yup. Side-effect of the rather wooly way that the browsable API has to infer what filters are present etc... Not typically going to raise an error, but in this particular case of filtering against the user, causes an exception when an authenticated user request is made, since the field is attempt to filter against a PK, but the object is being coerced into the We probably want to double check if this is still an issue, as it's possible that it's been resolved by something else along the way. Otherwise, we could wrap quiet exception handling around |
For anyone looking to reproduce this issue, they may want to take a look at #6592, although it wasn't able to reproduce the failure. |
I can confirm that this is still an issue with
|
I've added my 3 quarters to this issue. Please check out my pull request with the explanation of why I think this isn't a bug at all. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
* tests for encode#5127 * Resolves encode#5127
Checklist
master
branch of Django REST framework.Steps to reproduce
With
IsAuthenticated
permission class added to a ViewSet, accessing the Browseable API (not an issue with other formats) with an anonymouys user causes´get_queryset()´ to be called and if, for example, ´get_queryset()´ expects an authenticated user, call can fail with exception.
I believe this happens when calculating the template context of a permission denied response, as currently
get_context()
(https://github.com/encode/django-rest-framework/blob/master/rest_framework/renderers.py#L626) callsget_filter_form()
(https://github.com/encode/django-rest-framework/blob/master/rest_framework/renderers.py#L611) which calls ´get_queryset()´.Example code:
Traceback:
Expected behavior
HTTP 403 Response
Actual behavior
HTTP 500 Response
The text was updated successfully, but these errors were encountered: