Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @jonnydmg. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
jonnydmg
left a comment
There was a problem hiding this comment.
There is a big PR to review. Good work getting this ready for core. This code a little old and some things have changed in core, so this PR needs to update accordingly.
Biggest things.
- We need to support sites with
is_site_meta_supportedfalse. There was some work done there to support it but not complete. - Site endpoint needs to be registered on single site. So it always exists then return an error on single site.
- WP_REST_Site_Meta_Fields has no test coverage at all.
- Single site needs tests.
- Super admin should be allowed to do everything on the endpoint.
- Code coverage and ticket need needs to be added to every test.
This feel like we are on the right track, if I am nitpicing here, becuase I think this good to go into core and just want to get the final bits to push forward into core.
I will wait until feedback is complete to do some real testing for this PR.
jonnydmg
left a comment
There was a problem hiding this comment.
There is a big PR to review. Good work getting this ready for core. This code a little old and some things have changed in core, so this PR needs to update accordingly.
Biggest things.
- We need to support sites with
is_site_meta_supportedfalse. There was some work done there to support it but not complete. - Site endpoint needs to be registered on single site. So it always exists then return an error on single site.
- WP_REST_Site_Meta_Fields has no test coverage at all.
- Single site needs tests.
- Super admin should be allowed to do everything on the endpoint.
- Code coverage and ticket need needs to be added to every test.
This feel like we are on the right track, if I am nitpicing here, becuase I think this good to go into core and just want to get the final bits to push forward into core.
I will wait until feedback is complete to do some real testing for this PR.
Introduces WP_REST_Sites_Controller plus tests. See #40365.
aa03545 to
cc81250
Compare
…and add missing group annotations
spacedmonkey
left a comment
There was a problem hiding this comment.
Here is a PR with some unit test improvements.
This is has unit tests that cover single site as well.
…oint-tests Tests: Add unit tests for WP_REST_Site_Meta_Fields functionality
…oint-more-tests Tests: Rename rest-sites-controller.php to wpRestSitesController.php …
Add format validation for the `domain` and `path` parameters in WP_REST_Sites_Controller so malformed values are rejected with a clean 400 rest_invalid_param instead of failing later inside wp_insert_site()/ wp_update_site() (which surfaces as a 500). domain must be a valid hostname or bare IPv4/IPv6 address, optionally followed by a port (bracketed IPv6 is intentionally not supported, so IPv6 addresses can't carry a port). path must start and end with a forward slash and be made up of characters valid in a URL path segment. Ticket #40365.
…t-check-exists' into feature/40365-rest-sites-endpoint-check-exists # Conflicts: # src/wp-includes/rest-api/endpoints/class-wp-rest-sites-controller.php
…oint-force-delete Enhance site deletion process to support force deletion and user removal
…oint-check-exists Check if domain exists before creating / updating.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Opened a follow-up PR against What it fixes: the This PR adds an optional New PHPUnit coverage is included for the network-id validation and cross-network access behavior on those routes. Both the single-site and multisite 🤖 Generated with Claude Code |
…oint-super-admin Add per-network super-admin scoping to REST sites controller
…oint-v2 Define allow_batch support for site endpoints
REST API: Rename check_domain_is_available() to check_url_is_available()
Hey @Biont, yes, I think we can close #9626. It adds a read-only |
Combines check_network_ids_exist() and check_network_access() into one check_network_ids() method, used consistently across get_items, get_item, create_item, update_item, and delete_item_permissions_check(). Also adds test coverage for delete_item_permissions_check() network validation, which previously had none. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
While reviewing I've opened a fix here: lloc#9 It:
|
…oint-fix REST Sites: Fix network permission checks and add delete permission coverage
spacedmonkey
left a comment
There was a problem hiding this comment.
I have spent a long time testing this and I am happy to say, I am happy to commit. Thanks for all the amazing work @lloc, thanks for getting this one across the line.
peterwilsoncc
left a comment
There was a problem hiding this comment.
While the changes to checking and getting super admins may be helpful for a programmatic API I don't think that querying one network from another via a public API is a security risk.
For example, this current implimentation exposes cross nmetwork sites when no network is specified.
- Install and network enable WP Multi Network
- Create a new network
- Create a new user (
n2admin) - Set n2admin as a super user of the second network
- Log in to the second network as n2admin
- Observe in the dashboard "My Networks" they only have access to network 2
- In the browser console run the command
wp.apiFetch( { 'path': '/wp/v2/sites' } ) - Observe the result contains details for both the network they are super admin of and the network
This is an example of why I made my earlier comment that the network should be inferred from the URL on which the request is being made. It's a security risk but, equally significantly, details of one network should not be made available from another. Doing so breaks the isolation multiple networks are intended to maintain.
That is a bug and sorry that one is me. This commit 959bf3d. I will fix it. Fixed in |
…work filter is provided
…point-current-network Site REST API: Default network id
|
@spacedmonkey @jonnydmg The endpoint just can't allow querying across network, it will introduce data exposure no matter how it's coded up Each network is entirely independent: logins, network activated plugins, mu-plugins can be network specific via One network may hard code super admins via The same will occur if one network filters the Even for sites on the same network, the plugins can differ site-to-site so the endpoint can't be available on sub-sites due to different plugins. This is what I think needs to happen before this can be considered secure enough to commit:
This will ensure that plugins and mu-plugins for the endpoint match what is loaded in the network admin currently. |
Trac ticket: https://core.trac.wordpress.org/ticket/40365
There are some open questions that we should discuss in the trac ticket.