Skip to content

Add Lexbox login to the Platform.Bible lexicon extension#2428

Draft
imnasnainaec wants to merge 6 commits into
developfrom
pb-ext-lexbox-login
Draft

Add Lexbox login to the Platform.Bible lexicon extension#2428
imnasnainaec wants to merge 6 commits into
developfrom
pb-ext-lexbox-login

Conversation

@imnasnainaec

@imnasnainaec imnasnainaec commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

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-ancestors CSP unknowns an embedded login page would hit.

  • FwLiteWeb: new GET /api/auth/login-web-view/{authority} endpoint that invokes AuthService.SignInWebView when SystemWebViewLogin is enabled and returns the LoginResult. The existing /login/{authority} endpoint is redirect-based and requires a Referer header, so it doesn't fit this mode; it still throws NotSupportedException there.
  • Extension: FwLiteApi gains getAuthServers()/login()/logout(); new lexicon.authServers, lexicon.login, and lexicon.logout commands; 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:

  • Sign-in can outlive the 30s PAPI request timeout. login-web-view blocks until the user finishes or cancels in the browser; if that exceeds platform.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?
  • External login-state changes aren't pushed to the webview. It fetches status on open and after its own login/logout only, so a sign-in/out done elsewhere (e.g. the embedded viewer) won't reflect until reopen. Acceptable for now, or worth a subscription?
  • Local API hardening before shipping. FwLiteWeb still runs with --FwLiteWeb:CorsAllowAny=true on a fixed localhost port; now that users can be signed in, that local API is more sensitive. Not addressed here — flagged for follow-up.
  • Non-success sign-in outcomes are logged, not shown. lexicon.login now returns the LoginResult and 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

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>
@github-actions github-actions Bot added 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related 📙 Platform.Bible labels Jul 8, 2026
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2305f2cd-8dd9-43cb-a829-2a6402479177

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pb-ext-lexbox-login

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@argos-ci

argos-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jul 9, 2026, 7:23 PM

@hahn-kev hahn-kev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Comment thread backend/FwLite/FwLiteWeb/Routes/AuthRoutes.cs Outdated
imnasnainaec and others added 2 commits July 8, 2026 12:37
- 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
imnasnainaec and others added 3 commits July 9, 2026 13:38
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related 📙 Platform.Bible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Lexbox login to the Platform.Bible lexicon extension

3 participants