22 Commits
Author SHA1 Message Date
kevinveenbirkenbachandClaude Opus 5.5 8d513b24b8 fix(web-app-wordpress): address the CodeRabbit findings on the OIDC binding
- Check the issuer before the plugin settings are written, so a failed
  deploy never persists an external issuer.
- Fail closed when the administrator already carries a foreign Keycloak id
  under any subject-identity key; name the key, not the value, and say how
  to recover.
- The Playwright spec proves the OIDC login creates no account instead of
  rejecting every existing name-plus-digit account.
- The README's manual binding first unbinds the id from other accounts.

🎯 Fix: 90 %
💥 Break: 7 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 84
🚦 Gate: ⛔ break 7 % > 5 (no live WordPress run yet); make quality-high run 5 green on this tree

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:43:30 +00:00
kevinveenbirkenbachandClaude Opus 5.5 9e33a351ea fix(web-app-wordpress): fail closed on a foreign subject identity on the administrator
get_user_by_identity (client-wrapper L864-893 in plugin 3.11.4) finds an
account by the user meta openid-connect-generic-subject-identity OR by
<blog_prefix>openid-connect-generic-subject-identity. The bind wrote only
the unprefixed key on the administrator, and the final check listed only
the holders of the administrator's own sub. A prefixed entry with a
different sub on the administrator account therefore survived every
deploy, and a sign-in with that other sub landed on the platform
administrator. 3.11.4 itself writes only the global key (L1297); older
plugin versions or a manual edit can leave a prefixed one.

The deploy now lists the administrator's meta keys (names only, so no
token values are read), then reads the values of the unprefixed key and
of every key ending in openid-connect-generic-subject-identity through
wp user meta list --keys. It fails unless every value is the
administrator's Keycloak id and the unprefixed key holds it. Nothing is
deleted: a foreign identity on the administrator is never legitimate, so
the operator sees it instead of the deploy erasing the evidence. The
unbind loop and the final owner check now compare the administrator's
login case-insensitively; WordPress cannot hold two logins that differ
only in case, so the match can only hit the administrator.

Review follow-up (CodeRabbit on #2094):

- The bind reads the administrator's id from the local Keycloak, but
  OIDC_OVERRIDE.URL and the OIDC_OVERRIDE.CLIENT endpoints can point
  WordPress at another issuer. That issuer sends a different sub, so the
  bind either waits on a Keycloak container that is not there or stores
  an id no token ever carries, and the administrator's next sign-in
  creates <name>2. An assert before the Keycloak lookup now fails the
  deploy unless ISSUER_URL is the local Keycloak realm and TOKEN_URL
  lives under it. Skipping the bind instead would leave the same
  lockout and the same <name>2 account, so failing closed is the only
  safe choice. No shipped inventory sets OIDC_OVERRIDE.URL.
- The holder listing matched only the global key, so an account holding
  the administrator's id only under a site-prefixed key was never
  unbound and the final check failed every deploy. The listing now uses
  --meta_compare_key=LIKE across all sites. Per holder the deploy reads
  the key names, then the values of the subject-identity keys, and the
  new oidc_subject_strays filter yields one (account, key) pair per key
  whose value is the administrator's id. The unbind deletes the value
  under exactly that key. No SQL is built; the sub is passed quoted to
  wp-cli. The final LIKE owner check stays.
- The settings test also asserts identify_with_username is false, next
  to the email_format and link_existing_users checks.

Live deploy follow-up: kcadm's JVM writes cgroup warnings such as
"[0.001s][warning][os,container] Cgroup memory controller path ..." to
stdout before the JSON list on nested DinD and CI hosts. keycloak_user_id
parsed stdout with a plain json.loads, so the bind failed with "kcadm
printed no JSON user list (Expecting ',' delimiter: line 1 column 7
(char 6))". The filter now parses through json_from_noisy_stdout from
utils/kcadm_json.py, the helper web-app-keycloak's kcadm_json filter
uses, imported from utils like the role's other filters. A non-list
result is still refused.

The Playwright specs now check identity, not only the URL. The addon
spec asserts that profile.php shows the administrator's user_login after
the OIDC round-trip, and that users.php (network users.php on multisite)
lists the administrator and no account named after it plus a digit, the
name the plugin gives a duplicate when the bind is broken. The users.php
locator is '#the-list .column-username strong a': WordPress 7.1.4
renders the primary column as th scope=row (class-wp-list-table.php
L1838), so a td-only locator never matches. The RBAC test asserts that
biber's row on users.php shows the email Keycloak stores for biber, read
through a new keycloakUserEmail helper, and not the literal "email" that
the unbraced email_format produced on main.

Evidence: test_oidc_account_linking.py passes 15 tests and 23 subtests,
test_oidc_subject_strays.py 4 tests, test_keycloak_user_id.py 7 tests,
including two JVM warning lines in front of the user list. Against the
old json.loads parser that test fails with the deploy's exact error.
Negative controls on a copy of the tree: without the issuer assert the
4-row issuer truth table and the ordering test fail; with the listing
and the filter reduced to the global key, the holder listing test, the
exact-key unbind test and the filter pairing test fail; with
identify_with_username true the settings test fails.

Live compose deploys on a nested stack (proofs 2, 3 and 7): the bind
stores the Keycloak id, both administrator asserts pass, and an
idempotent rerun skips the unbind loop. Control A (a foreign account
holding the administrator's id under the unprefixed key) and control B
(the same under a wp_2_ prefixed key) are unbound, and the role goes
green. The fail-open control (a foreign id under a wp_2_ key on the
administrator) fails closed at the identity assert, before any unbind.
Live probes: platformadmin keeps the administrator role, users.php
lists exactly one platformadmin and no platformadmin2, and
test-admin-oidc-login.js and test-rbac-roles.js pass. The users.php
assertion failed 3 of 3 tries in proofs 2, 3 and 7 with the old
td.column-username locator, which is the negative control for the
locator fix; the corrected locator is proven by CI on this pull request.

Remaining: an administrator account carrying a foreign prefixed identity
fails the deploy until the operator deletes that key. A deployment that
signs WordPress in against an external issuer now fails until the
override or the addon is dropped. An account holding the id only under a
key that contains, but does not end in, the subject-identity name is not
unbound and fails the final check. The corrected users.php locator and
the network users.php path are not yet proven on a live stack.

🎯 Fix: 93 %
💥 Break: 4 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 89
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 16:09:20 +00:00
kevinveenbirkenbachandClaude Opus 5.5 680024ec36 fix(web-app-wordpress): bind admin by Keycloak id, stop email linking
cf313adf64 let the OIDC plugin link an existing account by a verified
email match. In plugin 3.11.4, validate_existing_user_link sets
$can_replace = ! $by_username && true === $email_verified
(client-wrapper L1356), so a verified email match also replaces the
Keycloak identity an account is already bound to. A new Keycloak user
holding a reused address could take that account over.

link_existing_users is now false. A sign-in finds an account only by the
sub claim stored in the user meta openid-connect-generic-subject-identity
(get_user_by_identity, L864-880). create_if_does_not_exist stays on: a
sign-in without a bound account creates one. An email that already
belongs to an account fails closed, wp_insert_user refuses it with
existing_user_email. A user name that is already taken does not fail:
the plugin creates the account under the next free name, <name>2
(L1268-1272). The email_format "{email}" fix stays.

Every deploy binds the install administrator. On the stack host it reads
the Keycloak user with the administrator's exact user name through the
admin API, with the admin credentials of the Keycloak container itself
(kcadm, as the OpenTalk and Mattermost roles reach Keycloak), and writes
its id with wp user meta update. The keycloak_user_id filter refuses
output that is no JSON list and anything but exactly one match. The id
is the sub WordPress receives: get_subject_identity returns the ID token
sub (plugin client L1048), the default client in realm.json.j2 carries
no protocol mapper, and no scope maps a claim named sub; the only sub
mapper is Keycloak's oidc-sub-mapper in the basic scope.

The bind is exclusive. get_user_by_identity returns the first account by
login when several hold the same sub, so the deploy then lists every
account holding the id across the network, deletes the meta from each
one except the administrator (one changed loop item per unbound login in
the deploy log), and fails unless the administrator alone holds the id
under any key ending in openid-connect-generic-subject-identity, which
covers the blog-prefixed keys the lookup also reads. The settings task
moved into the stack-host file, so the addon entry is one gated include
like the other addons.

Evidence: test_oidc_account_linking.py renders the settings map the
config lookup hands WordPress and checks link_existing_users false,
create_if_does_not_exist true and the email format; it checks the full
kcadm query (-r "$1" -q username="$2" -q exact=true with realm and user
name in that order), the stored id, the holder listing, that the unbind
loop targets every holder but the administrator, and that the final
check fails on another owner, on no owner and on a failed command.
Negative controls on a copy of the tree: removing the unbind task, the
final check, swapping $1 and $2, and turning linking on fail exactly
their four tests; keeping the administrator in the loop, dropping
exact=true and reducing the check to the exit code fail their three.
test_keycloak_user_id.py covers the exact match among look-alikes, case,
no match, two matches, an empty id and non-JSON output.

Remaining: WordPress users that existed before and were never bound can
no longer link themselves; an administrator binds them by setting the
user meta (README, C1 proposal). An account that holds the
administrator's id only under a blog-prefixed key is not cleaned
automatically; the deploy fails and names it. No deploy has proven the
login or the cleanup end to end.

Gate: the local quality-high gate has not run; CI runs it on the pull
request. The MEDUSA scan against e0f751eb4e is 100 over 13 files with
no finding.

🎯 Fix: 85 %
💥 Break: 12 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 75
🚦 Gate: ⛔ fix 85 % < 90, break 12 % > 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:38:53 +00:00
kevinveenbirkenbachandClaude Opus 5.5 cf313adf64 fix(web-app-wordpress): link OIDC accounts by verified email
Main run 43828138456 failed WordPress#0 (swarm, onion) and WordPress#3
(compose), and PR 2074 WordPress#0 failed the same way. Every addon spec
that signs in through wpAdminLoginViaOidc landed on
wp-login.php?login-error=link-requires-verified-email after the Keycloak
round trip.

Root cause: the unpinned daggerhart-openid-connect-generic plugin
installed 3.11.4 (released 2026-11-16). Its new validate_existing_user_link
refuses any link by user name unless link_unverified_users is set, and
ignores email_verified on that path. The role linked by user name
(identify_with_username: true), so the install administrator could no
longer be linked. Keycloak already sends email_verified=true for the
administrator: the job log shows "updated platformadmin" from
email_verified.py.

Fix: link existing accounts by email (identify_with_username: false).
3.11.4 accepts that link only when the claim says email_verified=true.
email_format also rendered the literal "email" instead of the claim
placeholder, so it could never match an account. It now renders to
"{email}". link_existing_users stays on and the verified-email check is
not disabled.

Evidence: the plugin source of tags 3.11.4 and 3.11.3 on
plugins.svn.wordpress.org, and the job logs of run 43828138456.
test_oidc_account_linking.py checks the rendered email_format against
the email claim name in Keycloak's realm.json.j2. It fails on the base
commit ('email' != '{email}') and passes with this change.

Remaining risk: in 3.11.4 a verified email match can re-link a WordPress
account that is already bound to another Keycloak identity. The legacy
host follow-ups are in the C1 proposal.

Gate: quality-high-257 was cancelled on the operator's order (MEDUSA
scans first), so the local gate has not run. CI runs it on the pull
request. The MEDUSA scan is done at 100. No deploy has proven the admin
login end to end.

🎯 Fix: 85 %
💥 Break: 6 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 80
🚦 Gate: ⛔ fix 85 % < 90, break 6 % > 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:32:46 +00:00
kevinveenbirkenbach 989cd45f56 Merge branch 'fix/codescan/cyclic-imports' into fix/codescan/python-hygiene
# Conflicts:
#	cli/administration/deploy/development/down.py
#	cli/administration/deploy/development/inventory/__init__.py
#	tests/unit/python/utils/cache/test_base.py
#	tests/unit/python/utils/cache/test_data.py
2026-11-13 20:13:12 +00:00
kevinveenbirkenbachandClaude Opus 5.5 357eb3bd32 fix(codescan): break the runtime import cycles CodeQL reports and lint new ones
CodeQL py/cyclic-import alerts #1023-#1029 and #1112-#1113 map to three cycles: utils.inventory.tools <-> libretranslate, utils.env.builder <-> its handlers, and utils.roles.applications.variants <-> the inventory legacy resolver. Each cycle loaded only because one side deferred an import into a function body. The shared piece now lives in a leaf module both sides import: utils/inventory/tools_vars.py, utils/env/context.py (BuildContext, EnvBuilder), and _resolve_round_include inside variants.py. The stricter lint found four more cycles, each broken the same way: compose <-> down (cli/administration/deploy/development/docker_root.py), the utils.cache package web (utils/cache/reset.py), utils.cache.carrier <-> users (utils/cache/tokens.py replaces users/store.py) and credentials -> provision (cli/administration/inventory/ruamel_io.py).

tests/lint/repository/python/test_import_cycles.py fails on any runtime import cycle between the repository's own modules. It counts TYPE_CHECKING imports and implied parent-package edges, and skips only __main__ blocks and submodule-to-parent reads. Negative control: 3 of the 11 self-tests fail on the old logic. Whole repository: 12 passed. Targeted tests of every touched module: 4275 passed.

Accepted security findings: 78 medusa findings, all on lines that exist verbatim in base 28d05e0183. They come from code moved unchanged into docker_root.py, tools_vars.py and tokens.py, or from untouched lines of touched files (compose.py, credentials_generator.py, credentials/reset/cli.py, users/__init__.py, yaml.py). Reviewed as by design or false positive: argv-list subprocess calls, dev docker-root teardown, NotASecret test-lane keys, SafeLoader yaml.load, md5 memo key, Jinja expression strings.

🎯 Fix: 90 %
💥 Break: 5 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 86
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:07:50 +00:00
kevinveenbirkenbachandClaude Opus 5.5 326f063bd3 fix(codescan): clear the mechanical CodeQL notes and lint them away (WIP)
Work-in-progress commit on the collective code-scanning sidetree, so main
can be merged in; the single quality-high gate runs on the integration
branch before the pull request.

Fixes the CodeQL notes py/import-and-import-from, py/unused-import,
py/unused-global-variable, py/empty-except, py/mixed-tuple-returns and
py/unused-local-variable across 194 files, and adds one lint per rule under
tests/lint/repository/python/ so none of them can come back:
test_import_and_import_from, test_unused_imports_hidden_from_ruff,
test_unused_global_variables, test_empty_except, test_mixed_tuple_returns,
test_unused_local_variables, plus test_modules_import.

Accepted security finding: MEDUSA-MP-SCAN-2056 (low) on
utils/i18n/client.py:21, an import line matched by a keyword heuristic;
operator-confirmed false positive.

🎯 Fix: 85 %
💥 Break: 8 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 78
🚦 Gate: ⛔ fix 85 % < 90, break 8 % > 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:44:29 +00:00
kevinveenbirkenbachandClaude Opus 5.5 268b2a46f9 feat(web-app-wordpress): set admin_email, blogname and the FreedomTranslate options through the options map
WORDPRESS_OPTIONS now merges the role's own contributions (admin_email from the platform administrator, blogname from the design title while the design service is on, the freedomtranslate-wp config.options while that addon is on) under services.wordpress.options, so the inventory still wins and wordpress_options_checked guards the merged map. design.php no longer writes blogname, the addon task no longer writes its options, and WORDPRESS_OPTIONS_OWNED_ELSEWHERE drops the three. Every deploy now converges admin_email, and blogname while the design is on; a write WP-CLI reports as unchanged no longer counts as a change, and the FreedomTranslate readback runs after the options write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 12:53:11 +01:00
kevinveenbirkenbachandClaude Opus 5.5 c3e2114e91 Merge branch 'fix/web-app-wordpress/permalink-options' into feature/store-i18n
Conflicts resolved: the inventory validator keeps store-i18n's custom-role
declaration skip and gains the open-subtree check; the suppression catalogue
keeps both new rows; WORDPRESS_PERMALINK_STRUCTURE gives way to the options
map. WORDPRESS_OPTIONS_OWNED_ELSEWHERE also lists the store-i18n writers the
merge brought along: the design logos (WORDPRESS_DESIGN_LOGOS keys) and the
freedomtranslate options; two custom-role validator tests pass open_paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 11:35:18 +01:00
kevinveenbirkenbachandClaude Opus 5.5 46e0bd1367 feat(web-app-wordpress): manage WordPress options from services.yml and pin the old permalink structure
Deploys since 197d74416d rewrote the blog's permalink structure to
/%postname%/, so links of the form /blog/YYYY/MM/DD/<slug>/ answer 404
(docs/security/user.md:24 fails the URL check).

services.wordpress.options maps WordPress option names to values; the role
reads each option, writes only the ones that drift and flushes the rewrite
rules after a write. permalink_structure is pinned to
/blog/%year%/%monthnum%/%day%/%postname%/, the value WordPress itself sets
for a subdirectory network. A guard refuses options the role writes
elsewhere, secret-named keys and values WordPress would not read back
unchanged.

The inventory validator accepts any child key under a services.yml key that
carries '# nocheck: inventory-open-subtree <reason>'; services.wordpress.options
carries it, everything else stays strict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 11:30:31 +01:00
kevinveenbirkenbachandClaude Opus 5.5 22614627d5 test(objstore): read web-app-wordpress meta through ROLE_FILE_META_SERVICES
test_s3_public_url.py built roles/web-app-wordpress/meta/services.yml with a pathlib chain, which TestRoleFileSpot rejects in favour of the utils.roles.mapping constant (quality-high run 6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 22:19:46 +01:00
kevinveenbirkenbachandClaude Opus 5.5 f287322065 fix(objstore): serve public bucket files same-origin on every vhost of the consumer
WordPress put objstore.public_url, the clearnet api.seaweedfs.s3 host, into S3_UPLOADS_BUCKET_URL, so the onion pass of WordPress#0 (CI run 40979252521) loaded the site logo from clearnet and the leak spec failed; the /objstore rebase only fired on onion-only consumers and never on a multi-network node. lookup('objstore', app, 'relative_url') now returns /_infinito/objstore/<bucket> for a shared consumer with a public bucket and an API domain, and locations.conf.j2 serves that path on every vhost of the consumer, clearnet and onion alike, by proxying over the loopback to the provider's own vhost.

The route passes GET and HEAD only, answers 404 for a path ending in / (no ListObjects), drops the query string (no S3 subresources or presigned queries) and the Authorization and Cookie headers, so only the public bucket's anonymous read applies, and adds nosniff plus a sandbox CSP; private and embedded buckets get no route. Only web-app-wordpress switches to relative_url: mastodon, pixelfed, baserow, bookwyrm, snipe-it, listmonk, mediawiki, shopware and peertube need absolute URLs for federation, mail or server-side rendering, and decidim and funkwhale sign URLs, which the route deliberately refuses. The prefix moves from /objstore to /_infinito/objstore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 21:52:35 +01:00
kevinveenbirkenbach 9c7b615743 Merge branch 'triage/wordpress1' into integration/store-i18n-merge 2026-10-30 19:33:38 +01:00
kevinveenbirkenbachandClaude Opus 5.5 b5736bda44 feat(web-app-wordpress): serve each multisite site on its own network sibling
CI run 40979252521 WordPress#1 (multisite, multi network): a request on a network sibling resolved to the clearnet site, because WordPress picks the site by Host before any mu-plugin runs and the network kept only clearnet base URLs per site. Operator decision: a real multisite per network with real child domains (option B).

infinito-network-origins.php is now also installed as wp-content/sunrise.php (SUNRISE=true), so the sibling host resolves to its own site before mu-plugins load; a guard constant stops the second load from mu-plugins. WORDPRESS_SITE_DOMAINS holds the canonical domains in the first domain's network, WORDPRESS_NETWORK_BASE_URLS carries every sibling of each site's base URL (sites ';', siblings ','), and INFINITO_NETWORK_BASE_URLS takes that list. Child sites are inserted by files/php/multisite/sites.php only where no site exists on the domain and path, replacing wp site list plus wp site create. The multisite variant's child domains move from server.domains to domains.canonical.

Covered by 29 Python tests and two PHPUnit suites; PHPUnit and a variant 1 deploy with an onion pass still have to run (store-i18n gate and deploy).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 18:49:33 +01:00
kevinveenbirkenbachandClaude Opus 5.5 55604ca19c fix(web-app-wordpress): load the editor canvas design tokens from the page's own origin
CI run 40979252521 WordPress#0 (swarm, variant 0, onion pick): the block editor canvas stayed transparent (rgba(0, 0, 0, 0) instead of --design-surface-1). The trace shows the canvas iframe requesting https://cdn.main.infinito.test/_shared/css/default.css and the onion page's CSP (style-src-elem 'self' http://cdn.<onion> ...) blocking it; the clearnet pass of the same spec was green. design.php writes WORDPRESS_DESIGN_CONFIG.tokens into the infinito_design option once for every network sibling, so an absolute CDN host pins the onion editor to clearnet.

The token sheet now uses the cdn lookup's relative_urls, rendering /_infinito/cdn/_shared/css/default.css. WordPress prefixes a relative style source with site_url(), which infinito-network-origins derives from the request host, and every generic vhost serves /_infinito/cdn/ (basic.conf.j2 includes cdn.conf.j2), so the canvas loads from the page's origin on both networks. Same approach as the Joomla TinyMCE fix 175e00218f. test_design_tokens.py renders the tokens through the real cdn lookup and fails on the old URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 18:04:11 +01:00
kevinveenbirkenbachandClaude Opus 5.5 2e1ea3e9cc test(web-app-wordpress): reach meta/users.yml through ROLE_FILE_META_USERS
test_role_files_are_referenced_via_spot flagged
test_multisite_usernames.py:13 for spelling the role file path
"roles/web-app-wordpress/meta/users.yml" literally. The test now joins
the role directory with ROLE_FILE_META_USERS from utils.roles.mapping,
which resolves to the same path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 22:11:52 +01:00
kevinveenbirkenbachandClaude Opus 5.5 6df5f2be86 fix(web-app-wordpress): give the MCP subscriber a login multisite accepts
On a multisite network WP-CLI's `user create` runs
wpmu_validate_user_signup(), which only accepts lowercase letters and
digits. The MCP subscriber was declared as `mcp-wordpress`, so every
variant with `multisite.enabled: true` (variant 1) stopped at "Create the
subscriber the MCP adapter authenticates as" with "Usernames can only
contain lowercase letters (a-z) and numbers." (WordPress#1 in runs
40625679270 and 40243434327).

meta/users.yml now declares `mcpwordpress`. The users dict is the one
place the login lives: the role tasks, the MCP basic-auth login
(mcp_client_login) and the MCP client configs (mcp_servers) all read
users[owner].username, and the owner key, hence the token-store key,
stays mcp-web-app-wordpress. The email follows the login.

On an existing single-site install the next deploy creates mcpwordpress,
mints its application password and replaces the stored token; the old
mcp-wordpress subscriber is left in place with its now untracked "mcp"
application password. Remove it with `wp user delete mcp-wordpress`.

test_multisite_usernames mirrors the multisite signup checks (charset,
reserved names, 4-60 characters, not all digits): every account the role
declares passes, and mcp-wordpress, `_`, `.`, uppercase, too short, all
digits, admin and too long are refused. With the old login the test
fails with WordPress's own message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 21:27:36 +01:00
kevinveenbirkenbachandClaude Opus 5 39d8de790b test(web-app-wordpress): cover the OIDC payload instead of exempting it
Two lint suppressions shipped with the multisite OIDC work. Both are replaced
by the thing they were standing in for.

settings.php claimed an exemption from the mirrored-test rule because every
call it makes belongs to the WordPress runtime. The six functions stub in a
few lines, so the claim does not hold. SettingsTest.php declares WP_CLI and
the globals over a state holder and includes the real payload per case:

  * a single site is written without switching blogs
  * every site of a network is written, switch_to_blog paired with restore
  * a site whose write does not persist is named by blog id
  * every site is still visited before that failure is reported
  * a payload that is not a map halts, and so does an absent one

The fourth case is the one worth having: a `break` on the first failure would
pass the other three and silently stop writing.

Neither existing house pattern fits. `eval` suits the tag-less tinker snippet
of web-app-akaunting, `proc_open` the standalone script of web-app-joomla;
this is a tagged file that needs a runtime, so it is stubs plus `include`,
which also avoids the `nocheck: eval` the akaunting test carries.

The installer test's cache-read exemption rested on a cached read serving a
stale call log. Measured, that risk is confined to the suite and sits around
3e-13: the log lives in a fresh TemporaryDirectory per run, mkdtemp verifies
non-existence, and each path is read once. What complying actually costs is
roughly 25 dead entries in an 8192-slot LRU, so the read goes through
utils.cache.files.read_text.

Proven by `make test-unit-php`: 32 tests, 68 assertions. The first version of
this test passed nothing at all -- it sits one directory deeper than the
other PHP tests, so dirname(__DIR__, 6) resolved to tests/ and the include
found no file. Without the test that would have stayed invisible.

The suite drives stubs, so it proves the payload's control flow and not that
WordPress behaves as stubbed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-06 22:54:27 +02:00
kevinveenbirkenbachandClaude Opus 5 4ba57c1fce fix(web-app-wordpress): activate plugins across a multisite network
A Multisite subsite served `/wp-login.php` with no SSO entry point even once
the OIDC settings reached every site (e1901fb88e), because the plugin was
never running there:

    wp plugin activate <name> --path=<docroot>

Without `--network` that activates the main site only, so a subsite had the
settings and no plugin. `--network` appears on no branch of this repository,
so the gap was everywhere.

`services.wordpress.multisite.enabled` now resolves once, in vars/main.yml,
and feeds the activation, the multisite conversion gate and playwright.env.j2,
which until now recomputed the same lookup inline. The conversion gate also
drops a `| default(false)` on a key meta/services.yml always declares.

The installer moves out of Ansible into files/shell/install_plugin.sh. Eight
tasks interlocking through register/when/until/failed_when read as one linear
script, and the contract arrives as environment assignments. The container
address stays an inline shell assignment rather than an `environment:` entry
because in swarm it is the literal text `"$(resolve-container-id ...)"`, which
only the shell evaluates; the body streams over stdin because swarm workers
carry no role checkout (03ed52eea5).

Moving the logic across languages would have dropped the WP-CLI 255 contract
to shellcheck coverage, since the suite has no shell tests. The unit suite
therefore now drives the real script against a stubbed `container` wrapper
instead of evaluating the task file's `when:` expressions, which exercises the
behaviour rather than the text describing it.

A mutation pass over that suite -- eight mutations, each required to turn its
own guard red -- found two defects before any deploy:

  * `set -e` is suspended inside an `if` condition, so a probe folded into
    `if needs_install; then` turned an unreadable version into "nothing to
    do". The version read is now a standalone call that aborts with 67.
  * a bare `return` propagates the status of the preceding test, so
    `[ -n "$WP_PINNED_VERSION" ] || return` aborted the script whenever an
    unpinned plugin was already present -- the path every redeploy takes.

The second hid behind a vacuously passing check, which is why the suite gained
exit-code assertions where it previously only counted calls.

This commit carries a fix and a refactor together. The `--network` fix lives
inside the extracted script's activate(), so separating them would mean
reverting the extraction, committing the flag, and reapplying it.

No deploy has run any of this, in compose or in swarm.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-06 21:00:44 +02:00
kevinveenbirkenbachandClaude Opus 5.5 52fe3c9c2c style: apply make autoformat to the merged Stalwart and Tor files
Formatter output only: the parsed YAML and the Python AST of every touched file equal their previous versions.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-03 19:57:30 +02:00
Alejandro Roman a390fea9e9 fix(swarm-stalwart): fix CI issues, cmments mapache 2026-09-28 18:23:16 +04:00
kevinveenbirkenbachandClaude Opus 5 604843bb87 fix(wordpress): refuse an MCP request the site cannot attribute to a user
The mu-plugin header describes the split as 'the adapter authorises the transport, the callback authorises the operation'. The second half held, every ability carries infinito_mcp_may_read. The first did not: the adapter answered the initialize handshake to anyone, so the server and its protocol version were readable without a credential.

Measured in run 34653754175, the swarm WordPress#0: test-mcp-guest.js posts an anonymous initialize and expects at least 400, and the error context reads 'Expected: >= 400, Received: 200'. Its neighbour addons/mcp-adapter.spec.js posts an anonymous tools/list and passed, so the tool call was already refused and only the handshake was not.

The filter hangs on rest_pre_dispatch and refuses every route under the mcp namespace while the site cannot attribute the request. It leaves an already short-circuited response alone rather than overwriting it, scopes itself by route prefix so the rest of the REST API stays as open as it was, and reaches is_user_logged_in, which triggers determine_current_user and with it wp_validate_application_password, so a client presenting its application password passes. A WP_Error renders no jsonrpc key, which is the second thing the spec asserts.

The new unit test reads the guarded prefix out of the PHP and the endpoint out of the spec and requires the endpoint to sit under the prefix. Without it an adapter that moves namespace would leave the guard protecting nothing while both negative specs keep passing.

A positive spec was tried and reverted: handing the MCP credential to the Playwright env is forbidden by tests/lint/ansible/services/test_mcp_secret_not_in_playwright.py, because the trace travels in the CI artifact. No role probes its MCP endpoint with the credential at deploy time either, so the authenticated direction stays unproven.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 09:54:28 +02:00