Skip to content
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

Restrict access to extranet pages via REST API #3

Open
HPiirainen opened this issue May 25, 2020 · 0 comments
Open

Restrict access to extranet pages via REST API #3

HPiirainen opened this issue May 25, 2020 · 0 comments

Comments

@HPiirainen
Copy link

Similar to how current floauth_filter_pre_get_posts works. defined( 'REST_REQUEST' ) can be used inside pre_get_posts to detect whether the query is a REST API request.

There are some difficulties though:

  • is_user_logged_in() does not work in pre_get_posts in REST requests as being logged in does not mean user is authenticated
  • is there a way to detect if it's an internal REST request? Implementing restriction for all REST requests would mean extranet pages wouldn't be shown f. ex. in block editor parent page selector

Might also consider simply emptying relevant fields (f. ex. content, excerpt) in the REST responses using rest_prepare_page filter instead of removing the pages from all results. But even this may have some undesired consequences and should be tested. This also does not empty any other fields (f. ex. plugin-specific fields) that might leak restricted content.

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

No branches or pull requests

1 participant