Add Lexbox login to the Platform.Bible lexicon extension#2428
Add Lexbox login to the Platform.Bible lexicon extension#2428imnasnainaec wants to merge 6 commits into
Conversation
Use the system-browser OAuth flow (Auth:SystemWebViewLogin=true, as FW Lite desktop does) via a new FwLiteWeb /api/auth/login-system endpoint, and surface per-server sign-in status with login/logout buttons in the Select Lexicon webview. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
hahn-kev
left a comment
There was a problem hiding this comment.
this looks good to me. One thing you should watch out for is fetch timeouts. If the user isn't logged in to lexbox (likely) then it might take them a while to login to lexbox, so a normal 30s timeout for a fetch might timeout. This isn't a problem on FW Lite because the browser path uses redirect, and the desktop path doesn't trigger the web view login via fetch so it can await forever.
- Rename /login-system endpoint to /login-web-view to match SignInWebView - Remove unused AuthRoutes.ServerStatus record (dead code) - Document logout's reliance on papi.fetch following the backend redirect - Guard the post-login-failure auth refresh so it can't mask the login error Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts: # platform.bible-extension/src/main.ts
Addresses PR review feedback:
- Alias LexboxServer/AuthServerStatus/LoginResult to the backend-generated
@dotnet-types instead of hand-maintaining copies, so they can't drift from
the C# models the REST API returns. This also drops the loggedInAs
string|null vs optional discrepancy.
- lexicon.login now returns { result, servers } instead of discarding the
LoginResult, so the caller can tell success from failure (Offline /
Cancelled / a swallowed hard error). The Select Lexicon web view surfaces a
non-success, non-cancel outcome via the logger.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Select Lexicon sign-in status tracked a single pending authority, so starting a second server's login/logout re-enabled the first server's button mid-flight and its .finally() cleared the other row's pending state. Track pending authorities in a Set so each row's button disables independently. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
getAuthServers resolves to undefined on failure, and lexicon.login/logout include it as their refreshed server list. Pushing that undefined straight into state made AuthStatus render nothing, so a transient localhost fetch failure right after a successful sign-in/out blanked the whole auth section until the webview reopened. Route refreshes through applyServers, which keeps the previous list when the new value is undefined (an empty array still clears it). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds sign-in to Lexbox from the Platform.Bible lexicon extension, unblocking future account-based features (remote project listing, download, send/receive — out of scope here per the issue).
Uses the system-browser OAuth flow (
--Auth:SystemWebViewLogin=true, same as FW Lite desktop): MSAL opens the user's default browser and listens on a localhost redirect, avoiding the webview-sandbox /frame-ancestorsCSP unknowns an embedded login page would hit.GET /api/auth/login-web-view/{authority}endpoint that invokesAuthService.SignInWebViewwhenSystemWebViewLoginis enabled and returns theLoginResult. The existing/login/{authority}endpoint is redirect-based and requires a Referer header, so it doesn't fit this mode; it still throwsNotSupportedExceptionthere.FwLiteApigainsgetAuthServers()/login()/logout(); newlexicon.authServers,lexicon.login, andlexicon.logoutcommands; the Select Lexicon webview shows each configured server's sign-in status with a Log in / Log out button, including a pending state while the browser sign-in is in flight.Design points for review:
login-web-viewblocks until the user finishes or cancels in the browser; if that exceedsplatform.requestTimeout(default 30s) the command reply times out even though sign-in still completes. The webview refreshes status on timeout, so a sign-in that lands shortly after usually still shows up — but one finishing well after won't surface until the webview reopens. The timeout also only rejects the webview→host command: the underlying HTTP request to FW Lite stays open (no server-side timeout), so repeatedly triggering and abandoning sign-in leaves pending requests on the FW Lite process until each browser flow resolves. A durable fix is server-side (a timeout/cancellation on the endpoint, or honoring request cancellation), not client-side. Is refresh-on-timeout good enough for now, or is a per-request-type timeout (via paranext-core's shared store) or polling worth it?--FwLiteWeb:CorsAllowAny=trueon a fixed localhost port; now that users can be signed in, that local API is more sensitive. Not addressed here — flagged for follow-up.lexicon.loginnow returns theLoginResultand the webview logs a warning for a non-success/non-cancel outcome (e.g.Offline), but shows no targeted user-facing message. Is a visible "you appear to be offline" / failure notice wanted, or is the silent status refresh enough?Testing note: FwLiteWeb's production config registers only
https://lexbox.org; testing a packaged extension against staging needs extra--Auth:LexboxServers:*args.Closes #2426
🤖 Generated with Claude Code