IB-2: bind locale context across integrated login - #28
Open
xrpbanks wants to merge 3 commits into
Open
Conversation
Correct the CalorieApp login matrix contract identifier and lock it with a contract assertion.
No file content changes; preserve the reviewed tree.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR carries a single canonical locale through the full CalorieApp ↔ WordPress Identity Bridge ↔ embedded iframe login transaction by binding locale to the short-lived backend login state, propagating it across each step, and rejecting mixed state/locale authorization before issuing an authorization code.
Changes:
- Backend: accept/resolve locale at login start, persist it alongside the hashed login state, and return locale in start/state-validate/callback/status responses (and in the WordPress authorize redirect URL).
- WordPress plugin + embed bridge: resolve locale for
[calorieapp_embed]and integrated-login endpoints, include locale in iframe query + postMessage payloads, and enforce locale consistency checks. - Contracts/tests: add a frozen login test matrix contract and expand PHP/Python/Node tests to cover locale propagation and mismatch rejection.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| wordpress-plugins/calorieapp-identity-bridge/tests/test-integrated-login.php | Extends integrated-login tests to assert locale is returned/propagated and aliases resolve to canonical tags. |
| wordpress-plugins/calorieapp-identity-bridge/tests/test-identity-bridge-rest.php | Adds locale assertions to authorize flow and a mismatch-rejection test. |
| wordpress-plugins/calorieapp-identity-bridge/TESTING.md | Updates documented scenario coverage to include locale propagation/matrix coverage. |
| wordpress-plugins/calorieapp-identity-bridge/README.md | Documents locale binding behavior and shortcode locale overrides for previews. |
| wordpress-plugins/calorieapp-identity-bridge/includes/class-calorieapp-identity-bridge-rest.php | Adds optional locale to authorize, validates state locale from backend, and returns locale in authorize response. |
| wordpress-plugins/calorieapp-identity-bridge/includes/class-calorieapp-identity-bridge-integrated-login.php | Resolves locale for embeds/flows and enforces locale consistency through integrated login endpoints. |
| wordpress-plugins/calorieapp-identity-bridge/includes/class-calorieapp-identity-bridge-browser-authorize.php | Propagates locale from browser authorize requests into authorization. |
| wordpress-plugins/calorieapp-identity-bridge/assets/calorieapp-embed.js | Threads locale through iframe messages and REST calls; rejects mismatched locale contexts. |
| tools/tests/xaman_login_start_retry.test.mjs | Updates Node tests to ensure start-login retries consistently transmit locale. |
| tools/tests/test_identity_contracts.py | Adds contract assertions for the login matrix (locales + required context fields + scenarios). |
| tools/tests/calorieapp_embed_readiness.test.mjs | Extends embed readiness test to assert locale is carried through start/finish/authorize messaging. |
| frontend/components/XamanLoginPanel.tsx | Resolves initial locale, sends locale through embedded bridge messages, and enforces locale consistency across login phases. |
| contracts/identity-bridge/v1/README.md | Documents the locale-binding invariant for the identity bridge contract. |
| contracts/identity-bridge/v1/login-test-matrix.json | Introduces the frozen eleven-locale login/failure-path matrix contract artifact. |
| backend/tests/test_identity.py | Adds coverage for state-hash ↔ locale binding and cleanup behavior. |
| backend/tests/test_identity_endpoints.py | Adds endpoint-level tests for locale negotiation, propagation, and inclusion in relevant responses. |
| backend/app/services/identity.py | Persists state-bound locale and provides lookup/cleanup helpers. |
| backend/app/schemas.py | Adds request/response schema fields to carry locale through identity endpoints. |
| backend/app/models.py | Introduces the pendingloginlocale table to bind locale to hashed login state. |
| backend/app/main.py | Resolves locale at login start, includes locale in WordPress sign-in URL, and returns locale across validate/callback/status. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+415
to
+423
| $flow_locale = LocaleRegistry::resolve((string) ($flow['locale'] ?? 'en')); | ||
| $requested_locale = LocaleRegistry::resolve((string) $request->get_param('locale')); | ||
| if (!hash_equals($flow_locale, $requested_locale)) { | ||
| return new WP_Error( | ||
| 'locale_mismatch', | ||
| 'This sign-in flow is bound to another language context.', | ||
| ['status' => 409] | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Outcome
Carries one canonical locale through the CalorieApp / WordPress / Xaman login transaction and rejects state/locale mixing before an authorization code is issued.
Scope
[calorieapp_embed], with an optional locale attribute for controlled previewscalorieapp.identity-bridge-login-test-matrixand locks that identifier with a contract assertionCurrent reviewed state
mainat8d1e30f44db671e960e190f517489bcb88164c604be9e99ac566ef38cf85fc967d7a9e6e78a3ddacd257a150793b64d1092b370f6764ebdc50985312+582/-48; no scope drift after restack36ba4c8is the non-force merge commit with parents old IB-2: bind locale context across integrated login #28 head6c5466cand mergedmain;4be9e99is an empty synchronization commit with the identical tree, used only because retargeting the base did not itself emit the required Actions eventAutomated verification
4be9e99Deliberately excluded
PR #27 is merged. This PR is retargeted to
main, remains draft and still requires human review plus a separate merge GO.