Skip to content

IB-2: bind locale context across integrated login - #28

Open
xrpbanks wants to merge 3 commits into
mainfrom
feature/identity-bridge-v1-ib2
Open

IB-2: bind locale context across integrated login#28
xrpbanks wants to merge 3 commits into
mainfrom
feature/identity-bridge-v1-ib2

Conversation

@xrpbanks

@xrpbanks xrpbanks commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Outcome

Carries one canonical locale through the CalorieApp / WordPress / Xaman login transaction and rejects state/locale mixing before an authorization code is issued.

Scope

  • binds the resolved locale to a hashed, short-lived backend login state in an additive table
  • propagates locale through start, state validation, callback, origin-browser status, WordPress transient flow and iframe messages
  • resolves WordPress locale automatically for [calorieapp_embed], with an optional locale attribute for controlled previews
  • keeps locale as ephemeral request context, not identity authority or a persisted profile preference
  • freezes an eleven-locale automated login/failure matrix
  • uses calorieapp.identity-bridge-login-test-matrix and locks that identifier with a contract assertion

Current reviewed state

  • base: main at 8d1e30f44db671e960e190f517489bcb88164c60
  • head: 4be9e99ac566ef38cf85fc967d7a9e6e78a3ddac
  • reviewed tree: d257a150793b64d1092b370f6764ebdc50985312
  • 20 changed files, +582/-48; no scope drift after restack
  • 36ba4c8 is the non-force merge commit with parents old IB-2: bind locale context across integrated login #28 head 6c5466c and merged main; 4be9e99 is an empty synchronization commit with the identical tree, used only because retargeting the base did not itself emit the required Actions event

Automated verification

  • GitHub CI run 108 passed all four jobs on exact head 4be9e99
  • 238 backend tests passed; backend dependency audit found no known vulnerabilities
  • frontend lint, type checking, production build and embedded login/locale/retry tests passed
  • Identity Bridge and localization contracts passed; all three runtime locale copies are current
  • legal/licensing boundary and tracked-artifact checks passed
  • WordPress PHP lint, legal-footer compatibility, locale-registry regression, deterministic release tests and archive inspection passed
  • the production npm audit passes the repository's critical-severity gate; two existing high-severity Next.js/PostCSS advisories remain outside this PR's changes
  • targeted pre-push checks also passed: 154 backend identity tests, 6 Node login/locale tests, 6 contract tests and 5 releasebuilder tests

Deliberately excluded

  • no merge or deployment
  • no public copy translation or visual redesign
  • no profile, name, email, donation, rich-list or market-data expansion
  • no Open Food Facts contribution link yet; that remains a bounded CalorieApp content task after the login and durable-storage foundations
  • no showcase publishing

PR #27 is merged. This PR is retargeted to main, remains draft and still requires human review plus a separate merge GO.

@xrpbanks
xrpbanks changed the base branch from feature/identity-bridge-v1-ib1 to main August 30, 2026 04:28
@xrpbanks xrpbanks closed this Aug 30, 2026
@xrpbanks xrpbanks reopened this Aug 30, 2026
@xrpbanks
xrpbanks changed the base branch from main to feature/identity-bridge-v1-ib1 August 30, 2026 04:31
Correct the CalorieApp login matrix contract identifier and lock it with a contract assertion.
@xrpbanks
xrpbanks changed the base branch from feature/identity-bridge-v1-ib1 to main August 30, 2026 15:09
No file content changes; preserve the reviewed tree.
@xrpbanks
xrpbanks marked this pull request as ready for review August 30, 2026 15:30
Copilot AI lite review requested due to automatic review settings August 30, 2026 15:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]
);
}
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.

2 participants