Fix Xaman return across mobile browsers - #12
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Xaman authentication flow so the original CalorieApp tab can remain open while authentication completes in a separate tab/browser, then securely “hands back” authentication to the original tab via a short-lived, one-time proof. It also adds dedicated “launching” and “complete” UX pages and introduces backend support for polling login completion (including replay protection).
Changes:
- Frontend: open Xaman sign-in in a separate tab/window, poll backend for completion, and show explicit launching/completion pages.
- Backend: add an origin-browser handoff token model + identity service helpers, plus a new
/api/identity/login/statusendpoint to claim the session once. - Tests/docs: expand identity tests for the handoff behavior and document the cross-browser return flow.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new cross-browser/tab Xaman return + handoff design. |
| frontend/components/XamanLoginPanel.tsx | Opens a separate sign-in tab, polls /api/identity/login/status, and displays success messaging. |
| frontend/app/auth/launching/page.tsx | Adds a dedicated “preparing sign-in” page for the new tab. |
| frontend/app/auth/complete/page.tsx | Adds a completion/confirmation page with safe local redirect handling. |
| frontend/app/auth/callback/page.tsx | Redirects callback to /auth/complete and sets a sessionStorage flag for messaging. |
| frontend/app/api/backend/[...path]/route.ts | Allow-lists the new backend route api/identity/login/status through the proxy. |
| backend/tests/test_identity.py | Adds service-level tests for origin handoff token hashing, status transitions, and cleanup. |
| backend/tests/test_identity_endpoints.py | Adds endpoint tests for cross-browser completion and replay/claim behavior. |
| backend/app/services/identity.py | Implements origin login handoff creation/validation/claiming helpers. |
| backend/app/schemas.py | Adds request/response schemas for login status polling and start response token. |
| backend/app/models.py | Adds OriginLoginHandoffDB table for one-time handoff proof state. |
| backend/app/main.py | Adds /api/identity/login/status, issues the handoff token on start, and completes/fails the handoff on callback. |
Suppressed comments (1)
frontend/components/XamanLoginPanel.tsx:202
loginWindow.opener = nullcan throw if the named window already exists and has navigated cross-origin (e.g., a previous login attempt left the external tab open). Wrap this assignment so a reusable cross-origin window doesn't cause the whole login flow to error.
loginWindow.opener = null;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+164
to
+167
| const loginWindow = window.open( | ||
| "/auth/launching", | ||
| "calorieapp-xaman-login" | ||
| ); |
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.
Summary
Verification
release-check.ps1changesDo not merge until all GitHub checks are green.