Skip to content

fix(desktop): local-session 403 no longer forces register/login - #87

Closed
XYAIStudio wants to merge 1 commit into
mainfrom
cursor/desktop-local-session-403-150a
Closed

XYAIStudio wants to merge 1 commit into
mainfrom
cursor/desktop-local-session-403-150a

Conversation

@XYAIStudio

Copy link
Copy Markdown
Owner

Summary

Desktop 0.0.4 still showed the old register/login wall because POST /api/auth/local-session returned 403 Forbidden (user host.log: repeated 403s, then AuthGuard fell through to /login).

Root cause: the endpoint only auto-picked an existing user when OCTOP_DESKTOP was visible. Returning ~/.freeos DBs often have extra rows (org-mapped users). On Windows, a leftover OCTOP_DESKTOP=0 in the parent env also shadowed the shell’s =1 (CreateProcess keeps the first duplicate). Separately, React Router replaced /?desktop=1 with /projects before AuthGuard could remember the Wails shell, so retries were not treated as desktop.

What changed

  • Loopback / *.localhost / Origin-or-Referer-on-this-device always adopt a studio session (guest or preferred existing admin). Remote clients still get 403.
  • Windows launch env overlays parent keys so OCTOP_DESKTOP=1 wins.
  • SPA captures ?desktop=1 at boot and preserves it on //projects; desktop shell never navigates to login.
  • Empty Authorization: Bearer is no longer forwarded to organization identity (the Illegal header value b'Bearer ' noise).

Before / after

Before After
Fresh desktop local-session 403 → register/login guest JWT → optional model setup → /chat/main
Returning ~/.freeos, no JWT 403 (multi-user or env shadow) → login existing studio user JWT → chat (model wizard only if no providers yet)
Remote Host: example.com 403 403 (unchanged)

Test plan

  • uv run pytest tests/unit/users/test_local_session.py tests/integration/test_local_session.py tests/unit/api/test_jwt_auth_middleware.py tests/unit/api/test_org_identity.py tests/unit/test_org_integration.py
  • npx vitest run AuthGuard / Login / desktopShell / request.setup
  • npx tsc --noEmit in dashboard/
  • make all (not run in this agent; CI on the PR)
  • CHANGELOG Unreleased

Packaging / Windows rebuild is left to the coordinator after merge.

Target branch

  • Base is main (urgent desktop hotfix; user-requested)
Open in Web Open in Cursor 

Packaged WebView retries of POST /api/auth/local-session were returning
403 when the existing ~/.freeos DB had more than one user or OCTOP_DESKTOP
was shadowed on Windows, then AuthGuard dropped into register/login.

Issue a studio JWT on this device (loopback, *.localhost, Origin, or
desktop env), overlay launch env so Windows keeps OCTOP_DESKTOP=1, and
remember ?desktop=1 before the SPA replaces / with /projects.

Co-authored-by: XYAI Labs <haoboy8@gmail.com>
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