mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-29 06:17:25 +00:00
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>
This commit is contained in:
1 parent
e0f751eb4e
commit
cf313adf64
3 files changed
+56
-2
No files matched your search
@@ -66,6 +66,8 @@ the unified addon contract. The OIDC and WP-Discourse runtime config lives in ea
|
||||
| `s3-uploads` | `plugin` | enabled with the `seaweedfs` service | none |
|
||||
| `infinito-s3-uploads` | `mu_plugin` | enabled with the `seaweedfs` service | none |
|
||||
|
||||
The OIDC plugin links a Keycloak sign-in to an existing WordPress account by its email, and only when the claim carries `email_verified: true`.
|
||||
|
||||
The OIDC login + RBAC paths are covered by `test-admin-oidc-login.js` /
|
||||
`test-rbac-roles.js`, the Discourse round-trip by `test-discourse-roundtrip.js`.
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ config:
|
||||
http_request_timeout: 5
|
||||
identity_key: "{{ OIDC.ATTRIBUTES.USERNAME }}"
|
||||
nickname_key: "{{ OIDC.ATTRIBUTES.USERNAME }}"
|
||||
email_format: "{{ OIDC.ATTRIBUTES.EMAIL }}"
|
||||
email_format: "{{ '{' ~ OIDC.ATTRIBUTES.EMAIL ~ '}' }}"
|
||||
displayname_format: "{{ OIDC.ATTRIBUTES.GIVEN_NAME }} {{ OIDC.ATTRIBUTES.FAMILY_NAME }}"
|
||||
identify_with_username: true
|
||||
identify_with_username: false
|
||||
state_time_limit: 180
|
||||
@@ -0,0 +1,52 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import unittest
|
||||
|
||||
from ansible.parsing.dataloader import DataLoader
|
||||
from ansible.template import Templar
|
||||
|
||||
from utils.cache.base import _render_with_templar
|
||||
from utils.cache.files import read_text
|
||||
from utils.cache.yaml import load_yaml_any
|
||||
|
||||
from . import PROJECT_ROOT
|
||||
|
||||
ADDON = (
|
||||
PROJECT_ROOT
|
||||
/ "roles/web-app-wordpress/meta/addons/daggerhart-openid-connect-generic.yml"
|
||||
)
|
||||
REALM = PROJECT_ROOT / "roles/web-app-keycloak/templates/import/realm.json.j2"
|
||||
OIDC_VARS = PROJECT_ROOT / "group_vars/all/11_oidc.yml"
|
||||
EMAIL_CLAIM = re.compile(
|
||||
r'"user\.attribute":\s*"email",[^{}]*?"claim\.name":\s*"(?P<claim>[^"]+)"'
|
||||
)
|
||||
|
||||
|
||||
def _email_format() -> str:
|
||||
addon = load_yaml_any(str(ADDON), default_if_missing={})
|
||||
attributes = load_yaml_any(str(OIDC_VARS), default_if_missing={})["defaults_oidc"][
|
||||
"ATTRIBUTES"
|
||||
]
|
||||
return str(
|
||||
_render_with_templar(
|
||||
addon["config"]["oidc_settings"]["email_format"],
|
||||
templar=Templar(loader=DataLoader(), variables={}),
|
||||
variables={"OIDC": {"ATTRIBUTES": attributes}},
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def _email_claim_keycloak_emits() -> str:
|
||||
match = EMAIL_CLAIM.search(read_text(str(REALM)))
|
||||
assert match, f"{REALM} must map the email user attribute to a claim"
|
||||
return match.group("claim")
|
||||
|
||||
|
||||
class TestOidcEmailFormat(unittest.TestCase):
|
||||
def test_the_email_format_reads_the_claim_keycloak_emits(self):
|
||||
self.assertEqual(_email_format(), "{" + _email_claim_keycloak_emits() + "}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user