Skip to content

fix: cross-site user management and auth hardening - #195

Open
Kallyan01 wants to merge 25 commits into
mainfrom
fix/user-deletion
Open

Kallyan01 wants to merge 25 commits into
mainfrom
fix/user-deletion

Conversation

@Kallyan01

@Kallyan01 Kallyan01 commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

What

Fixes four defects in cross-site user management: delete requests never reaching brand sites, a fatal error on every brand-site request, an incorrect way of saving passwords and names on user creation, and toast positioning.

Why

Each failed silently or broke a flow outright:

  • Delete user from sites did nothing — the brand-site lookup missed, the brand site rejected the request, and wp_safe_remote_request() refused to send it.
  • Brand sites fatalled on every request: Call to undefined function wp_get_current_user().
  • Create user stored a different password than the admin typed, so the user could never log in;
  • Toasts landed on the left side, out of view.

Related Issue(s):

AI Disclosure

Self + Opus 5.5 for fix testing & validation

Issues Fixed

  • Deleting a user from brand sites did nothing; partial failures were hidden.
  • Brand sites fatalled on every request.
  • Create user, add to sites and role update failed on every site (feat!: Rescaffold and update dependencies. #124 regression).
  • Passwords weren't saved as typed (', ", < broke login); single-word names warned.
  • Per-site and validation errors were never shown.
  • Security: lookalike hosts passed auth, delete could remove the wrong user, and raw HTTP responses leaked to the browser.
  • Pairing lost sub-directory paths and failed on same-host/different-port sites.
  • Toasts were off-screen, overlapped, and cleared all at once.

Behaviour changes

  • Passwords: minimum 8 characters, no \ (as in core).
  • Sites now send X-OneAccess-Site-URL; update governing and brand sites together.

Testing Instructions

Setup: a governing site and a brand site on different URLs (or the wp-env pair: npm run wp-env start → 8888, npm run wp-env:child start → 8890).

Pairing & auth

  1. Settings → Add Brand Site with the brand's URL and API key → health-check passes. On the brand, Settings shows the governing URL (for a sub-directory governing site, the full path is kept).
  2. Load the brand site's /wp-admin/ → no fatal error.
  3. From a terminal, send a health-check to the already-paired brand with its key but a different origin → 401, and the brand's governing URL is unchanged:
    curl -H "X-OneAccess-Token: <brand key>" -H "Origin: https://evil.example" https://<brand>/wp-json/oneaccess/v1/health-check

Create user
4. Manage Users → Create User with password it's a "test" <pw> and a single-word full name → created on the brand. Log in on the brand's wp-login.php with the password exactly as typed.
5. Try a password containing \ → the notice shows "Passwords cannot contain the "" character." (not a generic error). A password under 8 characters is rejected too.

Add to sites / role update (broken on main by #124)
6. Users → User actions → Add to Sites → the user is created on the selected brand site.
7. Users → User actions → Manage Roles → change the role → it changes on the brand site.

Delete
8. Users → User actions → Delete from the brand site → the user is removed there and the row disappears.
9. Partial failure: stop or disconnect one brand site (e.g. change its API key in Settings), then delete a user from two sites → the notice lists the failing site, the other site is deleted, and the list refreshes. In DevTools → Network, the delete-user-from-sites response has no raw HTTP response in error_log.
10. On the brand, create a different user with the same username but another email → deleting the shared user from the governing site leaves that user untouched.

Toasts
11. Trigger one notice, then several at once (e.g. create a user on two sites) → they stack bottom-right without overlapping, and dismissing one doesn't clear the others.

Screenshots

Checklist

  • I have read the Contribution Guidelines.
  • I have read the Development Guidelines.
  • I have added necessary tests to cover my changes.
  • I have updated the project documentation as needed.
  • My code has detailed inline documentation.
  • My code is tested to the best of my abilities.
  • My code passes all lints, tests, and checks.
Open WordPress Playground Preview

Loading
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