Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Conversation

@danielpunkass
Copy link
Contributor

…edit

By extension of the fact that getting any individual post yields a forbidden context error when the context=edit and the user is not authorized, the user should also not be permitted to list any post items when unauthorized.

…edit

By extension of the fact that getting any individual post yields a forbidden context error when the context=edit and the user is not authorized, the user should also not be permitted to list any post items when unauthorized.
@rachelbaker
Copy link
Member

@danielpunkass Great catch that we were missing this permission check. I don't know if edit_posts is the correct permission check here, though.

@WP-API/amigos Any suggestions for the permission check we should be using here? I was thinking something like current_user_can( $this->post_type->cap->create_posts );

@danielbachhuber
Copy link
Member

Any suggestions for the permission check we should be using here? I was thinking something like current_user_can( $this->post_type->cap->create_posts );

Why not current_user_can( $this->post_type->cap->edit_posts ); ?

@rachelbaker
Copy link
Member

Why not current_user_can( $this->post_type->cap->edit_posts ); ?

WFM

@danielpunkass
Copy link
Contributor Author

Ah, am I reading this correctly that it would tie the permissions to e.g. whether the user has the ability to edit pages, or a custom post_type? I guess $this->post_type is set as a consequence of the specific endpoint e.g. /posts -> "post", etc? Sounds good to me, I'll update the pull request later tonight probably.

On advice of @rachelbaker and @danielbachhuber, refine the permissions test to require the user has the edit_posts permission for the specific post_type. Also add a unit test to confirm the functionality of allowing the post list to be retrieved when the user does in fact have the editing capability.
…s/WP-API into forbid-edit-context-listing

* 'forbid-edit-context-listing' of github.com:danielpunkass/WP-API:
  Remove trailing / from /posts in the comment.
… with others that may reject on a specific post type.
rachelbaker added a commit that referenced this pull request Jul 22, 2015
Add permission check for retrieving the posts collection in edit context
@rachelbaker rachelbaker merged commit c77302c into WP-API:develop Jul 22, 2015
@rachelbaker
Copy link
Member

Merged #1412

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants